The problem is 'm.rootAssembly.instances[\''+i+'\'].faces.getByBoundingBox(0,0,0,X,Y,Z'
gives you a string. It's not a Python expression. You may want to check out some Python tutorials to get an introduction to expressions, variables, and basic types, such as strings.
In your case you need to run what's in the string as an actual expression to get the returned face sequence, and build an array of faces from that. To make it more complicated, Abaqus returns their own internal type, Sequence
, when you call getByBoundingBox
. This type is a pain to work with because you can't create an empty one (at least not that I'm aware of). So dynamically building a list of faces for a set requires some extra attention. In the below code I get the face sequence for each rebar instance, and then add each individual face to my own list of faces
. Finally, to create the set, Abaqus is picky about the type on the faces
argument. We need to create a part.FaceArray
object for Abaqus to be satisfied.
import part
faces = []
for i in rebar_instances:
face_sequence = m.rootAssembly.instances[i].faces.getByBoundingBox(0,0,0,X,Y,Z)
faces += [f for f in face_sequence]
m.rootAssembly.Set(faces=part.FaceArray(faces), name='A')