I have a tuple called E3 containing element numbers, for instance:
(array([ 136, 2593, 3061, 4348], dtype=int64),)
Now, I would like to define the set of these elements.
Until now, I haven’t succeeded to do something more “systematic” than
mdb.models[‘Model-1’].rootAssembly.Set(elements=
mdb.models[‘Model-1’].rootAssembly.instances[‘Part-1-1’].elements[E3[0][0]:E3[0][0]+1]+
mdb.models[‘Model-1’].rootAssembly.instances[‘Part-1-1’].elements[E3[0][1]:E3[0][1]+1]+
mdb.models[‘Model-1’].rootAssembly.instances[‘Part-1-1’].elements[E3[0][2]:E3[0][2]+1]+
mdb.models[‘Model-1’].rootAssembly.instances[‘Part-1-1′].elements[E3[0][3]:E3[0][3]+1]
, name=’Set-0’)
Unfortunately, E3 is variable and usually has an arbitrary and large number of elements, so this is not practical at all.
I would love something like this:
mdb.models[‘Model-1’].rootAssembly.Set(elements=
mdb.models[‘Model-1’].rootAssembly.instances[‘Part-1-1′].elements[E3], name=’Set-0’)
but “TypeError: Invalid index type tuple”.
Or something like this:
mdb.models[‘Model-1’].rootAssembly.Set(elements=
mdb.models[‘Model-1’].rootAssembly.instances[‘Part-1-1′].elements[E3[0]], name=’Set-0’)
but “TypeError: only integer scalar arrays can be converted to a scalar index”.
Do you know a systematic way a creating a set from a tuple with element numbers?
Victor Fachinotti is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.