命令行接口¶
警告
自版本 20**.5.0 以来,命令行接口基于 fire 库,与之前版本的命令行接口不兼容。
在 Python 环境中使用 abqpy 默认将运行以下两个命令之一:
当
abaqus模块首次导入时:abaqus cae noGUI=script.py -- [args ...]当
odbAccess模块首次导入时:abaqus python script.py [args ...]
当您在已安装的 Python 解释器中运行包含上述语句的脚本时,将调用这些命令行:
python script.py [args ...]
为了提供提供运行自定义 abaqus 命令的功能,abqpy 提供两种选择。一种是使用单独的 abqpy 命令行,另一种是使用 系统环境变量.
目前,abqpy 命令行接口提供了几种运行模式:Abaqus/CAE 运行模式和 Abaqus Python 运行模式:
abqpy COMMAND SCRIPT <flags> [ARGS]...
COMMAND 是 abaqus、cae、python、run 或任何其他 Abaqus 命令之一,SCRIPT 是你的 Python 脚本的文件名称,flags 是可以传递给命令的选项,ARGS 是命令行选项之后传递的额外参数。 欲了解详情,请参阅 References 部分或运行 abqpy COMMAND --help 获取帮助。
备注
对于下面的命令,可以用以下语法指定布尔类型的选项(以 gui 选项为例):
--gui或--gui=True将选项设为True;--nogui或--gui=False将选项设为False。
更详细的信息请查看 这里。
示例¶
如果您想要在 Abaqus/CAE 模式下运行您的 Python 脚本,您可以运行:
abqpy cae script.py [args ...]如果您想在 Abaqus/CAE GUI 或无 GUI 模式下运行您的 Python 脚本,并提供
database文件选项,您可以运行:abqpy cae script.py --gui --database=file.odb [args ...] # GUI mode abqpy cae script.py --nogui --database=file.odb [args ...] # noGUI mode如果您想要在 Abaqus/CAE 模式下运行您的 Python 脚本,您可以运行:
abqpy python script.py [args ...]如果你想在你的 Python 脚本中调用命令行,你可以使用
abqpy.cli.abaqus对象:from abqpy.cli import abaqus abaqus.cae("script.py", gui=True, database="file.odb")
一些现代的 Python IDE 允许您自定义默认的 Python 启动参数传递给解释器。 这允许你直接运行 abqpy 命令行,并自定义您的默认 abaqus 运行选项。
例如:在 VSCode Python 扩展 中,您可以指定以下设置:
"python.terminal.launchArgs" : [ "-m", "abqpy", "cae", "--gui=True" ]
此设置将默认使用 VSCode Python 扩展运行的所有 Python 脚本文件,其运行命令如下:
python -m abqpy cae --gui=True script.py [args ...]
它提供了一种将默认 abaqus 执行过程更改为 GUI 模式的方法。
警告
请注意,如果有另外的选项紧跟在布尔值标志之后,则该布尔值标志将采用该标志后面的值。 因此这里使用 --gui=True 而不是 --gui 来避免这个问题。
参考¶
$ abqpy
Abaqus/CAE 运行模式¶
$ abqpy cae --help
INFO: Showing help with the command 'abqpy cae -- --help'.
NAME
abqpy cae - Run Abaqus/CAE command.
SYNOPSIS
abqpy cae SCRIPT <flags> [ARGS]...
DESCRIPTION
Run Abaqus/CAE command.
POSITIONAL ARGUMENTS
SCRIPT
Type: 'str'
The name of the python script to run
ARGS
Extra arguments to be passed after the Abaqus/CAE command line options
FLAGS
-d, --database=DATABASE
Type: Optional['str | None']
Default: None
The name of the database file to open, by default None
--replay=REPLAY
Type: Optional['str | None']
Default: None
The name of the replay file to open, by default None
--recover=RECOVER
Type: Optional['str | None']
Default: None
The name of the journal file to open, by default None
--startup=STARTUP
Type: Optional['str | None']
Default: None
The name of the startup file to open, by default None
--gui=GUI
Type: Optional['bool | None']
Default: None
Run Abaqus/CAE command with the graphical user interface (GUI mode), by default False.
-e, --envstartup=ENVSTARTUP
Type: Optional['bool | None']
Default: None
Execute the Abaqus/CAE startup file, by default True
--savedOptions=SAVEDOPTIONS
Type: Optional['bool | None']
Default: None
Use the saved options, by default True
--savedGuiPrefs=SAVEDGUIPREFS
Type: Optional['bool | None']
Default: None
Use the saved GUI preferences, by default True
--startupDialog=STARTUPDIALOG
Type: Optional['bool | None']
Default: None
Display the startup dialog, by default True
-c, --custom=CUSTOM
Type: Optional['str | None']
Default: None
The name of the file containing Abaqus GUI Toolkit commands to be executed, by default None
--guiTester=GUITESTER
Type: Optional['str | None']
Default: None
This option starts a separate user interface containing the Abaqus Python development environment along with Abaqus/CAE.
--guiRecord=GUIRECORD
Type: Optional['bool | None']
Default: None
Record the GUI commands to a file, by default None
NOTES
You can also use flags syntax for POSITIONAL ARGUMENTS
Abaqus Python 运行模式¶
$ abqpy python --help
INFO: Showing help with the command 'abqpy python -- --help'.
NAME
abqpy python - Run Abaqus/Python command.
SYNOPSIS
abqpy python SCRIPT <flags> [ARGS]...
DESCRIPTION
Run Abaqus/Python command.
POSITIONAL ARGUMENTS
SCRIPT
Type: 'str'
The name of the python script to run
ARGS
Extra arguments to be passed after the Abaqus/CAE command line options
FLAGS
-s, --sim=SIM
Type: Optional['str | None']
Default: None
The name of the simulation file to open, by default None
-l, --log=LOG
Type: Optional['str | None']
Default: None
The name of the log file to open, by default None
NOTES
You can also use flags syntax for POSITIONAL ARGUMENTS