Search code examples
pythonabaqus

Extract node set coordinates in abaqus using python script


I would like to extract the Node set coordinates using a python script. i tried with two different methods: The first from an odb file :

import sys
from odbAccess import *
from abaqus import *
from abaqusConstants import *
import __main__

odb = openOdb('C:/Temp/Job-1.odb')
set = odb.rootAssembly.instances['part-1'].nodeSets['Set-1']

numNodes = len(set.nodes)
partlabel=[];
partxcord=[];
partycord=[];
partzcord=[];
for curNode in a.nodes:
    partlabel.append(curNode.label)
    partxcord.append(curNode.coordinates[0])
    partycord.append(curNode.coordinates[1])
    partzcord.append(curNode.coordinates[2])

The error displayed is : keyerror : Set-1. knowing that when I defined the same syntax for the coordinates of the instance nodes, it works correctly.

myInstance = odb.rootAssembly.instances['part-1']

The second method is using Mdb commands :

 set = mdb.models['Model-1'].rootAssembly.instances['part-1'].sets[Set-1]

It doesn't work too and the error is : Model-1

I would be very grateful if you help me solve this problem


Solution

  • When you assemble the parts (in Assembly Module), you actually assemble the instance of the parts and NOT the part itself. However, you can still access the part information, such as, surfaces, sets, nodes, elements, etc.
    For ODB (output database):
    You can access Assembly information using: odb.rootAssembly.
    and the part information through the instance using:
    odb.rootAssembly.instances['<instance name>'].
    and directly the part information using: odb.parts['<part name>']

    For MDB (model database):
    You can access Assembly information using:
    mdb.models['<Model name>'].rootAssembly.
    and the instance information using:
    mdb.models['<Model name>'].rootAssembly.instances['<instance name>']
    and directly the part information using:
    mdb.models['<Model name>'].parts['<part name>']

    For example, accessing the element set from part and asssembly:

    # Let's consider, 'ASM_ELSET' is an element set created at the assembly level
    # and 'PRT_ELSET' is an element set created at the part 'PART-1'.
    
    # Access assembly level set
    aset = odb.rootAssembly.elementSets['ASM_ELSET']
    
    # Access part level set through the instance
    pset = odb.rootAssembly.instances['PART-1-1'].elementSets['PRT_ELSET']
    

    Please note that 'PART-1-1' is instance name for part 'PART-1.