命令行接口

警告

The command line interface is based on the fire package since version 20**.5.0, and it is not compatible with the command line interface of previous versions.

在 Python 环境中使用 abqpy 默认将运行以下两个命令之一:

  1. abaqus 模块首次导入时:

    abaqus cae noGUI=script.py -- [args ...]
    
  2. odbAccess 模块首次导入时:

    abaqus python script.py [args ...]
    

当您在已安装的 Python 解释器中运行包含上述语句的脚本时,将调用这些命令行:

python script.py [args ...]

为了提供提供运行自定义 abaqus 命令的功能,abqpy 提供两种选择。一种是使用单独的 abqpy 命令行,另一种是使用 系统环境变量.

目前,abqpy 命令行接口提供了几种运行模式:**Abaqus/CAE 执行 ** 模式和 **Abaqus Python 执行 ** 模式:

abqpy COMMAND SCRIPT <flags> [ARGS]...

where COMMAND is one of abaqus, cae, python, run or any other Abaqus commands, SCRIPT is the file name of your python script, flags are the options that could be passed to the command, and ARGS are the extra arguments to be passed after the command line options. For details, see the References section or run abqpy COMMAND --help for help.

备注

对于下面的命令,可以用以下语法指定布尔类型的选项(以 gui 选项为例):

  • --gui--gui=True 将选项设为 True;

  • --nogui--gui=False 将选项设为 False

更详细的信息请查看 这里

示例

  1. 如果您想要在 Abaqus/CAE 模式下运行您的 Python 脚本,您可以运行:

    abqpy cae script.py [args ...]
    
  2. 如果您想在 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
    
  3. 如果您想要在 Abaqus/CAE 模式下运行您的 Python 脚本,您可以运行:

    abqpy python script.py [args ...]
    
  4. 如果你想在你的 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 模式的方法。

警告

Noted that if a token other than another flag immediately follows a flag that’s supposed to be a boolean, the flag will take on the value of the token rather than the boolean value. Thus --gui=True instead of --gui is used here to prevent this problem.

参考

$ abqpy
NAME
    abqpy - The abqpy command line interface.

SYNOPSIS
    abqpy GROUP | COMMAND

DESCRIPTION
    The abqpy command line interface.

GROUPS
    GROUP is one of the following:

     misc
       Less frequently used Abaqus/CAE commands.

COMMANDS
    COMMAND is one of the following:

     abaqus
       Run custom Abaqus command: ``abaqus {args} {options}``, arguments are separated by space, options are handled by the :meth:`._parse_options` method.

     cae
       Run Abaqus/CAE command.

     python
       Run Abaqus/Python command.

     run
       Run custom command.

     viewer
       Run Abaqus/CAE command.

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
    --gui=GUI
        Type: 'bool'
        Default: False
        Run Abaqus/CAE command with the graphical user interface (GUI mode), by default False.
    --noenvstartup=NOENVSTARTUP
        Type: 'bool'
        Default: False
        Do not execute the Abaqus/CAE startup file, by default False
    --noSavedOptions=NOSAVEDOPTIONS
        Type: 'bool'
        Default: False
        Do not use the saved options, by default False
    --noStartupDialog=NOSTARTUPDIALOG
        Type: 'bool'
        Default: False
        Do not display the startup dialog, by default False
    --guiRecord=GUIRECORD
        Type: 'bool'
        Default: False
        Record the GUI commands to a file, by default False
    --guiNoRecord=GUINORECORD
        Type: 'bool'
        Default: False
        Do not record the GUI commands to a file, by default False
    Additional flags are accepted.
        Other unrecognized keyword arguments

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
    Additional flags are accepted.
        Other unrecognized keyword arguments

NOTES
    You can also use flags syntax for POSITIONAL ARGUMENTS

使用较少的命令

$ abqpy misc --help
INFO: Showing help with the command 'abqpy misc -- --help'.

NAME
    abqpy misc - Less frequently used Abaqus/CAE commands.

SYNOPSIS
    abqpy misc COMMAND

DESCRIPTION
    Less frequently used Abaqus/CAE commands.

COMMANDS
    COMMAND is one of the following:

     abaqus
       Run custom Abaqus command: ``abaqus {args} {options}``, arguments are separated by space, options are handled by the :meth:`._parse_options` method.

     adams

     append

     ascfil

     cosimulation

     cse

     decrypt

     doc

     emloads

     encrypt

     fetch

     findkeyword

     fmu

     fromansys

     fromdyna

     fromnastran

     frompamcrash

     fromradioss

     fromsimpack

     help

     information

     licensing

     make

     moldflow

     mtxasm

     networkDBConnector

     odb2sim

     odbcombine

     odbreport

     optimization
       Run Abaqus optimization command.

     restartjoin

     resume

     run
       Run custom command.

     script

     sim_version

     substructurecombine

     substructurerecover

     suspend

     sysVerify

     terminate

     toOutput2

     toexcite

     tonastran

     tosimpack

     tozaero

     upgrade

     whereami

评论