×
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!
  • Students Click Here

*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

Jobs

Python script help

Python script help

Python script help

(OP)
Hi,

       I need to convert an Abaqus input file into a different file format - to do this I obtained  a python script. But I have no idea how to run a python script on a file.I have never used python scripting before.

Could someone please suggest me how could I run a python script on a file (say "abc.inp"). I have installed python 3.0

Thanks in advance,
SS

RE: Python script help

If you have ABAQUS CAE. You could import the input file int CAE. Then go to file> run script.

Gurmeet

RE: Python script help

you can use execfile('yourfilename.py') command

MMS

RE: Python script help

(OP)
Thanks Gurmeet and MMS.

RE: Python script help

(OP)
Hi Gurmeet and MMS,

I tried both the approaches. But I could not convert my inp file to crk file. I am attaching the Python code and the inp file to this mail (both are in a compressed folder). Could you please take a look at it and let me know what is it I am doing wrong. Flawsurfs.py is the code I need to run.

All I need it to be able to run the Flawsurfs.py code on Crack.inp and generate a .crk file. I greatly appreciate any help you could offer.

Thanks,
Rajesh

RE: Python script help

I don't know what exactly you wanna do. but I checked out the scripts, afaik the Flawsurfs.py is not an abaqus runnable script, I think it is a simple python module that you can import it to another main script and use its functions and classes. you must find out or write another main script. it usually starts with "from abaqus import *"
but I think you can use the FESurfCrack.py like this:

*python FESurfCrack.py -tr 0.005 -inp Crack.inp > MMS.crk*
just run it in command prompt (without stars), you must have python installed.

Good Luck,

Mohammad Shahbazi
www.OmranAfzar.com

RE: Python script help

(OP)
Thanks Mohammed.
I tried the command lines but I have been getting syntax error messages. I am surely missing something. I also tried IDLE to run the FESurfCrack module and it is showing some indentation errors. I tried to make them consistent, but they (indentation errors) keep coming.I am attaching the screen shots of the errors I am getting and the python code.

My experience with Python is 'Zero'. I just need to run this file to convert my inp files to crk files. I would greatly appreciate any help in rectifying this problem. I have Python 2.6 installed on my Windows PC.

Thanks again,
SS

RE: Python script help

(OP)
Thanks Mohammed.

 I copied the batch file onto my PC and ran it (just double-clicked the batch file). But, it was just creating an empty (0 bytes) MMS.crk file.

   Excuse my ignorance with computers. Am I supposed to edit the batch file ? Like changing the path or something . Please let me know.

The MMS.crk file you sent is exactly what I am looking forward to generate. I would greatly appreciate if you could suggest what are the steps I need to follow. Once again thanks so much for the help.

SS

RE: Python script help

The python path of your's must be set in the batch file.
set it and run it again. installing python adds its path to your windows paths.

Good luck,

Mohammad Shahbazi
www.OmranAfzar.com

RE: Python script help

(OP)
Mohammad,

         After copying the batch file you sent, to the folder which has the python script I want to run, I set the path to the Python executable in the batch file. Then I ran it. The fact is that it is running; but it is creating a MMS.crk file that is empty.

I am changing the path in the file you sent to something like C:\Python26\ which has the python executable. I will check it again. I may be missing something. Thanks so much for your help. I appreciate it.

RE: Python script help

(OP)
Hi Mohammad,

 I modified the path in the batch file as you suggested ( I am attaching the folder with the file). But for some reason, it is not generating the complete MMS.crk file.
I am not sure if it has to do anything with the Python version I have or the way my computer is set-up. Please let me know what you think may be wrong.

Thanks,
Rajesh

RE: Python script help

(OP)
Thanks so much Mohammad. This works great.

Rajesh

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!


Resources