Abaqus python脚本:从共享相同坐标的两个连接器中选择一个

2024-04-18 02:41:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在编写一个脚本,该脚本自动在Abaqus中创建模型。在模型中,两个连接件图元应用于两个实例的两个节点。第一个连接器从实例1上的点a开始,到实例2上的点b结束。第二个连接器工作,反之亦然。这意味着两个连接器显然共享相同的坐标和重叠。用光标拾取基础连接件不是问题,但是自动执行此步骤并拾取基础连接件以指定截面是我遇到的问题,因为您无法使用findAt()方法,因为它总是拾取顶部连接件。这两条导线都已实现,但将截面指定给第二个接头不起作用。我是否可以使用getSequenceFromMask访问第二个底层连接器

我认为这与如何找到边有关,并且在创建连接器的导线时,可能会创建边的名称或设置。我可以将getSequenceFromMask中的掩码指定为第二个连接器的所需边吗? 这是循环的一部分。坐标来自库,截面的名称来自列表

mdb.models['Model-1'].rootAssembly.WirePolyLine(mergeType=IMPRINT, meshable=False, points=((
    mdb.models['Model-1'].rootAssembly.instances[ListeGConZug[0]].vertices.findAt((
    dctX2['XKoordLLZ_%s' % ladida[i]][y], dctY2['YKoordLLZ_%s' % ladida[i]][y], dctZ2['ZKoordLLZ_%s' % 
   ladida[i]][y]), ), 
mdb.models['Model-1'].rootAssembly.instances[ladida[i]].vertices.findAt((
   dctX3['XKoordLLE_%s' % ladida[i]][y], dctY3['YKoordLLE_%s' % ladida[i]][y], dctZ3['ZKoordLLE_%s' % 
   ladida[i]][y]), )), ))
mdb.models['Model-1'].rootAssembly.features.changeKey(NameWire[-1], 
   toName=NameWire[-1])
mdb.models['Model-1'].rootAssembly.Set(edges=
   mdb.models['Model-1'].rootAssembly.edges.findAt(((dctX3['XKoordLLE_%s' % ladida[i]][y], 
   dctY3['YKoordLLE_%s' % ladida[i]][y], dctZ3['ZKoordLLE_%s' % ladida[i]][y]), )), 
   name=NameWireSetConGZug[-1])
mdb.models['Model-1'].rootAssembly.SectionAssignment(region=
   mdb.models['Model-1'].rootAssembly.sets[NameWireSetConGZug[-1]], sectionName=
   NameWireSetConGZug[-1])

Tags: 实例模型脚本名称modelmodels基础mdb
1条回答
网友
1楼 · 发布于 2024-04-18 02:41:25

WirePolyLine(Abaqus脚本参考指南)的文档中:

points: A tuple of point pairs, each pair being itself represented by a tuple. For part level features each point can be a Vertex, Datum point, Reference point, orphan mesh Node, or InterestingPoint object specifying the points through which the polyline wire will pass. Each point can also be a tuple of Floats representing the coordinates of a point. For assembly level features each point can only be a Vertex, Reference point, or orphan mesh Node specifying the points through which the polyline wire will pass (coordinates cannot be specified). In any of the pairs, the first or second point can be NONE. In that case, the point pair will create a zero-length wire, which is required for certain types of connectors. You must specify at least one pair.

因此,您可以在每个实例上创建一个参考点,并使用它们定义导线对象,也可以直接使用顶点(如果使用孤立网格,则使用节点)


只是对代码的注释:尝试使用变量和格式,以便代码清晰易读。例如:

m = mdb.models['Model-1']
a = m.rootAssembly

points = (
    a.instances[ListeGConZug[0]].vertices.findAt((
        dctX2['XKoordLLZ_%s' % ladida[i]][y],
        dctY2['YKoordLLZ_%s' % ladida[i]][y],
        dctZ2['ZKoordLLZ_%s' % ladida[i]][y]),
    ),
    #<...the rest of your points definition>
)

wire_feature = WirePolyLine(mergeType=IMPRINT, meshable=False, points=(points, )

在似乎不可能找到“导线”边缘时,为所有搜索该边缘的人更新

如OP所示,有时似乎无法确定Abaqus是否会选择正确的边作为findAt方法的结果。例如,如果在同一位置有多个接头和/或接头是位于同一坐标位置的连接节点,则可能发生这种情况。我找到了一个很好的解决办法

调用WirePolyLine方法时:

  1. 在rootAssembly级别创建边(重要!)
  2. 创建一个Feature对象
  3. 返回Feature对象

Feature对象只有两个成员:nameid。因此,不可能直接使用它来创建分配连接器节所需的Set(请参阅SectionAssignment方法文档)。但是,由于导线的边是在rootAssembly级别创建的,因此我们可以循环通过在所需位置找到的所有边,并使用具有良好featureName的边

pos = (-5., 0., 0.)  # For example, this is the point where we are searching for our Wire

for edg in a.edges.findAt((pos,)):
    if edg.featureName == wire_feature.name:
        break

相关问题 更多 >