Reputation: 21
I want to convert a python script to an executable file. This python script will call another python script, which is the requirement.
Script :
from abaqus import *
from abaqusConstants import *
import __main__
import allAbaqusMacros
def Macro1():
import section
import regionToolset
import displayGroupMdbToolset as dgm
import part
import material
import assembly
import step
import interaction
import load
import mesh
import optimization
import job
import sketch
import visualization
import xyPlot
import displayGroupOdbToolset as dgo
import connectorBehavior
import os
execfile('C:\\\\Users\\\\Me\\\\Desktop\\\\Sample.py')""") - This also works
However, the code works only in ABAQUS PDE (Similar to VBA editor in Excel)
To track the usage of the few python scripts, I am doing this. I know we can run it from File->RunScript or in the CLI with an Abaqus Command. But that's not the requirement.
I want it as a file, which will run the other desired script on a single-click. Also, I have tried it as a batch file to run it in the command prompt.
Batch Command :
"C:\SIMULIA\Abaqus\6.14-3\code\bin\abq6143.exe" cae script =C:\Users\Me\Desktop\Sample.py %*
This works but it starts a new session. I have used "noGUI" instead of script, but
I get this error Message
getInputs cannot be used with the -noGUI option.
Also, I have tried running it using the below command as well.
C:\Python27\python.exe C:\Users\Me\Desktop\Sample.py
For this, the error message was
Traceback <most recent call last>:
File "C:\Users\Me\Desktop\Sample.py", line 1, in <module>
from abaqus import *
File "SMAPyModules\SMAPyaAbqPy.m\src\abaqus.py", line 5 in <module>
File "SMAPyModules\SMAPyaUtilsPy.m\src\i18n.py", line 1 in <module>
File "SMAPyModules\SMAPyaUtiPy.m\src\uti.py", line 5 in <module>
File "SMAPyModules\SMAPyaUtiPy.m\src\utiinternal.py", line 52 in <module>
File "SMAPyModules\SMAPyaUtiPy.m\src\uticty.py", line 145 in <module>
File "SMAPyModules\SMAPyaUtiPy.m\src\uticty.py", line 136 in _loadAbaqusDll
Value Error : dll not found : ABQSMABasShared.dll
Press any key to contuinue...
Is there any way to convert a Python script developed in Abaqus PDE or any Plug-in Development Environment to an executable file? Please help
Upvotes: 0
Views: 1815
Reputation: 2347
The Abaqus/Python API is useful for a variety of purposes, including pre/post-processing tasks, GUI building, and creating macros. I can see that you're just getting started and are operating under a number of misconceptions, so I will gently nudge you toward carefully reading the official docs, which answer all of your questions and more, very completely1.
However, because those docs might seem like quite a lot of information to absorb, I'll try to give you a few helpful tips to start with.
python file_name.py
. abaqus python [file_name.py]
.abaqus python
. Note, this is not part of the Abaqus kernel process - meaning you can't import any Abaqus-related modules this way, but the Python standard library should be available.abaqus cae file_name.py
. This command starts up a new CAE session and runs your script. abaqus cae noGUI=file_name.py
. getInputs
, because it requires a GUI popup window. abaqus cae noGUI=MyScript.py -- value1
. You can use as many command line args as you want. Alternatively, put the arguments into a file and open/read the file from within the script.import __main__
. If errors occur, the Python traceback usually tells you what is wrong.execfile
, you can use the functions/objects in other Python script(s) with the import
statement. For example from File_A import function1
, from File_B import function2
, etc. These imported Python scripts are then usually referred to as modules.These hints should help you get started, but remember it is just the tip of the iceberg, so to speak. For further execution options and details, see the Abaqus Analysis Users Manual > Introduction, Spatial Modeling, and Execution > Job Execution > Execution Procedures.
1Specifically, see the Abaqus Analysis User's Manual for instructions on how to call/execute Python scripts from the system shell, and see the Abaqus Scripting User's Manual for helpful examples and explanations for how Python is used with Abaqus. This should be read in tandem with the Abaqus Scripting Reference Manual, where full API details are available.
Upvotes: 4