简体   繁体   中英

How to create set from list of sets in Python?

In abaqus Python script, several Plies have a large number of copies, each of which has many fibers. In each Fiber, a set of edges has been selected: App1-1, App1-2, ..., App99-1, App99-2, ..., App99-88. How to create a new set that will contain all or some of these set of edges? Thank you.

Code:

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)

I can guess it should be something like this:

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

but I'm not sure about this and I have no idea about correct syntax

I tested the following on a simple part and it worked for me. I think you could adapt this to achieve what you're trying to do for your specific model. The key is the part.EdgeArray type. For whatever reason Abaqus requires your edges be supplied within that type, rather than a simple list or tuple. The Abaqus documentation is not clear on this, and when you pass a list of edges it will fail with a vague error: 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))

For others that may find themselves here - similar types are available for vertices, faces, and cells: part.VertexArray , part.FaceArray , and part.CellArray .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM