path and python
path and python
(OP)
Hi,
i am trying to create a python script to get displacements values along a path. Could anybody suggest me how to create a path with python and how to get XY data from a path in order to write those in a text file? Thanks!
i am trying to create a python script to get displacements values along a path. Could anybody suggest me how to create a path with python and how to get XY data from a path in order to write those in a text file? Thanks!





RE: path and python
newPath=session.Path(name=pathName,type=pathType,expression=inputList)
then having the path created, further you create the
XYData object using something like:
newXYData=session.XYDataFromPath(name=xyName,path=newPath,\
includeIntersections=TRUE,\
shape=DEFORMED,\
labelType=TRUE_DISTANCE,\
step=1,\
frame=1,\
variable=variable)
variable is a tuple of tuples, as an example
variable=(('S', INTEGRATION_POINT, ((INVARIANT, 'Mises' ), )),)
then you need to use
session.writeXYReport(fileName="C:\\blah_blah.txt", xyData=(newXYData,))
Of course, for details about the meaning and allowed values of each argument see
ABAQUS Scripting Reference Manual, more precisely:
Path object:
34.1 Path object
XY Data:
49.1 XYData object
writeXYReport
49.8 writeXYReport
RE: path and python
"VisError: State description not found.
File "script.py", line 29, in ?
variable=variable)
"
Do you know what the problem can be?
RE: path and python
Wild guess: something wrong with the data in 'variable'. ?
Is that parameter, 'variable', the one from session.XYDataFromPath(...) ??
If yes, than you should read carefully the documentation.
Also, in general, for having a better chance of getting help, do supply the code indicated by error message. (e.g., code near line 29)
RE: path and python
########
import sys
import os
import visualization
from odbAccess import *
from abaqusConstants import *
#####
files = os.listdir('.')
inputList= ((0,0,0),(25,0,0))
newPath=session.Path(name='track',type=POINT_LIST,expression=inputList)
u=(('U',NODAL,((COMPONENT, 'U1' ),)),)
session.paths['track']
xyName = 'X'
i=0
while i < len(files):
nameall = files[i]
ext = nameall[(len(nameall)-4):]
name = nameall[:(len(nameall)-4)]
if ext == '.odb':
odb = openOdb(path = nameall)
newXYData=session.XYDataFromPath(name=xyName,path=newPath,
includeIntersections=TRUE,\
shape=UNDEFORMED,\
labelType=TRUE_DISTANCE,\
step=1,\
frame=1,\
variable=u)
session.writeXYReport(fileName='%s.txt', xyData=(newXYData,)) % (name)
i=i+1
#######
RE: path and python
-CAE opens properly the .odb's
-all .odb's contain U1 at step 1 frame 1
There's a "\" missing on
newXYData=session.XYDataFromPath(name=xyName,path=newPath,
Considering your error is a run-time one, then...
you might need to plot the U1 as contour plot before
calling session.XYDataFromPath(...).
Also, which version of ABAQUS are you using ?
RE: path and python
myViewport.setValues(displayedObject=odb)
myViewport.odbDisplay.setPlotMode(CONTOUR)
before calling session.XYDataFromPath(...)?
thanks!
RE: path and python
I was wrong. It seems to work without needing the contour plot. Sorry for the mistake.
Did you check the path is created correctly by your script?
Try first to use the path created by the script and see
if you can manually create the expected XYData.
It might happen that the ABAQUS Scripting Interface not to work as expected (or mentioned in documentation) and you might need to debug manually line by line.
RE: path and python
1. You *don't* need \ to continue a line. Just amke sure you indent it approporiately. This is a nice Python ease of use feature.
2. Your last point "It might happen that the ABAQUS Scripting Interface not to work as expected (or mentioned in documentation) and you might need to debug manually line by line." ---> This is the very reason the CLI (Command Line Interface) is provided! Just type away and watch the result... Remember that there is tab completion for commands/methods. This can really help.
RE: path and python
- added line 24 ...setValues(displayedObject=odb). Make this refer to your own viewport handle.
- fixed line 32 (the %name was in the wrong place)
Try the following:
########
import sys
import os
import visualization
from odbAccess import *
from abaqusConstants import *
#####
files = os.listdir('.')
inputList= ( (0,0,0),(25,0,0) )
newPath=session.Path(name='track', type=POINT_LIST, expression=inputList)
u=(('U',NODAL,((COMPONENT, 'U1' ),)),)
session.paths['track']
xyName = 'X'
i=0
while i < len(files):
nameall = files[i]
ext = nameall[(len(nameall)-4):]
name = nameall[:(len(nameall)-4)]
if ext == '.odb':
odb = openOdb(path = nameall)
session.viewports['Viewport: 1'].setValues(displayedObject=odb)
newXYData=session.XYDataFromPath(name=xyName,path=newPath,
includeIntersections=TRUE,
shape=UNDEFORMED,
labelType=TRUE_DISTANCE,
step=0,
frame=6,
variable=u)
session.writeXYReport(fileName='%s.txt'%name, xyData=(newXYData,))
i=i+1
#######
RE: path and python
RE: path and python
Thanks for the tip, I am sure next time CLI will certainly help me figuring out the correct argument types when mistaken in the documentation.