0
rebar_set_command=[]

for i in rebar_instances:
 rebar_set_command.append('m.rootAssembly.instances[\''+i+'\'].faces.getByBoundingBox(0,0,0,X,Y,Z')

a='+'.join(rebar_set_command)

m.rootAssembly.Set(faces=a, name='A')

However it cannot be done because I think the value a in faces=a contains quotation marks.

How can I call the string to this Abaqus command without the opening and closing quote? Thanks!

1 Answer 1

0

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')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.