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!

Assign material to all parts In Abaqus using python 2

Status
Not open for further replies.

Luca_Riga

Aerospace
Feb 25, 2017
3
Hi at all,
I'm trying to learn python for Abaqus.
I need help to write my first script that should be an automatic assignment of materials
to all parts in a model.
I've obtained a sort of result using the .rpy file create recording a macro but i'm not able to
repeat the assignment for the other parts in the model
 
Replies continue below

Recommended for you

What exactly is the problem?

Overall it is not a difficult task. For solids it would be like that: Iterate through all parts, get all the cells of each part and then assign the section to those cells.
 
Thankyou for reply
The real problem is my inexperience about scripts in Abaqus,
I guess that this is not a difficult problem but i don't understand how cycling
on all parts.
Would you be so kind to provide me an example about this?
 
Here is an example. It assumes, that the name of the existing section is provided in the script. Otherwise it would be simple to ask the user for the name during runtime or to query the existing sections and use one with a specific name or type. Lets also assume, that this script is intended to work for solid regions (cells) and your model is called 'Model-1' (default).

Code:
from abaqus import *
from abaqusConstants import *
import regionToolset

m = mdb.models['Model-1']
mysectionname = 'Section-Steel'

print '\nUsed section: '+mysectionname
print 'Used regions:'

for mypartname in m.parts.keys():
    p = m.parts[mypartname]
    number_cells = len(p.cells)
    if number_cells > 0:
    	myregion = regionToolset.Region(cells=p.cells[0:(number_cells)])
    	p.SectionAssignment(region=myregion, sectionName=mysectionname, offset=0.0)
    print mypartname+' -> '+str(number_cells)+' Cell(s)'

m.rootAssembly.regenerate()

The existing part names are stored in a dictionary and with keys() you can get the names and directly use them in a for-loop. Then you can use each name to access each part. Afterwards the cells are queried and every cell is used with pythons list slicing [:]. This is necessary in cases where a part is partitioned and consists of more than one cell.
Parts without cells are ignored.
 
This will be very helpful for me
thanks so much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor