The <GuiOperations> node has
the following attributes:
[Operation Name] - The name
shown in the context menu.
[Priority] - The weighted
value determining the location within the context menu, the toolbar
or the menu where the user interface operation is defined.
[SourceType] - The type of
code being used to define the response behavior for operation execution.
CSharp - The code will be
written in C#.
Python - The code will be
written in Python.
[Type] - The type specifies
where the user interface operation should be placed in the user interface.
The allowed types are:
ContextMenuEntry - This is
the default type and should be specified in order to define user interface
operations that are shown upon Right Mouse Button selection of a component
in an External Connection system. ContextMenu should NOT be specified for operations defined in configuration
files located in the installation area or in the user-specific area
since it is not possible to associate them with a specific cell.
ToolbarButton - The type ToolbarButton should be used for creating custom entries
in the toolbar. You can define a toolbar group using the attribute Entry defined below. This type should NOT be specified
for user interface operations defined on the component configuration
file. It is reserved for user interface-specific configuration files
that are processed at add-in load from the installation or user specific
areas.
MenuEntry - The type MenuEntry should be used for creating custom entries
in Menu. The newly created Menu Entry is specified via the attribute
Entry defined below. This type should NOT be specified for user interface
operations defined on the component configuration file. It is reserved
for user interface-specific configuration files that are processed
at add-in load from the installation or user specific areas.
[Entry] - The Entry attribute is relevant only in conjunction with
a specified Type=MenuEntry or Type=ToolbarButton. It defines the name of a new menu
entry or Toolbar group where the user interface operation is shown.
For menu entries, it is also possible to define sub-menus of a given
menu as comma separated values. For example, specifying Entry as "NewMenu, SubMenu1" will result in the user interface
operation appearing from a sub-menu "SubMenu1" of a Menu Entry "NewMenu"
[Code] - The code defined
inside the configuration file, rather than a separate file:
<GuiOperations>
<! - Code can either be loaded from a file with the "ScriptFile" attribute,
or be included in a "Code" tag - >
<GuiOperation Name="Enter Something" Priority="2" SourceType="CSharp">
<Code>
<![CDATA[
Ansys.UI.Toolkit.MessageBox.Show("This is a test");
]]>
</Code> [Script] - The path to a Python script to run on execution of the
operation. Specification of the script cannot be combined with execution of
custom code. Therefore a script should not be included if code is defined
inside the tags of the GuiOperation node. Scripts
invoked from a user interface operation defined on the
ContextMenu of the cell have access to the
following variables:
container - A string that
can be passed to any command or query that requires as a parameter
the reference to the data container associated with the component.
configurationObject - The configuration object can be used to access
some of the information specified in the configuration file, such as
a working directory or error file. The query
GetEntityProperties(Entity=configurationObject)
returns a dictionary that contains all the available configuration
information.
When the user interface operation invokes a script, the invocation of the script is wrapped in a command. It is possible to specify scripts to be executed in order to interrupt or cancel the execution of the command. It is also possible to specify an error file to provide messages when the command execution fails, with the same control on the error display that is provided for the update. A detailed description of the attributes is given below:
InterruptScript=[string] -
An optional Python script that is invoked when the computation is
interrupted. In Workbench terminology, the Interrupt operation closes
the external application cleanly, allowing access to data. The Interrupt
operation is visible only if the Interrupt script is provided.
StopScript=[string] - An
optional Python script that is invoked when the computation is stopped.
In Workbench terminology, the Stop operation abruptly closes the external
application, possibly resulting in the loss of data. The Stop operation
is visible only if the Stop script is provided. The same script can
be used for Stop and Interrupt. The script has access to the same
information (strings container and configurationObject) that is passed to the executing
script.
ErrorFile=[string] - A file used to communicate that the execution of
the user interface operation was not successful. The error file muist be
removed by the user interface operation upon completion. If it is still
present, Workbench sends an error message. The content of the error message
can be specified through the attribute CheckOnError (see below). A generic
message is displayed if CheckOnError is not specified.
CheckOnError=[string] - If an error file is specified, its content is
scanned for lines that contain the specified error string. All lines that
contain the string are displayed as error messages (with the error string
stripped from the message). An error string named file causes the whole
content of the file to be displayed.
UseUpdateConfiguration=[boolean] - This variable can be specified as a shortcut, in order to use
for the custom user interface operation the same files specified in
the Update instructions for stop/interrupt and for controlling the
error message display. If the attribute is True and the attributes
above are not specified, the code will use the ones provided for the
first update instruction, if specified.
[Image] - The name (without
extension) of a file containing an image to be used for the user interface
operation. Files with common extension for images are searched under
the Images directory under External Connection
add-in. If a Customization directory is provided
under the installation or user specific area, the corresponding Images
directories are also searched for the specified file.
[Tooltip] - A string to display as the
Tooltip for
ToolbarButton type operations. The string has
no effect for other operation types.