Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Python script for importing amplitude data - problems with script

Status
Not open for further replies.

SwimBikeRun4342

Mechanical
Mar 6, 2013
28
I am trying to write a very quick python script that imports amplitude data from a .txt file at a different location. I have zero experience with python and could really use some help. Below is the (very small) python code.

# -*- coding: mbcs -*-
from part import *
from material import *
from section import *
from assembly import *
from step import *
from interaction import *
from load import *
from mesh import *
from job import *
from sketch import *
from visualization import *
from connectorBehavior import *
from sys import path
path.append('D:\New Folder\Config2_Automated')
mdb.models['Model-1'].TabularAmplitude(name='Amp-1',input=TopLeg_TopJoint_FxQ2.txt, smooth=SOLVER_DEFAULT, timeSpan=STEP)



I get the following error:

NameError: name 'TopLeg_TopJoint_FxQ2' is not defined



So basically, I want to simply import the .txt file into my ABAQUS model, as an amplitude. Since the file is located elsewhere, I tried to write a path. However, my path must still not work because I get the error that my .txt file is not defined. Any suggestions? What does the error mean and how do I get ABAQUS/python to recognize the .txt file??

Thanks!



 
Replies continue below

Recommended for you

TopLeg_TopJoint_FxQ2 is a variable (which you haven't defined)
use ' ' to make it into a string
'TopLeg_TopJoint_FxQ2.txt'

Easiest is just to do what you want in CAE, and look up abaqus.rpy to see to what python commands it translates
 
sdebock -thanks, I appreciate the helpful reply.

Unfortunately that does not work either. Also, using the corresponding CAE file does not give me the code I want. Basically, I want to automate a process that imports data from a given .txt file to abaqus for numerous iterations. This should not be hard, but I am having problems. I can do it manually in CAE by going to the amplitude, clicking tabular, right clicking the cells, and selecting 'read from file'. I then find the file I want to import and select it. The problem in the corrosponding .rpy file is that scripts shows that amplitude as if it were entered manually. Since I intend for the amplitude to change for different iterations, I need abaqus to be able to import the data. Alos, doing this manually will take to long, so it must be inbedded into the scripts.

I have also tried using the .inp file with the code

*AMPLITUDE, NAME=name, INPUT=file_name

but this is not working either! The job fails and I get the following message:

All data lines on *amplitude, definition=tabular, excepting the last data line, must have exactly four data pairs (eight entries) or one single data pair (two entries). Please check the data lines for *amplitude.

My .txt file is simply two columns of data, each having the same amount of points. I really could use some help here! I just need to automate the process, so putting the command in either the .inp files for the jobs in in a python command are fine. I just cannot do it manually in CAE.






Summary:
-I want to be able to import data to the tabular amplitude feature in ABAQUS. I want the process to be automatic, so I do not have to do it manually each time
-I cannot just import the data in CAE and use the corrosponding .rpy file. THis is because when I go thru the process in CAE, the corresponding .rpy file just shows the tabular amplitude data as if it were entered manually in CAE, not imported from an external file like it needs to be.
-I have tried 2 methods each descibed previously: 1) creating a python code. 2) importing it in the .inp file. Both methods yield errors for me.


I would really appreciate some help!
THanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor