Executing commands

All commands are ultimately executed in the kernel process, but there are several ways this can be accomplished.

For example:

  • You can execute kernel commands from a file by using the –start or –replay options on the command line.
  • You can execute kernel commands from a file by using FileRun Script.
  • You can type kernel commands in the Abaqus/CAE CLI.
  • The GUI mode infrastructure can send a command string from the GUI to the kernel process for execution (see Command processing for details).
  • You can issue a kernel command directly from the GUI using the sendCommand function.

The sendCommand function takes three arguments:

  • A required string argument specifying the command to be executed in the kernel.
  • Two optional Boolean arguments, writeToReplay and writeToJournal.

The optional Boolean arguments control whether or not the sendCommand function writes the command to the replay or journal file. By default, the sendCommand function writes the command to the replay file but not to the journal file. If the command modifies the model in any way, you should record the command in both the replay and journal files. However, if the command modifies only session data (such as the view of the viewport), you should record the command in the replay file, but you should not record it in the journal file. By convention, the user should be able to completely recreate the result of an interactive session by replaying its replay file. Only the commands that are written to the journal file will be available for data recovery in the event that the application aborts.

Abaqus Scripting Interface commands automatically journal themselves. As a result, if you use the sendCommand function to issue an Abaqus Scripting Interface command, you should not set writeToJournal=True. Otherwise, the command will be recorded twice in the journal file. For more information, see Abaqus/CAE command files.

If you write your own kernel scripting module and functions, you should be aware that you can use the journalMethodCall function to record a command in the journal file. This option is preferable to using the writeToJournal argument in the sendCommand function. Your command should not call journalMethodCall if the command changes the Mdb object using built-in Abaqus Scripting Interface commands, because these are journaled by default. A command that changes the customData of the Mdb should call journalMethodCall. For an example that illustrates one common use of the journalMethodCall function, see journalMethodCall.

In general, you should enclose the sendCommand function in a try block to catch any exceptions that might be thrown by the kernel command. In order for exceptions to be caught, they should be class-based exceptions and not simply strings. For example:

from abaqusGui import sendCommand
try:
    sendCommand("mdb.customData.myCommand('Cmd-1', 50, 200)"
except ValueError, x:
    print 'an exception was raised: ValueError: %s' % (x)
except:
    exc_type, exc_value = sys.exc_info()[:2]
    print 'error. %s.%s'%(exc_type.__name__, exc_value)