如何从Python中的集合列表创建集合?

时间:2018-09-30 00:03:39

标签: python arrays set abaqus

在abaqus Python脚本中,几个层具有大量副本,每个副本具有许多纤维。在每个光纤中,已选择一组边缘:App1-1,App1-2,...,App99-1,App99-2,...,App99-88。如何创建一个包含所有或部分这些边缘集的新集合? 谢谢。

代码:

allApps=[]
...
for i in range(Plies):
    ...
    for j in range (Fiber):
        appSet = Model.rootAssembly.Set(edges=
            Model.rootAssembly.instances['Part'+str(i+1)+'-'+str(1+j)].edges[0:0+1], 
            name='App'+str(i+1)+'-'+str(1+j))
        allApps.append(appSet)

我猜应该是这样的:

Model.rootAssembly.Set(name='allAppEdges', edges=.?.Array(allApps))

但是我不确定,也不知道语法正确

1 个答案:

答案 0 :(得分:1)

我简单地测试了以下内容,它对我有用。我认为您可以对此进行调整,以实现针对特定模型的目标。密钥是part.EdgeArray类型。无论出于何种原因,Abaqus都要求在该类型中提供边,而不是简单的列表或元组。 Abaqus文档尚不清楚,并且当您传递边列表时,它将失败并出现模糊错误:Feature creation failed

from abaqus import *
import part

mdl = mdb.models['Model-1']
inst = mdl.rootAssembly.instances['Part-1-1']

# Loop through all edges in the instance and add them to a list
my_edges = []
for e in inst.edges:
    my_edges.append(e)

# Create a new set with these edges
#mdl.rootAssembly.Set(name='my_edges', edges=my_edges) # This will fail because my_edges needs to be an EdgeArray
mdl.rootAssembly.Set(name='my_edges', edges=part.EdgeArray(my_edges))

对于可能会在这里找到自己的其他对象-顶点,面和单元格可以使用类似的类型:part.VertexArraypart.FaceArraypart.CellArray

相关问题