Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Abaqus environment file - auto update working directory 2

Status
Not open for further replies.

jball1

Mechanical
Nov 4, 2014
71
Hi,

Can I modify my Abaqus environment file such that whenever I open a CAE or an ODB, the working directory is changed to the location of the opened CAE or ODB?

Thanks,
Andrew
 
Replies continue below

Recommended for you

To do this you would have to run a Python script (at startup) that will first wait for the command used to open database (openMdb or session.openOdb) and then execute the command used to change working directory (os.chdir).
 
This is done automatically when you start A/CAE via command line in the folder that you want to have as work dir. I assume you work with Windows. Use the Windows Explorer, go into the folder and do shift+RMB -> Open command window here. As an alternative you can type CMD into the address bar of the Win Explorer. In the command window then just type 'abaqus cae' or 'abaqus view' to start the pogram.
 
FEA way said:
To do this you would have to run a Python script (at startup) that will first wait for the command used to open database (openMdb or session.openOdb) and then execute the command used to change working directory (os.chdir).

Would you mind helping me with the lines of code I would need for this script? Could I put these lines in the abaqus environment file? Or would it have to be a separate script?

Mustaine3 said:
This is done automatically when you start A/CAE via command line in the folder that you want to have as work dir. I assume you work with Windows. Use the Windows Explorer, go into the folder and do shift+RMB -> Open command window here. As an alternative you can type CMD into the address bar of the Win Explorer. In the command window then just type 'abaqus cae' or 'abaqus view' to start the pogram.

Thanks. This is very good to know. I just “wrote” my first python script (mostly just used the replay file) that imports amplitudes into a model, assigns them as displacement boundary conditions, and then runs a non-linear dynamic analysis. I have to run the analysis 12 times with different inputs. Each analysis is run in a different folder. I had a os.chdir command in there that I had to manually update for each folder, but based on what you said, I realized that the command was unnecessary, since each script was being called by a .bat file located in the folder for that analysis.
 
You will probably need separate script. After its execution the script would have to monitor the replay file and wait for the command used to open database. It may not be easy to script this but seems doable for me.
 
Here's a script that I wrote to do this, sort of. It's not automatic, and I am not sure you can make it run automatically any time you open a new cae. To get around that I've attached it to a button and then put the button om my toolbar. It works for me maybe it'll work for you.

Python:
import os
from abaqus import *


def doIt():
    #print("Current WD:",os.getcwd())
	fullFilePath=mdb.pathName
	path=os.path.dirname(fullFilePath)
	#print('Path ',path)
	os.chdir(path)
	print("New WD:"+ '//' + mdb.pathName)
 
DanStro said:
Here's a script that I wrote to do this, sort of. It's not automatic, and I am not sure you can make it run automatically any time you open a new cae. To get around that I've attached it to a button and then put the button om my toolbar. It works for me maybe it'll work for you.

Thanks! I'll try this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor