1

I am using python in Abaqus to print coordinates of specific nodesets. I am currently able to find the nodelabel, and x-y-z coordinates of each printed node. I also would like to print the instance (or nodeset) name each node belongs to, so I can manually check if my programs works right.

This is my code;

# Define list with with partnames
PartNames = ["C7", "T1", "T2", "T3", "T4", "T5", "T6", "T7", "T8", "T9", "T10", "T11", "T12",
             "L1", "L2", "L3", "L4", "L5", "S1"]
modelname = "SpineModel"

# Create lists to write data to
PartLevelLeft = []
aLabels, axcoords, aycoords, azcoords = [],[],[],[]

for i in range(len(PartNames)-1): # S1 does not contain screws
    PartLevelLeft = mdb.models[modelname].rootAssembly.sets["Screw['" + PartNames[i] + "_L']"]

    # Create lists to write data to, otherwise only the last printed set is used
    partlabelL, partxcordL, partycordL, partzcordL, instanceL  =[], [], [], [], []

    for curNode in PartLevelLeft.nodes:
        partlabelL.append(curNode.label)
        partxcordL.append(curNode.coordinates[0])
        partycordL.append(curNode.coordinates[1])
        partzcordL.append(curNode.coordinates[2])
        instanceL.append(curNode.instanceName)

    # create the list to save all coordinates
    aLabels, axcoords, aycoords, azcoords, instancename = [],[],[],[], []

    aLabels.append(partlabelL)
    axcoords.append(partxcordL)
    aycoords.append(partycordL)
    azcoords.append(partzcordL)
    instancename.append(instancename)

    pt1L = [axcoords[0][0], aycoords[0][0], azcoords[0][0]]
    pt1PartlabelL = aLabels[0][0]
    pt1InstanceName = instancename

    print('pt1L = ', pt1L, 'pt1PartlabelL = ', pt1PartlabelL, 'pt1InstanceName = ', pt1InstanceName)

But when I print the first point (x,y,z), label and instancename, the instancename array appears empty, see photo;

Does anyone know how to fix this? Thank you in advance

JetskiS
  • 31
  • 4

1 Answers1

0

I think it's because you don't get the name. If I keep the code concerning name, I get:

# Define list with with partnames
PartNames = ["C7", "T1", "T2", "T3", "T4", "T5", "T6", "T7", "T8", "T9",
             "T10", "T11", "T12",
             "L1", "L2", "L3", "L4", "L5", "S1"]
modelname = "SpineModel"
for i in range(len(PartNames) - 1):  # S1 does not contain screws
    PartLevelLeft = mdb.models[modelname].rootAssembly.sets[
        "Screw['" + PartNames[i] + "_L']"]
    instancename = []
    instancename.append(instancename)
    pt1InstanceName = instancename

    print('pt1L = ', pt1L, 'pt1PartlabelL = ', pt1PartlabelL,
          'pt1InstanceName = ', pt1InstanceName)

As you can see, you set pt1InstanceName as an empty list with an empty list in it instancename.append(instancename).

I think you should add something like pt1InstanceName = PartLevelLeft.name (but as I don't have Abaqus, I can't tell you the exact attribut).

PS: with the aLabels, axcoords, aycoords, azcoords, instancename = [],[],[],[], [] line in the loop, your list won't grow as they are reinitialized at each turn of the loop.

ndclt
  • 2,590
  • 2
  • 12
  • 26