Using the Command Window

You can use the command window to invoke commands, access data entity properties, and invoke data entity and data container methods interactively, one at a time:

  1. Select File > Scripting > Open Command Window.

  2. Enter the commands you want to run, one at a time.

As you enter each command, the appropriate action will occur in the Ansys Workbench database and, if applicable, in the GUI.

Command Window Usage

While recording a journal, Ansys Workbench creates a number of variables for the object references that contain the data in your project. For example, consider the following lines from a journal:

template1 = GetTemplate(TemplateName="Thermal")
system1 = template1.CreateSystem()

In this journal, template1 and system1 are the variables for the references to the associated data objects. The variables are used within the journal to access the properties and methods of the objects. These variables are created and recorded specifically for replaying the journal, and they are not immediately accessible from within the command window. However, when working in the command window, you may want to use these variables. Doing so can aid in manually examining the details of your project or assist in creating scripts based on the journal. To use these variables, execute the command ImportJournalVariables in the command window to make the variable definitions from the currently recorded journal available in the command window. You should be aware of the following points when using the ImportJournalVariables() command:

  • The variable definitions are based on those in the currently recorded journal. By default, this journal is the automatically recorded journal controlled by user preferences. For more information, see Setting Journaling Preferences. If you have manually started a journal recording of part of your session, the variable definitions are taken from the manually recorded journal. For more information, see Recording a Journal Manually.

  • If you have any manually defined variables of the same name as any journal variables, your variables will be overwritten by the journal variables.

  • Changing the definition of a journal variable in the command window after executing ImportJournalVariables() does not affect the definition of the variable in the currently recorded journal.

  • The ImportJournalVariables() command can be executed multiple times in a session and will update the variables based on the currently recorded journal.

Command Window Navigation

The command window uses the Python programming language to interpret and invoke commands or other operations. In addition, you can use numerous keyboard shortcuts to facilitate your window interaction.

Text Cursor Keyboard Keys  —  When typing a command or statement, the following special keys are available for moving the text cursor:

KeyAction
Left Arrow Moves the cursor back one character
Right Arrow Moves the cursor forward one character
Ctrl + Left ArrowMoves the cursor back one word
Ctrl + Right Arrow Moves the cursor forward one word
Home Moves the cursor to the beginning of the line
End Moves the cursor to the end of the line

Copy and Paste Keyboard Keys  —  You can copy text from the command window to the clipboard or paste text from the clipboard as input to the command window. The following keys allow you to copy and paste text:

KeyAction
Ctrl+C/Ctrl+InsertCopies selected text from the command window to the clipboard. Text copied from the command window is first selected (highlighted) using the mouse.
Ctrl+V/Shift+InsertPastes the text found on the clipboard into the input area of the command window. If multiple lines of text are pasted, the lines must be one or more complete Python statements.

Command History  —  The command window maintains a history of commands or statements that you enter so you can easily recall a previously entered command or statement and invoke it again without retyping it. You could also make some modifications to it before invoking it again.

The following keys allow you to access the command history:

KeyAction
Up Arrow/Page UpRecalls the previously entered command, and the command before that if the key is pressed again
Down Arrow/Page DownRecalls the next command in the history list

Command Completion  —  The command window provides a command-completion (tab-completion) feature to automatically complete partially typed variables and commands to save tedious typing.

Type one or more characters and press the Tab key once or multiple times to see the defined variables and commands that have names beginning with the characters you typed. Entering an object variable name with the dot (.) and then pressing the Tab key will cycle through the defined properties and methods for that object. Entering one or more characters after the dot will restrict the completion results to just those properties and methods that start with those characters.

The following keys allow you to access the command completion:

KeyAction
Tab Completes the current text on the command line with any variable, property, command, or method name that is valid in the current context. Press Tab repeatedly to cycle forward through possible completions, if available.
Shift+Tab Same as Tab but cycles backwards through possible completions.