Snippets are existing lines of code that can quickly and easily be inserted in the command line, saving you from repetitive typing. A snippet can contain editable fields, which are automatically selected for modification when the snippet is inserted. When a field is selected, you can type a new value to override the default value or let the default value remain. Pressing the Tab key moves the cursor to the next editable field.
When nothing is entered in the command line, pressing Ctrl + space opens a list of suggestions displaying all variables and snippets. When you scroll down to the snippets, you can see those predefined for standard Python commands as well as those in the Snippets panel.
If you know the name of the snippet, you can begin typing its name to find it in
the list of suggestions. The predefined Snippet Template
provides code for swapping two variables.
When you insert a snippet in the command line, all editable fields can easily be seen.
For example, in the Snippet Template snippet, the first
editable field (foo) is highlighted.
Typing something changes the foo value to whatever you type
(value1). Notice that both
foo values change to value1 in one
operation.
Pressing the Tab key moves the cursor to the next editable field,
causing bar to be highlighted.
Typing something changes the bar value to whatever you type
(value2). Notice that both
bar values change to value2 in one
operation.
Pressing the Tab key again finalizes the code.
To define an editable field, you must use the following notation:
${#:default_value} where # is the
index of the field. For the first editable field, the value is
1. To reference an editable field that is already
defined, you simply need to specify its index (${#}), as
shown in the following figure for the Geometry snippet.
For the previous example for swapping two variables, you can define the following snippet:
temp = ${1:foo}
${1} = ${2:bar}
${2} = tempFrom the Snippets pane, you can easily insert a snippet in the command line by clicking it. This pane displays all personal snippets, which are either those supplied by ANSYS for ACT-specific commands or those that you create. It does not display snippets for basic Python commands because these snippets cannot be removed. For example, the Snippets pane displays the supplied Snippet Template for swapping two variables, but it does not display the lambda snippet for this basic Python command.
Note: When typing in the command line, autocompletion displays all snippets in the Snippet pane as well as the snippets for basic Python commands.
To make creating and managing snippets easy, the Snippets pane provides toolbar icons and a context menu.
Toolbar Icons:
Add a new snippet.
Add a new snippet folder.
Import an existing snippets collection.
Export the current snippets collection.
Show hidden icons; only displays when the ACT Console window is not wide enough to display all icons in the toolbar.
Context Menu:

You can create snippets and folders using any of the following methods:
Click the icon with the three dots to the right of an entry in the command history and select .
Click the toolbar icon for adding a new snippet or folder.
Right-click a snippet or folder in the Snippets pane and select or . Where you right-click determines where the new snippet or new folder is placed in the Snippets pane.
When you right-click a folder, the new item is created inside this folder.
When you right-click a snippet, the new item is created at the bottom of the containing folder.
Once the snippet or folder is created, the Snippet Properties dialog box opens so that you can specify properties. A snippet has two properties, Caption and Value. A folder has only Caption.
Caption specifies the text to display as the name for the snippet or folder.
Value specifies the code that the snippet is to insert in the command line. When a snippet is created from an entry in the command history, Value displays the code for this entry by default.
After specifying the properties for the snippet or folder, you click to save your changes or to discard the newly created snippet or folder.
To view or edit the properties of an existing snippet or folder in the Snippets pane, right-click it and selecting to open the Snippet Properties dialog box. When finished, click to save changes or to exit without saving changes.
You can delete a snippet or folder from the Snippets pane by right-clicking it and selecting .
Caution: If you delete a folder, all of its contents are also deleted. Deleting a snippet from the Snippets pane also removes it from the list of suggestions for autocompletion.
When creating a snippet or folder, you can determine its location by using a particular creation method, as described in Creating Snippets and Folders. To organize existing snippets and folders in the Snippets pane, you can drag them to the desired location in the hierarchical tree structure.
By default, the Snippets pane contains a Helpers folder and an Examples folder. The Helpers folder contains snippets for frequently used commands. The Examples folder contains snippets for use as templates. For example, the AddPressure snippet provides an example of how to create a pressure on the first face of the first body for the first part.
You can import or export a collection of snippets as an XML file.
Clicking the toolbar icon for importing a snippets collection
(
)
appends the snippets in the selected XML file to the list already shown
in the Snippets pane.
Clicking the toolbar icon for exporting a snippets collection
(
)
exports all snippets in the Snippets pane to the
specified XML file.
The following figure shows the XML file that results from the export of a snippets collection.