Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

path and python 5

Status
Not open for further replies.

Pirikokku

Geotechnical
May 12, 2006
6
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!
 
Replies continue below

Recommended for you

First you create the path object

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

 
Thanks! I am writing a short routine to read from a list of .odb files the displacements data and write a report file automatically.I tried to run this script but return this error

"VisError: State description not found.
File "script.py", line 29, in ?
variable=variable)
"

Do you know what the problem can be?

 
No, I don't.

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)



 
Yes, "variable" is the one from session.XYDataFromPath(...)...but no idea what's State Description(no reference on the documentation) here below is my script...actually python don't return me any error code but only the warning message I wrote before.....



########
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
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
#######


 
I assume you checked the following:
-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 ?
 
I am using the version 6.5-6. I used the same script to open the .odb's and write the displacements in txt files, and it works. But I would like to have some flexibility, and with the path tool would be better. Since that is my second script in python i have still some problems to understand how to interact with the CAE modules. If I have understood correctly, I should plot the U1 before (basically like it works in the CAE GUI..isn't?)....that means that I have to call something like:

myViewport.setValues(displayedObject=odb)
myViewport.odbDisplay.setPlotMode(CONTOUR)

before calling session.XYDataFromPath(...)?

thanks!
 
Actually, I have just re-tested one of my scripts.
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.
 
Couple of quick things before I look at your script more closely:

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.
 
It works with some minor fixes:
- 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
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
#######
 
thanks brep. I got it. now is working as I expected.
 
Brep,
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor