Write a for loop in Abaqus Macro (Python)
12:07 23 Jan 2015

I've been using Abaqus for a while but I'm new to macros and python script. I'm sorry if this kind of question has already been asked, I did search on google to see if there was a similar problem but nothing works..

My problem is the following :

I have a model in Abaqus, I've ran an analysis with 2 steps and I created a path in it and I'd like to extract the value of the Von Mises stress along this path for each frame of each step. Ideally I'd love to save it into an Excel or a .txt file for easy further analysis (e.g in Matlab).

Edit : I solved part of the problem, my macro works and all my data is correctly saved in the XY-Data manager.

Now I'd like to save all the "Y" data in an excel or text file and I have no clue on how to do that. I'll keep digging but if anyone has an idea I'll take it !

Here's the code from the abaqusMacros.py file :

# -*- coding: mbcs -*-
# Do not delete the following import lines
from abaqus import *
from abaqusConstants import *
import __main__



def VonMises():
    import section
    import regionToolset
    import displayGroupMdbToolset as dgm
    import part
    import material
    import assembly
    import step
    import interaction
    import load
    import mesh
    import optimization
    import job
    import sketch
    import visualization
    import xyPlot
    import displayGroupOdbToolset as dgo
    import connectorBehavior

    odbFile = session.openOdb(name='C:/Temp/Job-1.odb')
    stepsName = odbFile.steps.keys()
    for stepId in range(len(stepsName)):
            numberOfFrames = len(odbFile.steps.values()[stepId].frames)
            for frameId in range(numberOfFrames):
                    session.viewports['Viewport: 1'].odbDisplay.setPrimaryVariable(
                        variableLabel='S', outputPosition=INTEGRATION_POINT, refinement=(
                            INVARIANT, 'Mises'))
                    session.viewports['Viewport: 1'].odbDisplay.setFrame(step=stepId, frame=frameId)
                    pth = session.paths['Path-1']
                    session.XYDataFromPath(name='Step_'+str(stepId)+'_'+str(frameId), path=pth, includeIntersections=False, 
                        projectOntoMesh=False, pathStyle=PATH_POINTS, numIntervals=10, 
                        projectionTolerance=0, shape=DEFORMED, labelType=TRUE_DISTANCE)
python macros path abaqus