×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Creating sets using the Python API

Creating sets using the Python API

Creating sets using the Python API

(OP)
I created a simple box and meshed it & I would like to create 2 sets one that contains the central elements & a second that contains all the surrounding elements.

I can calculate quite trivially which elements I want in each set but I'm having problems creating the sets. I created a few sets in CAE and then inspected the *.jnl files to find the method but I just don't understand what I'm seeing, for instance,

CODE --> python

mdb.models['Model-1'].parts['Part-1'].Set(elements=mdb.models['Model-1'].parts['Part-1'].elements.getSequenceFromMask(mask=('[#0:10 #4 #0:3 #12 ]', ), ), name='Set-1') 

The above is what I get when I manually select elements in the CAE window, the numbers in no way match up with the element numbers that I picked.

I've been pouring over the Reference Manual but so far cant find a set generator method where I can just list the element numbers. I'm pretty sure there is one though.

Thanks

RE: Creating sets using the Python API

You have to change the /CAE python journal settings to INDEX.
Place the code below in a abaqus_v6.env, restart /CAE and create the set again. Now your .rpy file should look a bit different.

CODE

def onCaeStartup():
    session.journalOptions.replayGeometry
    session.journalOptions.setValues(replayGeometry=INDEX) 

RE: Creating sets using the Python API

(OP)
Unfortunately I dont have admin rights on this computer to do that.

RE: Creating sets using the Python API

Place the file in your work directory to get these options at least there.

RE: Creating sets using the Python API

(OP)
do you mean put a copy of the amended abaqus_V6.env in my working directory?

I just tried that but it hasnt change the output in the *.jnl file. Its still using 'elements.getSequenceFromMask'

RE: Creating sets using the Python API

Try to create a new empty text file in your work directory. Add my code, save the file and then rename it to abaqus_v6.env. Then restart /CAE in that directory and try again.

RE: Creating sets using the Python API

(OP)
Tried it, no luck, still the same.

RE: Creating sets using the Python API

(OP)
I found the following method,

CODE --> Python

mdb.models['Model-1'].parts['Part-1'].Set(elements=mdb.models['Model-1'].parts['Part-1'].elements.getFromLabel(1, 2, 3, 4, ), name='testing') 

Which gives the following error,

TypeError: too many arguments; expected 1, got 4

So I tried,

CODE --> Python

elList = [1,2,3,4]
mdb.models['Model-1'].parts['Part-1'].Set(elements=mdb.models['Model-1'].parts['Part-1'].elements.getFromLabel(elList), name='testing') 

Which gave the error,

TypeError: arg1; found tuple, expecting int

So then I tried,

CODE --> Python

mdb.models['Model-1'].parts['Part-1'].Set(elements=mdb.models['Model-1'].parts['Part-1'].elements.getFromLabel(1), name='testing') 

Which gave the following error,

TypeError: elements; found MeshElement, expecting tuple

Puzzling...

RE: Creating sets using the Python API

See Scripting Reference Guide 45.4.5 SetFromElementLabels()

RE: Creating sets using the Python API

(OP)
Thanks Mustaine very much appreciated.

RE: Creating sets using the Python API

(OP)
Just one more thing, would you know where there is a list of available internal variables for the API?

eg number of elements, how to access lists of elements in each set etc

RE: Creating sets using the Python API

(OP)
Scratch that I worked it out :D

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources