Search code examples
pythonabaqus

Field output object not iterable


I tried the follwing code and tried to read eseden from a nodeset. I get the following error as "Type error Field output object is not iterable".

Aravind

from odbAccess import *
from textRepr import *
from abaqusConstants import *
import odbAccess
odb=openOdb(path='python2d.odb')

NodesofInterest = odb.rootAssembly.instances['PART-1-1'].nodeSets['NODESET'] 

eseden=odb.steps['Step-1'].frames[1].fieldOutputs['ESEDEN'].getSubset(region=NodesofInterest)

for v in eseden:
    print v
    print (v.elementLabel,v.data)

Solution

  • The method getSubset called on fieldOutputs repository returns a FieldOutput object. That object contains a member values, which can be used to read values for a specific variable, 'ESEDEN' in your case.

    Member values is actually a FieldValueArray with FieldValue objects, each with all the necessary information about data for a single node.

    The reason you're getting an error is that 'FieldOutput' object is really not iterable, so to retrieve the actual information, you need to follow connections as I've just described.

    To make this description somewhat more clear, here's a simple example using your code:

    from odbAccess import *
    from textRepr import *
    from abaqusConstants import *
    import odbAccess
    
    odb=openOdb(path='python2d.odb')
    
    NodesofInterest = odb.rootAssembly.instances['PART-1-1'].nodeSets['NODESET'] 
    eseden=odb.steps['Step-1'].frames[1].fieldOutputs['ESEDEN'].getSubset(region=NodesofInterest)
    
    # This kind of iteration should work since FieldValueArray is not 
    # a repository
    for value in eseden.values:
        # Should print node's label and corresponding value
        print value.nodelabel, value.data
    

    You can read more about this if you search for FieldOutput and FieldValue in the documentation. Unfortunately, I can't find a way to directly link any part of documentation separately.