2.5. Command Files

Command files contain EnSight command language as ASCII text that can be examined and even edited. They can be saved starting at any point and ending at any point during an EnSight session. They can be replayed at any point in an EnSight session. However, some command sequences require a certain state to exist, such as connection to the Server, the data read, or a Part created with a Particular Part number.

There are a multitude of applications for command files in EnSight. They include such things as being able to play back an entire EnSight session, easily returning to a standard orientation, connecting to a specific host, creating Particle traces, setting up a keyframe animation, etc. Anything that you will want to be able to repeatedly do is a candidate for a command file. Further, if it is a task that you frequently do, you can turn the command file into a macro (see the Macro section below).

Command Files

EnSight commands are intended to journal, step-by-step the EnSight features you have interactively used in the order that they were used. These journaled commands can be saved to a file and then replayed. You can peruse a command file and make minor changes, such as editing a filename that was loaded and then rerun the edited command file to load the new file and perform the same actions on it that were performed on the original file. However, it is not intended that you would program a command file, nor try to type in commands to make EnSight do specific functions. It is intended that you interactively use EnSight and then save the journaling to a command to record what you have done. Do not attempt to code EnSight using command language

Saving Command File

The command file which will repeat the entire current session can be saved from the menu as follows: FileSaveCommands from this session... This command file can then be replayed at startup of a new EnSight session and will redo step by step each of the commands.

Documenting Bugs

Command files are one of the best ways of documenting any bugs found in the EnSight system. Hopefully that is a rare occasion, but if it occurs, a command file provided to Ansys will greatly facilitate the correction of the bug.

Nested Command Files

Command files can be nested, which means that if you have a command file that does a specific operation, you can play that command file from any other command file, as long as any prerequisite requirements are completed. This is done by adding the command play: <filename> in the command file.

Default Command File

EnSight is always saving a command file referred to as the default command file (unless you have turned off this feature with a client command line option. This command file can be saved (and renamed) when exiting EnSight, as described later in this section. The default command file is primarily intended to be a crash recovery aid. If something unforeseen were to prematurely end your EnSight session, you can recover to the last successfully completed command by restarting EnSight and running the default command file. Saving the Default Command File for EnSight Session

2.5.1. Command Dialog

Figure 2.4: Command Dialog - Execution Tab

Command Dialog - Execution Tab

You use the Command dialog to control the execution of EnSight command language. The language can be entered by hand, or as is most often the case, played from a file. This dialog also controls the recording of command files.

FileCommand....

2.5.1.1. Execution Tab

History

In the History window, commands to be executed will be shown in black below the green current line indicator. As commands are executed, they will be show in gray above the current line. Many operations can be preformed on the commands in the History window by highlighting commands and clicking the right mouse button to bring up an action menu. From this menu you can:

Breakpoint

set a breakpoint which will stop command execution at the selected command.

Disable

disable the selected command(s).

Copy

copy the selected command(s) to the system clipboard.

Write/append

write the selected command(s) to a new file or append them to an existing file.

Execute

execute the selected command(s).

Goto

move the current line pointer to the selected command (Press play or step to resume execution at this command).

Play Control

Stop

Stops command file playing.

Play

Starts playing a command file. If you haven't provided a command file name (see the Load section below), a File selection dialog will open for you to select or enter the file name. Command play continues as long as there are commands in the file, an interrupt: command has not been processed, and the Stop button has not been pressed.

Single Step

Executes only the current (next) command, indicated by the green current line pointer.

Skip

Skips over the current (next) command, indicated by the green current line pointer.

Speed

Use the Speed slider to control the speed of command file play.

Command Entry

Commands can be typed into this field for execution. Type the command and press return.

Load

The name of a command file to be executed can be typed into this field. Press return to load the file.

Or, you can use the associated Browse button to browse for a command file. A File selection dialog will open. Select or enter the file name. The file will be loaded when you click Open.

The Cd button associated with the Load field can be used to change EnSight's current directory to the directory of the loaded command file. This can be useful for playing command files that contain path information that assumes you're starting from the command file's directory.

Record

Check Record to start recording commands. If you have not typed a record filename in the text field provided, A File selection dialog will open for you to select or enter the file name. When Record is checked, all actions in EnSight are recorded to the specified file. As long as the record filename stays the same, the record button may be toggled on and off at any time, appending more commands to the file. When a new record file is selected, any existing commands in the file will be overwritten. You can browse for a new record file or directory at any time by clicking the browse button associated with this field.

Record Part Selection By

Use this radio button to select the method by which part selection will be recorded in the command language either by Number (default) or by Name.

Delay Refresh

When checked, this will cause the EnSight graphics window to refresh only after the playfile processing has completed or has been interrupted by the user.

2.5.1.2. Macros Tab

Figure 2.5: Command Dialog - Macros Tab

Command Dialog - Macros Tab

<filename>

This window displays the contents of the currently selected file in the Command files list (see below).

Macros

A three-column table that lists all of the currently defined keystroke macros.

Keystroke macros are defined in a text file, macro.define. Macros can be defined at a site or local level, with local macros overriding site macros that might be defined for the same key. The macro.define file (if any) that resides in the %CEI%/ensight242/site_preferences/macros directory defines site-level macros, while the macro.define file (if any) under the macros directory in the user's EnSight Defaults directory (located at %HOMEDRIVE%%HOMEPATH%\(username)\.ensight242 commonly located at C:\Users\username\.ensight242 on Win10, C:\Documents and Settings\yourusername\.ensight242 on older Windows, and ~/.ensight242 on Linux, and in ~/Library/Application Support/EnSight242 on the Mac) will define that user's local macros. Any command files referenced by macros must be located in these directories as well.

In the Macros table, local macros are shown in black, site macros are shown in blue, and local overrides of site macros are shown in red.

The table columns are:

Key

a symbol representing the keyboard key on which a macro is based

Modifier

a symbol representing one of the modifier keys that may be pressed along with the base key, (Shift, Ctrl, or Alt)

Description

a brief description of the macro

The Edit, Delete and New buttons, below, operate on the macro selected in this table.

Edit

Opens The Edit Macro dialog. Change any of the values in this dialog to edit the currently selected macro, then click Close. Your changes will not be written to the macro.define file until you either click Save Changes (see below) or close the command dialog and answer Yes to the Save Changes query message.

Delete

Deletes the selected macro, provided it is not a site macro.

New

Opens the New Macro dialog. Change any of the values in this dialog to define the new macro, then click Close. Your changes will not be written to the macro.define file until you either click Save Changes (see below) or close the command dialog and answer Yes to the Save Changes query message.

Save Changes

Saves the changes from this Command dialog session to the local macro.define file.

Command Files

This list shows the command files that are associated with the currently selected macro.

2.5.1.3. New/Edit Macros Dialog

Figure 2.6: New/Edit Macro Dialog

New/Edit Macro Dialog

Key

A list of the key symbols supported for defining macros

Repeatable

If checked, this causes the macro to be repeated while the specified key is held down.

Modifier 1

An optional modifier key (Shift, Ctrl, or Alt) to be held down along with the base key.

Modifier 2

A second optional modifier key.

Description

A brief text description that allows you to quickly identify the macro.

Command Files

Lists the command file(s) associated with a macro. Depending on how it is set up, a macro can execute command files three different ways:

  1. A single file is executed once for each key press.

  2. The command file repeatedly executes as long as the key is held down.

  3. Multiple command files execute in a cycle for each keystroke.

Add...

To add a new command file to the list click Add.... A File selection dialog will open. Select or enter the desired file and click Save.

Add Menu...

To add a menu selection to the list click Add Menu.... A dialog showing available menu options will open. Select one of the menu options to be executed for this macro.

Remove

To remove a command file from the list, select a file in the list, then click Remove.

Move up

To change the order of execution of the command files listed, select a file, then click Move up to change its position.

2.5.1.4. Python Tab

The Ansys EnSight Interface Manual Python EnSight Module Interface contains a description of this section.

2.5.1.5. Troubleshooting Command Files

This section describes some common errors when running commands. If an error is encountered while playing back a command file you can possibly retype the command or continue without the command.

ProblemProbable CausesSolutions
Error in command category

Incorrect spelling in the command category

Check and fix spelling

Command does not exist

Incorrect spelling in the command

Check and fix spelling

Error in parameter

Incorrect integer, float, range, or string value parameter

Fix spelling or enter a legal value

Commands do not seem to play

Command file was interrupted by an error or an interrupt command

Click continue in the Command dialog

See Record and Play Command (Journal) Files.

2.5.1.6. Saving the Default Command File for EnSight Session

EnSight is always saving a command file referred to as the default command file (unless you have turned off this feature with a Client command line option). This default command file receives a default name starting with ensigAAA and is written to your system temporary directory (for example, /usr/tmp, unless you set your TMPDIR environment variable is set to a valid pathname). This command file can be saved (and renamed) when exiting EnSight. If you do not save this temporary file in the manner explained below, it will be deleted automatically for you when you quit normally from EnSight.

2.5.1.6.1. Quit Confirmation Dialog

Figure 2.7: Quit Confirmation Dialog

Quit Confirmation Dialog

You use the Quit confirmation dialog to save either or both the default command file and an archive file before exiting the program.

FileQuit...

Save Command Backup File To

Toggle-on to save the default command file. Can also specify a new name for the command file by typing it in or browsing to it. (see Command Files for more information on using command files.)

Save Full Backup Archive File To

Toggle-on and specify a name (by typing it in or browsing to it) to create a Full Backup archive file, which is a machine-dependent, binary dump of the current state of this version of EnSight on this machine.

Yes

Click to save the indicated files and terminate the program.

See Record and Play Command (Journal) Files.

Auto Recovery

While EnSight is running, an auto recovery command file, recover.enc, is written to the EnSight Defaults directory (located at %HOMEDRIVE%%HOMEPATH%\(username)\.ensight242 commonly located at C:\Users\username\.ensight242 on Windows 10, ~/.ensight242 on Linux, and in ~/Library/Application Support/EnSight242 on the Mac). If EnSight crashes for some reason, this temporary file is not deleted. When EnSight is restarted (without using a play file) you will be prompted with the option of using the auto recover command file.

Auto Recovery Dialog

Figure 2.8: Auto Recovery Dialog

Auto Recovery Dialog