Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Element selection by python script - Abaqus

Status
Not open for further replies.

AbhishekM

Mechanical
Oct 22, 2019
2
Hello all,

I am having trouble selecting elements from Abaqus using python script, it needs to be adaptable to varying mesh size and varying sample length/area.

I am trying to generalize part of script for element selection in pre-processing and using the element sets for use in post processing. I have searched and thought that I got the solution using one of the other questions, but I having a different error. I ran this for a 2D model in Abaqus PDE 2017 version.

I have read these questions :
1. Selecting multiple partitioned regions in ABAQUS with findAt for setting mesh controls
2. Abaqus: script to select elements on a surface
3. Selecting elements in Mesh Part (Orphan Mesh)

I am also attaching my code

Python:
length=float(120) 
height1=float(3)
height2=float(0.7)
th=float(45)
ElemSize=float(0.1)
dms=float(4)
crack=float(10)
crack_offset=float(8.5)  

a = mdb.models['xxxxxx'].rootAssembly

RP_Cent = a.ReferencePoint(point=(length-th+crack+crack_offset,2*height1+height2,0))
a.features.changeKey(fromName='RP-1', toName='RP_Cent')
RP_Left = a.ReferencePoint(point=(length-th+crack+crack_offset-dms/2,2*height1+height2,0))
a.features.changeKey(fromName='RP-1', toName='RP_L')
RP_Right = a.ReferencePoint(point=(length-th+crack+crack_offset+dms/2,2*height1+height2,0))
a.features.changeKey(fromName='RP-1', toName='RP_R')

e1 = a.instances['Upper_Adh'].elements
Cent = e1.getByBoundingBox(length-th+crack+crack_offset-dms/2, 2*height1+height2-ElemSize, 0, 
                           length-th+crack+crack_offset+dms/2, 2*height1+height2, 0) 
a.Set(elements=Cent, name='Centroid_Elements')

The reference points are getting generated so the co-ordinates are not wrong.

I had expected the created set to be of element type and have 10 elements, however the set created is of geometry type and ofcourse has no elements. Error Screenshot. Please suggest a correction to my code or a better approach.

All help is appreciated.


 
Replies continue below

Recommended for you

Make a simple example, adopt the script to that (as good as possible) and attach the .cae file and the script here. Then I can run it, see what happens and suggest something.
 
Hi @Mustaine3,
I am so happy that you responded. Have read too many of your replies.

Mustaine3 said:
Make a simple example, adopt the script to that (as good as possible) and attach the .cae file and the script here. Then I can run it, see what happens and suggest something.

As per your suggestion I was making a fresh model to upload here, but it so happened that the code generated element sets for both 2D and 3D parts the way I wanted them to. However the same code is not working in existing models. Could you somehow explain why.

Also could you let me know how to read / extract a particular reference point's x,y,z co-ordinates for use in python code, without having to use the query function.

Regards,
Abhishek M

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor