×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

path and python
5

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!

RE: path and python

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

RE: path and python

(OP)
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?

 

RE: path and python

No, I don't.

Wild guess: something wrong with the data in 'variable'. ? smile

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

(OP)
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[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

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 ?

RE: path and python

(OP)
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!

RE: path and python

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.

RE: path and python

3
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.

RE: path and python

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

(OP)
thanks brep. I got it. now is working as I expected.

RE: path and python

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Solutions Brief - Protecting and Rescuing On-Ground Personnel
Keeping our warfighters safe and delivering them a competitive advantage is a key goal of departments of defense around the world. It’s a goal shared by embedded computing manufacturers like Abaco: we never forget who we serve.This case study describes how a major international contractor integrated an Abaco single board computer at the heart of its CAS/CSAR solution. Download Now
Datasheet - Top Enhancements Creo 7.0
PTC's Creo 7.0 has breakthrough innovations in the areas of generative design, real-time simulation, multibody design, additive manufacturing, and more! With Creo 7.0, you will be able to design the most innovative products faster than ever before, keeping you on the cutting edge of product design and ahead of your competition. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close