6.3 Executing commands

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

The sendCommand function takes three arguments:

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, Section 9.5 of the ABAQUS/CAE User's Manual.

In general, you should enclose this 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('print "this is a test"')
except:
    print 'something went wrong'