简体   繁体   中英

How to fix this loop error in python for abaqus?

I created an abaqus model with different parts and each part has the same node numbering. I'm trying to make a set that contains all nodes with labale of 180. I wrote this loop but it takes just the the last part's node. How can I correct this script to take all nodes with label of 180 from all parts?

for j in range(1,n):

    mdb.models['Model-1'].rootAssembly.SetFromNodeLabels(nodeLabels=(('part-'+str(j), (180, )), ), name='SETofNode180')

Through every iteration of the for loop a new node set is created and overwrites any existing node set. That's why you're only seeing one node set which contains a single node from the last part in your list.

You should construct a list of node labels separately and then call SetFromNodeLabels once, passing it a list of all the node labels.

nodeLabels = []

for j in range(1,n):
    nodeLabels.append( ('part-'+str(j), (180, )) )

mdb.models['Model-1'].rootAssembly.SetFromNodeLabels(nodeLabels=nodeLabels, name='SETofNode180')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM