Carlos Borau
Carlos Borau

Reputation: 1473

Create a node set in Abaqus programatically (python scripting)

I would appreciate if someone could tell me what I'm missing. I'm trying to create a geometry-dependent set of nodes from a merged instance part. Once generated the geometry, the instances, merged and meshed the resulting part, the code reads:

all_nodes = model_assembly.instances[merged_part_instance_name].nodes
left_nodes = []
bottom_nodes = []
for n in all_nodes:
    xcoord = n.coordinates[0]
    ycoord = n.coordinates[1]
    if xcoord > xmin and xcoord < xmax:
        left_nodes.append(n)
    if ycoord > ymin and ycoord < ymax:
        bottom_nodes.append(n)

With the code above, I have a list of 'MeshNode objects', so writing this works fine:

model_assembly.Set(nodes=all_nodes, name='Set-all')

However, when I write:

model_assembly.Set(nodes=left_nodes, name='Set-left')

it gives me the error Feature creation failed. I checked in the CAE console, and both all_nodes[0] and left_nodes[0] have the same structure:

mdb.models['mymodel'].rootAssembly.instances['merged_part_instance'].nodes[x] # x may differ

Nonetheless, I noticed that printing the lists gave different results:

>>>print(all_nodes)
['MeshNode object', 'MeshNode object', ...

>>> print(left_nodes)
[mdb.models['mymodel'].rootAssembly.instances['merged_part_instance'].nodes[57], mdb.models['mymodel'].rootAssembly.instances['merged_part_instance'].nodes[59],...

So, why are they different? Can I fix it or there is a better way to achieve this? Thanks in advance

Upvotes: 0

Views: 4745

Answers (1)

Carlos Borau
Carlos Borau

Reputation: 1473

It looks like the assembly.Set method needs specifically a MeshNodeArray as input, so doing this solved my problem:

good_left_nodes = mesh.MeshNodeArray(left_nodes)
model_assembly.Set(nodes=good_left_nodes , name='Set-left')

Upvotes: 1

Related Questions