Python: How to select all instances at once?
Python: How to select all instances at once?
(OP)
Hi everyone,
Using Python, I'm trying to select the faces of all instances with getByBoundingBox:
This is very tedious for many instances. Unfortunately, rootAssembly doesn't have the attribute faces, so I can't use
Is there an alternative way to select all faces with a bounding box?
Thanks very much!
Using Python, I'm trying to select the faces of all instances with getByBoundingBox:
CODE --> Python
faces = a.rootAssembly.instances['Part-1'].faces.getByBoundingBox(...)+ a.rootAssembly.instances['Part-2'].faces.getByBoundingBox(...)+ a.rootAssembly.instances['Part-3'].faces.getByBoundingBox(...)+ ...
This is very tedious for many instances. Unfortunately, rootAssembly doesn't have the attribute faces, so I can't use
CODE --> Python
faces = a.rootAssembly.faces.getByBoundingBox(...)
Is there an alternative way to select all faces with a bounding box?
Thanks very much!





RE: Python: How to select all instances at once?
RE: Python: How to select all instances at once?
My code is:
CODE
edges1 = [] for i in a.rootAssembly.instances: edges1.append(i.edges.getByBoundingBox(-1,-1,-1,1,1,1))]_____________________________________________________________________________________
Edit: I think I found the solution (maybe there's a simpler one?):
CODE
edges1 = [] for i in a.rootAssembly.instances.keys(): edges1.append(a.rootAssembly.instances[i].edges.getByBoundingBox(-1,-1,-1,1,1,1))]_____________________________________________________________________________________
Edit2: I have to do the second iteration, as you mentioned, as well:
CODE
edges1 = [] for i in a.rootAssembly.instances.keys(): for ii in a.rootAssembly.instances[i].edges.getByBoundingBox(-1,-1,-1,1,1,1): edges1.append(ii)_____________________________________________________________________________________
Edit3: I give up.. the above works for the edges, but not for faces. When I do it with faces, i get the error "TypeError: faces; found tuple, expecting GeomSequence"
Any help is appreciated, please.
RE: Python: How to select all instances at once?
CODE -->
a = mdb.models['Model-1'].rootAssembly for iname in a.instances.keys(): for xface in a.instances[iname].faces: print iname, xface.indexRE: Python: How to select all instances at once?