Beruflich Dokumente
Kultur Dokumente
SimXpert Templates can range from simple serial tasks to complex procedures with loops and branching
that span multiple workspaces in SimXpert. Batch execution of multiple runs with varying inputs is also
supported for DOE and stochastic approaches.
Through the optional connection to SimManager, SimXpert Templates can be published for enterprise-
wide sharing, and subsequently retrieved for execution or editing.
Properties can be assigned to each object in the Template. The Connection tool is used to establish
procedure sequence and data flow. Outputs from one action are connected to inputs of another. Looping,
Choice, and custom scripts can also be added.
4
Overview of Template Builder workspace
Tools are provided to create user interfaces to gather inputs from the user during template execution.
Inputs can be in many different forms, such as a data file, number or text entry, or picking objects from
a SimXpert model.
SimXpert Templates may utilize multiple workspaces in SimXpert and may also utilize published objects
(templates and actions) from a SimManager database, if installed.
5
Types of objects used in a SimXpert template
Action
An Action is a black-box entity that performs a specific task from inputs and generates outputs. An
Action is typically a script (Python or RADE) that can be written by the user or supplied by MSC in an
Action library. Inputs are collected prior to executing the action and outputs are passed upon completion.
In the Template Builder workspace, the default icon for Action is a “script” icon, although a different icon
may be assigned by the author:
Core Action
Core Actions are reusable actions that are provided as part of the built-in action library in SimXpert, and
are stored in the installation directory. Each Core Action executes some tool or command from SimXpert
and is stored as a file, with the *.act extension. In Template Builder you can link any Core Action into a
Template using the Actions toolbox. Core Actions are part of SimXpert and may not be modified.
Custom Action
A Custom Action is a user-written action that incorporates script to perform a task. SimXpert supports
the creation of scripts using the public domain Python language or the proprietary RADE language. The
script may utilize the Application Programming Interface (API) of SimXpert to query a model, modify
data, create objects, and execute commands.
Like a Core Action, a Custom Action is also stored as a *.act file. This can be in any convenient location,
such as on a local drive or in SimManager. The default location for actions created in Template Builder
workspace is C:\ <SimXpert install directory> \Process. This location may be changed in Template
Builder Options.
A key feature of Actions is that they are re-usable. The same action may be inserted in multiple different
Templates. When a Core or Custom Action is used in a Template, an instance of the action is created,
which is linked to the Action file. The main script code remains in the Action file and may only be
changed by editing the source action (not permitted for Core Actions). When changes are made to a
Custom Action file, all Templates containing linked instances of the action can automatically receive the
modifications. Versioning of actions is provided to facilitate updating of templates.
6
Types of objects used in a SimXpert template
SimXpert Template
A SimXpert Template is a collection of Actions, executed in a defined manner. Each action in the
template may receive inputs from a prior action and may pass outputs to a subsequent action. Looping,
choice, and branching may be defined between actions to give the template flexibility. A Template may
also be nested in another Template.
When executed, the template may be run interactively, gathering inputs from the user as each action is
executed. Some templates can be set up to run in batch mode, in which case, all inputs must be supplied
at the start of execution.
In the Template Builder workspace, the default icon for SimXpert Template is a “gear” icon with
connections:
The file extension *.proc is used to indicate a SimXpert Template (process) file. The default location for
Templates created in Template Builder workspace is C:\ <SimXpert install directory> \Process.
Embedded Template
Template Builder allows for creation of a “sub-template” within a template. This is called an embedded
template and is saved as part of the parent template, rather than as a separate *.proc file.
VRADE Template
A template that was built using the previous “SimTemplate Builder” (now located on Tools menu in
SimXpert Template Builder workspace) is called a VRADE (Visual RADE) Template. Starting with
SimXpert R3.2, a VRADE template may not be used as a component in a template built in the Template
Builder workspace.
These templates are supported for legacy purposes, and may still be executed from the Tools > Templates
menu. But new templates should be built using the Template Builder workspace.
7
Types of objects used in a SimXpert template
Or start with a blank window to begin editing a new SimXpert Template. From the Controls toolbox,
select New Template. See Creating a new template for details.
The Action Editor tool provides automatic code generation for input and output parameter declarations.
It also provides a wide selection of user interfaces for input parameters, such as text box, drop list, picking
from model, option buttons, or direct input from a prior action.
All public classes and methods of the SimXpert API are made available to action authors.
See Creating a new script action for more information.
Each action in a template may be assigned different prompting behavior for inputs, to control when
prompting occurs. Different display icons may be assigned, including an interactive graphics snapshot
icon.
In the case of Custom Actions, user interface options may be added, such as buttons, sliders, file
choosers, etc. See Parameter Interface for details on creating user interfaces.
Three Loop tools are provided to repeat a group of actions until some condition is satisfied.
The Properties of an action instance that can be changed in the dialog box include: Prompting behavior,
display icon, input parameter default values, etc.
Connection properties should also be checked to make sure the desired parameters are being passed from
one action to another.
See Action Properties dialog box and Connection tool for details.
The properties for the template itself should also be checked and modified, as needed. See Template
Properties dialog box.
Creating Templates
14
Template Builder Workspace window
If SimXpert is already opened in a different workspace, use the Workspace selector and select Template
Builder from the list.
Toolboxes
A unique set of Toolboxes exists for the workspace. The tools allow for quick access to Actions and
Templates and stored on the user’s machine. The ability to browse and retrieve items from SimManager
is also available on the workspace toolbox. A full set of controls and editing tools are provided for the
assembly of new templates.
Note: All toolboxes and sub-menus are detachable by clicking on the dashed line at the top of the
tool list. The detached toolbox can be parked anywhere in the SimXpert workspace.
16
Template Builder Workspace window
Toolboxes may also be viewed in tree form by right-clicking in toolbox area and checking Tree Display.
Context menus
Right-clicking on any object will bring up a context menu for that item. See also: Context menus
Model Browser
The Model Browser shows the contents of all templates and actions that are currently opened for editing.
Several templates can be open for editing at the same time. Use the Model Browser to view the open
17
Template Builder Workspace window
templates and the contents of each. Clicking on the template’s name or icon in the Model Browser will
change the template displayed in the graphics window and the selected template will become “current.”
The same is true for Custom Actions. Multiple actions can be opened for editing and the Model Browser
is also used to display and switch between actions.
Getting Help
Context Help
Click the “?” at the upper right corner of any dialog box, or simply click F1 key to open context-sensitive
help for the current command or dialog.
Balloon Tips
Hovering the mouse over any item in a toolbox or the graphics window will cause a “balloon” window
to appear. Information in the balloon tip includes the name and description of the object, as well as
descriptions of input and output parameters. Custom Actions will also display a balloon tip, showing
the documentation provided by the action author.
18
Template Builder Workspace window
Search Tools
A search utility can be opened by right-clicking in the toolbox area and selecting Search.
Just type a string into the text box and all tools containing the string are immediately displayed, along
with their parent folder organization.
19
Editing an existing template
Step 2: Use the file open dialog box to locate the existing template, which has a *.proc file extension,
and Open.
For now, ignore any file type of *.act, since these are actions, not templates. (See Creating an Action
section of User Guide)
Step 3: Upon selecting the template file, it is opened and is visible in flowchart form in the graphics
window, and in tree view in the Model Browser.
20
Editing an existing template
Step 4: You may see a warning message or red circle icon indicating that one or more actions in the
template are invalid or missing. This is caused by a mismatch in the version, or by the action not being
found in the expected location.
Double-click on any action instance marked in this way to open its Properties. Use Update button to
locate and replace with the latest version of the action, or re-establish the correct file path using a file
browse dialog.
Refer to other sections of this User Guide for modifying and adding objects to the template.
21
Creating a new template
Template Builder
A new template can be started from the entry screen of the Template Builder workspace, or at any time
once working inside the workspace.
Step 1: From the entry screen select New, Template.
If Template Builder is already open and another template is being edited, it is possible to start a new
template without closing the current one. From Controls toolbox, choose New Template. (Or, right-
click in a blank area of the template builder graphics window to access the Controls toolbox.)
22
Creating a new template
Step 2: The new Template is automatically given a name such as Template1, and appears in the Model
Browser. The small blue “clock” over the Template icon indicates that it has not yet been saved.
Step 3: Double-click on the icon to open up a Properties dialog box. Enter a display Label for the
template, if desired. Otherwise the Name will be used as the display label.
Step 4: Type in a new Name, which will be used as the file name for the template, and need not be the
same as the label.
Step 5: Enter a brief Summary for the Template. Enter a detailed Description in the large text box, and
Apply. The template label is updated in the Model Browser and the properties title bar.
Step 6: The Version is automatically set to 1.000 and normally should not be changed for a new template.
Step 7: Indicate whether you want to “Save current unit system” in the template. If checked, the current
user Units will be checked against the saved Unit system upon execution. You will be prompted if
mismatch of units occurs.
Step 8: Revisit the Properties dialog box later, once the template actions, inputs, and outputs have been
established. For now, close the Properties panel by clicking Ok.
Step 9: Proceed to insert actions into the template, as described in Inserting objects in a template.
23
Recording a Macro
Recording a Macro
The Macro Record feature can be used to capture the code associated with the SimXpert commands
executed in one of the SimXpert analysis workspaces. (Structures, Crash, etc.) A template file (*.proc)
is created, which can later be edited in Template Builder.
Step 1: To turn on Macro Record, go to Tools menu, then Macro, Record New Macro.
Step 2: A dialog box appears. Enter the Name
Step 3: Select a Format:
• Neutral - saves only a template file (*.proc)
• Python - saves both a template file (*.proc) and the associated Python script (*.py)
Step 5: A small control button toolbar appears. Use the Pause control button (right button) to temporarily
stop recording at any time without ending the recording session. Click again to resume.
Step 6: Execute the SimXpert commands to be recorded. During recording, the record-able commands
in menus, toolbars and toolboxes are marked with a small red dot and/or the label “(Rec.)”
24
Recording a Macro
The recording may include the execution of templates, macros, and scripts. Their execution will be
recorded as part of the macro. For Template execution, only the full, successful, execution of the template
is recorded (i.e., stepping through Actions is not recorded).
Script execution from the Script editor (or Macros dialog) is also recorded as an Embedded Script Action
in the macro. If an unmodified script file is opened and executed, then a reference to the file will be
recorded. Otherwise, the script code itself will be copied into the recording.
Everything that is recorded to a macro is also recorded to the session file.
Step 7: Click the Stop button when done. A macro file will be saved as a template (*.proc) file format.
The saved macro file may later be refined and edited in Template Builder.
Recorded macros may be replayed as a “macro” using the Tools, Macro, Macros menu. In this case the
Unit System will automatically change to the recorded unit system. Or a recorded macro, since it is a
template, can be edited in Template Builder or executed in the Template Execution window.
See Also:
A brief video that covers the steps of macro recording and editing in Template Builder can be found on
SimCompanion.
Gesture recording
When picking of objects is done during macro recording, the pick gesture is saved in detail. This goes
beyond simply recording object i.d.’s. The saved information includes the scene (model objects
displayed, viewing angle, and zoom) and the screen location of the picks.
When replaying a macro / template using saved inputs, the pick gesture is recreated, resulting in the same
view, scene, and the saved screen locations (area or single pick). Even if their object ID's are not the same
as those during record, object in the same location of the model will be picked. See Running a Template
for more information on running templates with recorded inputs.
Limitations on recording
Certain commands and picking options are not yet fully supported for gesture recording and playback. If
any of the following are done during macro recording, then only object ID’s are remembered, not gesture
data:
• Undo/redo
• Pre-selection of objects
• Reverse Selection (from Pick Filters toolbar)
• Picking of contact bodies
25
Recording a Macro
Arranging
Inserted objects may be moved around using click-and-drag. Multiple objects may be selected using
window selection or by holding the Ctrl key. Then click and drag the selection to move multiple objects
together.
Deleting
To delete an object, right-click on it and select Delete from context menu. Multiple objects may be
deleted by selecting while holding Ctrl key, then right-click on one of the selected items and Delete.
The detailed procedure for inserting each type of object into a template are discussed in the following
sections.
A Custom Action may be located outside the default locations, and thus will not be found using Search.
In this case, use the Browse... tool in the Actions toolbox to initiate a file browser dialog box. Navigate
to the directory where the Custom Action file is stored, and select Open.
Once an action is selected, the mouse pointer temporarily changes to an action icon outline.
Step 3: Drop the action into the graphics window by clicking at the desired location within the new
template.
Hint: • To automatically create a Connection, place the action on top of the preceding
action in the template.
The action icon is now seen at the selected location. This creates an action instance that is linked to the
selected action file.
28
Inserting objects in a template
It is given the name of the selected action, with a sequence number appended. It is a linked action (i.e.,
an instance of the Action) and as such, there are limitations on which of its properties can be changed. A
small “shortcut” arrow is seen over the action icon in the graphics window and in the Model Browser.
This identifies the action as linked to another.
Step 4: Double-click on the linked action in the Model Browser tree or flow chart to open the Properties
dialog box.
Step 5: Since the linked action is an instance of an Action, only a few properties may be changed. On the
Properties page, you can change the label, prompting behavior for inputs, display icon style, and
execution mode (auto, manual-on, or manual-off). See Action Properties dialog box.
Step 6: Click Inputs page to set or modify the values of input parameters for this instance of the action.
Step 7: Click Ok to apply changes and close the dialog.
Notes: • To open the Action for editing, click the Edit button on the Properties page. This
will open the Action editor. (The Edit button is disabled for Core Actions that are
delivered with SimXpert as part of the action library; they may not be edited.)
• If changes are made to a Custom Action, all instances of the action in templates
can receive the modifications.
29
Inserting objects in a template
See Also:
See Core Action library for a listing of Core Actions in SimXpert.
The Search tool can also be used to locate a template using a text string search. Or use the Browse tool
in the Templates toolbox to initiate a file browser dialog box. Navigate to the directory where the
template files (*.proc) are stored, and select Open.
Once a Template is selected, the mouse pointer temporarily changes to a template icon.
Step 2: Drop the Template into the builder window by clicking at the desired location within the current
template.
Step 3: An instance of the template appears and the template icon is seen at the selected location. This
represents a link to the original template. It is given the name of the original template, with a sequence
number appended.
This is similar to a linked action. Note that any changes to the template file will result in change to all
instances of that template.
Hint: To automatically create a Connection, place the selected template on top of the preceding
action in the template.
30
Inserting objects in a template
Step 2: Click in the graphics window on the task that will precede the embedded template, or anywhere
in the window where the new embedded template is desired.
The new embedded (child) template is automatically given a name, such as Process1. A blank template
editing window is opened in the graphics area.
Step 3: From this point, the procedure for adding content to the embedded template is identical to that
for creating a new template.
Step 4: Open the template Properties dialog box by double-clicking on the embedded template in the
Model Browser. From Properties panel, the name, summary, and description may be changed.
It is also possible to create an embedded template using existing objects in the template. See Creating an
embedded template from existing actions for details.
See Retrieve and insert into template in the SimManager Interface section for details.
See Retrieving from SimManager for details on the SimManager interface.
Creating an Action
Template authors who are comfortable writing Python scripts can create their own actions. These may be
embedded in a template or saved as a separate re-usable action file.
Embedded Script
Advanced users may wish to create a Custom Embedded Action (embedded script) that is saved as part
of a Template. It will not appear separately as an action in the Action toolbox when saved. This is
appropriate in cases where re-use of the script is not anticipated.
The steps to create an embedded script are briefly described below.
Step 1: From the Controls toolbox, select Embedded Script tool to insert a Custom Embedded Action
into the current template being edited.
Step 2: Click at the desired location in the graphics window to drop the embedded script icon into the
current template. It is given a default name, such as “Script01.”
Step 3: Double-click on the script icon to open Properties dialog box. Refer to the section Action
Properties Dialog box, Properties page for details on filling out this dialog box.
Step 5: Click the Edit button to Open embedded script editor. Define Inputs and Outputs on the Data
tab, and add the Python script on the Code tab. Click Ok to close the action editor.
Step 6: The Properties panel will still be open. Save the code from the Publish page of Properties and
click Ok to close the window.
See Also:
For full details, see: Creating Actions, Creating an embedded script, in this User Guide.
33
Creating an Action
Step 2: A Create New Action dialog box opens for the new script action. Enter the Label, Name, Type
(Python or RADE) and destination directory, then OK.
Step 3: The Action Editor is opened automatically. There are four tabs along the bottom. Starting with
the Data tab, add new Input parameters using + button. Add Output Parameters in the same way.
34
Creating an Action
Step 4: On the Code tab, click Update to add specified inputs and outputs to code.
Step 5: On the Code tab, add Python or RADE code to the Action.
Step 6: Use the Layout tab to create or import a custom input dialog box.
Step 7: Select the Advanced tab at the bottom of the Action editor to modify the Action Options, add
Meta Data, or add detailed documentation.
Step 8: Return to the Data tab to Save and optionally Publish the new Custom Action.
Step 9: Once the new Custom Action is saved or published, it is available to place into a Template as
described in Inserting objects in a template, above.
See Also:
For a more detailed explanation of each step, see the section: Creating Actions, Creating a new script
action
35
Creating an embedded template from existing actions
Step 4: The selected actions are replaced with an embedded template, which is given a default name, such
as Process01.
Step 5: Double-click on the new Embedded Template to open its Properties panel. From there you can
change the name, display icon, etc.
Step 6: Or click on the Embedded Template name in the Model Browser to edit it, such as adding or
removing actions or modifying connections.
Notes:
1) When creating the Embedded Template, select two actions only: the first and last action. If more than
two actions are selected, or if any connections are selected, the Create Embedded Template command
will not be available on the context menu.
2) Embedded Template creation is not allowed if the first and last actions are on different levels of the
template hierarchy. For example, if the first action is before a Choice control and the last action is after
the Choice, the Embedded Template creation will fail and an error message will be shown.
36
Controls toolbox
Controls toolbox
In addition to tools for Creating an Action, the Controls toolbox has several tools for establishing template
process flow and gathering user inputs.
Template sequence and data flow are established using the Connection tool. Connection tool defines the
order of actions in the template. In addition, outputs from one action are assigned as inputs to another
with the use of this tool.
From Controls toolbox, interactive features can be added to a Template with the use of the File, Choice,
and Prompt tools. These tools provide a template author the means to gather user inputs and choices
during template execution. These might include instructions to enter numerical and string data, to supply
a data file, or to make a choice between several options.
Iterative portions of templates can be set up using the three Loop tools provided. An action or a group of
actions may be specified to repeat until some condition is satisfied.
These tools are covered in turn in each of the following sections.
37
Connection tool
Connection tool
The actions in a Template are chained together with the Connection tool. Use it to define both Control
Path (sequence of actions) and Data connector (outputs of one action connected to inputs of another).
Step 1: On the Controls toolbox, select Connection.
Step 2: Click on the action to be executed first (source) and the connection icon becomes attached to the
mouse pointer.
Step 3: Then click on the subsequent action (destination). An arrow between two actions indicates the
connection has been created. A bold blue arrow indicates the control path, and perhaps a data connector
as well. A black arrow indicates a data connector only.
A connection icon also is shown in the Model Browser for the template.
Step 4: To open up the property page for a connection right-click on it and select Properties. All
available outputs from the previous actions are listed on the left. All inputs for the downstream action are
38
Connection tool
shown on the right. Click the dot by an output, on left, then select an input, on right, to make the data
connection.
Three check boxes on the upper right allow user to specify the following properties of the Connection:
• Visible - On by default. Un-check to hide a connection.
• Splines - When activated, connections appear as curved lines. When un-checked, connections
are displayed as orthogonal lines.
• Control Path - When checked, indicates that the connection is part of the process flow. If un-
checked, connection is a data path only. You may check this box if it is desired to make the
connection a control path.
The following buttons are found on the right side of the dialog:
• Auto Connect - When pressed, Template Builder attempts to make automatic connections by
matching parameter names and/or data types between the left side (prior action’s outputs) and
the right side (downstream action’s input parameters).
• Reset - Remove all connections and start over.
39
Choice tool
Choice tool
The Choice tool is used to provide user with a choice of actions during template execution and to provide
branching in the control path.
Step 1: Select Choice tool in the Controls toolbox.
Step 2: Click on the action that will precede the Choice. The choice action (diamond icon) is placed after
the selected action and automatically connected.
Step 3: The choice block should be connected to all possible downstream actions. Create Connections
between the choice block and each of the actions representing the choice options. (See Connection tool
section.)
Step 4: Open the Properties panel for the Choice action by double-clicking on it in the Model Browser
(or right-click in the builder window and select Properties). Type a Name and brief Summary for the
choice action in the text boxes, if desired.
Step 5: In the Value column of the table, enter the following items:
prompt - enter the message that will appear to the user.
numOptions - enter the number of choices.
40
Choice tool
option1, option2, etc. - type in the name of each option as it will appear to the user.
Step 6: Select options for the choice tool at upper right: Prompt for Inputs, Display, and Execution.
See Action Properties dialog box, Properties page for details on these options.
Step 7: An action should be linked to each choice. Select an option, then go to the Link drop-down list
and select the appropriate action for that choice. Repeat for all choice options.
Step 8: Click Ok to apply changes and close the Properties dialog box.
41
Simple Loop tool
Step 2: Click again in the graphics window on the action that precedes the loop. A Connection is made
automatically.
Step 3: Then create a Connection between the loop icon and the first action in the loop (loopAction).
Step 4: Make another connection from the Loop to the action that takes place after the loop is completed
(breakAction). See Connection tool section for help with connections.
Step 5: Add actions and make connections to form the Loop. Make one more Connection from the last
action inside the loop back to the Loop icon. This completes the loop.
42
Simple Loop tool
Step 6: Right-click on the Loop icon and select Properties. Enter a Name and Summary at the top of
the Properties dialog box.
Step 7: Select options for the loop tool at upper right: Prompt for Inputs, Display, Execution, and
Show Connected Inputs. (See Action Properties dialog box, Properties page for details on these
options.)
Step 8: Select the breakAction row in the table, then select a Link from the drop-down list to identify
the connected action that takes place when the iterations of the loop are finished.
Step 9: Select loopAction in the table and then select an action in the drop-down list that identifies the
connected action that is at the start of the loop.
Click Apply to save changes.
Step 10: Go to the Inputs page and double-click in Value field of the input parameter: count to set the
default value. (number of times to execute the loop). Check the Hidden box to hide the input and
suppress prompting.
Step 2: Follow the same procedure as Simple Loop tool to place the For-Each Loop icon into the template
and establish Connections. Add and connect all loop actions.
Step 3: Double-click on the icon to open the Properties dialog box, which is nearly identical to the
Simple Loop. Enter a Name and Summary at the top. Select options for the loop tool: Prompt for
Inputs, Display, Execution, and Show Connected Inputs.
Step 4: Follow the same procedure as the Simple Loop tool to specify the links for Break Action and
Loop Action. Check the parallel box (future capability) to have the loop actions processed
simultaneously for each list item. (e.g., to run parallel on different CPU’s)
Step 5: Go to the Inputs page of the Properties dialog box and, if appropriate, set the default values for
the input parameter named list. Separate the list items with a semi-colon. (Usually the list will come from
a user selection or a prior action.) Check the Hidden box to hide the input and suppress prompting.
Step 7: Check all Connections and parameters being passed from one loop action to another. Check that
the input list is connected, if coming from a prior action.
45
While Loop
While Loop
The “While” Loop tool is very similar to the Simple Loop. In this case, there must be two inputs to the
loop. Each time the While Loop is executed, an expression involving a comparison of the two inputs is
evaluated. The loop is repeated as long as the expression remains true.
One of the inputs must be modified during the loop such that the expression eventually becomes false.
At that time, the template exits the loop and goes to the break action.
Step 1: From Controls toolbox, select While Loop tool.
Step 2: Follow the same procedure as Simple Loop tool to place the loop icon into the template and
establish Connections.
Step 3: Double-click on the icon to open the Properties dialog box. The Properties dialog is nearly
identical to the Simple Loop. Enter a Name and Summary at the top.
Select options for the loop tool at upper right: Prompt for Inputs, Display, Execution, and Show
Connected Inputs:
46
While Loop
Step 4: Follow the same procedure as Simple Loop tool to specify the links for breakAction and
loopAction.
Step 5: Select an operation for comparing the two input parameters, using an expression of the form
operand1 (operation) operand2.
For example, operand1 equals operand2.
Operations include:
• equals
• does not equal
• less than
• greater than
• less than or equal
• greater than or equal.
Step 6: Go to the Inputs page of Properties dialog box and, if appropriate, set the default values for the
two input parameters, operand1 and operand2.
For example, both operands might initially be set to “Yes.” Inside the loop, a prompt to user allows for
selection of “Yes” or “No.” The operation “operand1 equals operand2” would become false
when “No” is selected and the template would exit the loop.
File tool
The File tool allows for prompting user to select a file (or files) to be opened or saved during template
execution.
Step 1: From Controls toolbox, select File icon to place a file prompt into the current template.
Step 2: Click in the graphics window at the location where the file prompt is desired to place it into the
Template.
Step 6: Select Inputs on left. Double-click in Value text box and enter a default file or folder name, if
any.
Step 7: Select Publish at left to review the Publish page. Although the File Prompt action is not normally
saved as a separate action when a template is saved, it is possible to save a File Prompt action from the
Publish page of Properties panel so that you can quickly create a File prompt with the same options.
Step 8: Click Ok to save and close the Properties dialog box.
49
Prompt tool
Prompt tool
The Prompt tool is an action that prompts the user to supply a data string during template execution.
Step 1: Select the Prompt tool from Controls toolbox to add a prompt action to the current template.
Step 2: Click again in the graphics window at the location in the current template where the prompt
action is desired.
Step 3: Double-click on the new prompt action to open the Properties dialog box. Enter a Name and
Summary at the top.
Select options for the Prompt tool at upper right: Prompt for Inputs, Display, and Execution.
Step 4: Type in the message that will be displayed to the user in the Value field.
Step 5: Select Inputs on the left side. Double-click in the Value text box and enter a default response, if
any.
Step 6: Select Publish on the left side. Although the Prompt action is not normally saved as a separate
action when a template is saved, it is possible to Save a Prompt action from the Publish page of Properties
panel.
Step 7: Click Ok to save and close the Properties dialog box.
50
Message tool
Message tool
The Message tool displays a dialog box with a prompting message to the user upon execution and asks
user to confirm or reject the displayed message.
Step 1: Select the Message tool from Controls toolbox to add a message action to the current template.
Step 2: Click again in the graphics window at the desired location in the current template.
Step 3: Double-click on the new Message action to open the Properties dialog box.
Step 4: Type in the Name of the message action and a brief Summary in the text boxes.
Step 5: Select msgType in the property table. Click the drop-list arrow and select one of the following
message types: Ok, Ok/Cancel, Yes/No, Yes/No/Cancel.
Note: If Cancel is selected by the user, the template execution will be aborted.
Step 6: Select prompt and double-click in Value text box. Enter the message that will be displayed to
the user.
Step 7: Select Inputs on left. Double-click in Value text box and enter a default response, if any.
Step 8: Select Publish at left to review Publish page. Although the Message action is not normally saved
as a separate action when a template is saved, it is possible to Save a Message action from the Publish
page of Properties panel. Click Ok to close the Properties dialog box.
51
Template Properties dialog box
Properties
To display or edit the general properties of the Template. Note that the Properties panel for an embedded
template does not have all the options shown here:
Enter a Label, which will be used to identify the template in the graphics window and bubble tips.
Provide a Name, which is used as the file name. By modifying the Name or Location of an existing
template, copying of a template is accomplished. (See Publish, below.)
Enter a brief Summary and a detailed Description for the template.
The Version consists of a major version number (e.g. 1.000 vs. 2.000) and a minor version number (e.g.
1.001 vs. 1.002). The minor version number is incremented each time the template is saved. The + button
52
Template Properties dialog box
is used to increment the major version number and should only be done when its behavior has changed
to make it incompatible with “parent” Templates that may be using it. (This is relevant when the template
is nested within another template.)
The default Icon may also be changed here. Click the file browse button to locate an icon for the
template.
An option button is present to Hide Actions in a template. This might be done in the case of a sub-
template, or when the user does not need to see the constituent actions.
Select the Show only unused outputs check box if it is desired to limit the Outputs page to display only
output parameters that are not connected to inputs.
Check the box to Save current unit system if it is desired to always execute the template in the current
unit system. If attempted to execute in a different unit system, the user will be asked to change the units.
Click Apply button to make changes immediately without closing the Properties dialog. Click Ok to save
changes and close the dialog. Click Cancel to close the Properties dialog without saving changes.
Inputs
The Inputs page shows all inputs for all Actions that are not yet connected to outputs (that is, undefined
inputs) for the entire template. These inputs will be supplied by the user during template execution.
Input parameters are not created here, but rather in the individual actions in the template.
Default values for inputs can be specified in the Value column. Double-click in any text box to edit, or
in some cases, select from a drop-down list. This is especially important if Input prompting for any of the
actions is set to “Use Defaults.” Default values set here, at the template level, will take precedence over
the default values set in each Action file.
53
Template Properties dialog box
If an Input is connected to a prior Output, or if a default Value has been specified, you can check the
Hidden box to suppress prompting for that input.
‘
Note: If a real input parameter type is defined with a Unit Value user interface, the action Inputs
property page will show the units expected, e.g. 10 (mm). Values are stored internally in
MKS (internal model units), rather than user-selected model units.
Expressions
Instead of entering a value, you may use an “Expression” which will result in an action or python function
being run in the background to resolve the Value of an input. An Expression is of the form:
“=act1(x,1,1),” where act1.act is the action to be evaluated. It must start with an equal sign, followed by
the name of the action or Python module evaluated. The parentheses contain the inputs for the expression
and must be present, even if empty. In the case of a python module the format would be: =module.func(x,
y, z).
As soon as you start to type “=” in the field, a list of actions that can be used in an expression pops up.
Select the action from the list and complete the parameter section. The valid locations which will be
searched for expressions are defined in Tools > Options > General > Custom Expressions. You may also
designate certain Python modules that will be imported before evaluating an Expression.
Outputs
The Outputs page shows all the outputs of the Template. When “Show only unused Outputs” is selected
on the Properties page, only the outputs that are not connected to any inputs of a subsequent action are
shown. This page is for review only; no editing is possible. Outputs are defined in the Action editor for
each individual action in the template.
54
Template Properties dialog box
Publish
The Publish page of template Properties enables you to Save locally or Publish to SimManager, after
designating the file location, user interface, and applicable workspaces. Note that the Publish page for an
embedded template does not have all the same options as a stand-alone template.
Location
Set the folder where the Template will be stored.
Filename
The Filename will be automatically generated, based on the Location, above, plus the Name provided
on the Properties page.
Workspace
Designate the workspace(s) for which the Template is applicable by clicking the button to the right of the
Workspace(s) text box. Make multiple selections if the template can run in more than one workspace.
55
Template Properties dialog box
Create CSV
Click the Create CSV button to create a comma-separated values file that contains all inputs and default
values for the template. It enables you to specify multiple sets of inputs for running iterations
automatically. See Template Execution, Batch execution of templates for more details. All inputs for the
template must be included in the *.csv file (or valid defaults set), as it is not possible to have a mixture
of supplied inputs from *.csv and input prompting dialogs. Prior to creating the *.csv file, the prompting
for each action should be set to At Execution of Parent. Otherwise, Template Builder considers all
inputs as being resolved internally and no prompting required.
Right-click on the Batch Input Data object in Model Browser to open the *.csv file in a spreadsheet
editor.
Create Layout
Click the Create Layout button to create a form for Template inputs. Any existing layouts will be
replaced. If a dialog box with a separate tab for each action is desired, place a check in the “Create layout
with each Action on a tab” button.
The input layout is saved as part of the template file. Right-click on it in Model Browser to open it in a
text editor.
56
Template Properties dialog box
It may be saved as a *.ui file, which you can then edit in Qt Designer (www.trolltech.com) or a text editor.
Editing this file will allow for changing the size, shape, and order of text boxes and choices in the
template inputs dialog box.
Save
Saves the template to the local file Location. The file name is established from the Name field on the
Properties page.
For embedded templates, this causes a copy of the embedded template to be saved as a separate template
file, but does not change the status of the current template as embedded. Nor will the newly created
template file be linked in any way to the current embedded template.
Publish
Saves the template to a local drive and also to SimManager. The template is then available to other users
to retrieve or to run in a managed execution mode. (SimManager can manage the execution of template
and results files.) See Publish a Template from Template Builder for details.
Publish as Resource
Saves the template to a local drive and also to SimManager. This option is used when author wishes to
make the template file available to other users. The template can be retrieved and run locally, but cannot
be run using managed execution in SimManager. See Publish Template as Resource for details.
See Also:
Refer to Publishing from SimXpert to SimManager in this User’s Guide for more details.
Preview
Click the Preview Button to open a window that displays the template contents in a hierarchical list,
similar to the tree view in Model Browser.
57
Action Properties dialog box
The properties that can be edited include: Prompting behavior, Display icon, Execution (optional or
automatic), and Default values for inputs. For controls and linked actions, these properties are applied
only to the selected instance of the action. The source script file (*.act) is not affected by any changes
made here. For an Embedded script, the changes are immediately applied.
Hint: To keep open a Properties box at all times that refreshes according to the object selected,
go to Tools, Options, Template Builder options. Select Use dynamic window button on
General tab.
The Properties page for Embedded Script (shown in the image below) is significantly different from the
Properties page for a linked action because the embedded script is fully editable. For an Embedded
58
Action Properties dialog box
Script, there are four pages in this dialog box: Properties, Inputs, Outputs, and Publish. Each page is
accessed by clicking the icons on the left side.
.
.For Linked Script Action, there are only three sheets in the Properties dialog box. Publish sheet is not present. The Properties sheet is slightly different, and is limited in the items that may be changed.
For a linked action instance there are three pages: Properties, Inputs, and Outputs.
Properties page
All displayed fields can be changed from the Properties page for an Embedded script. These include
Name, Summary, Script type, Prompt for Inputs mode, Display icon, and Execution mode.
59
Action Properties dialog box
For a linked action, only the Label, Input mode, Display icon, Execution mode, Show Connected
Inputs, and Required Version may be modified from Properties page.
Any other changes must be made to the Custom Action file using the Edit button, which opens the Action
editor for the script action. (Core SimXpert actions may not be edited.)
.
Label
Only present for linked action. A unique label may be assigned to each instance of an Action.
Name
Name of the action (file name). Not editable for linked action. For embedded script the Name field is used
as the label since there is not a separate file saved.
Version
Linked action only. Not editable. Shows the version of the core action that was in effect when the
template was last saved. See also: Required Version
Summary
60
Action Properties dialog box
• At execution of Parent - select if all undefined inputs are to be gathered at the start of template
execution. This might be desirable if the template is to be run in a batch mode.
• At execution of Action - Wait until just before the action is executed to prompt for inputs. A
dialog box appears prior to executing the action. This makes the template more interactive, and
may be necessary if an input is not available at the start of template execution.
• Never - To skip prompting and use default values (as specified on the Inputs page of the Action
properties dialog box) or connected inputs from a prior action. Use this option if you are sure that
prompting is not needed.
Display
Select the type of icon that will be seen in the Template Builder and Execution windows:
• Icon - to show the assigned icon (graphic symbol) for the action.
• Graphics Snapshot - to display a small SimXpert graphics window. The graphics snapshot
window is interactive and the SimXpert display commands (rotate, zoom, etc.) can be used. It
may also be re-sized.
• Bitmap Snapshot - a non-interactive re-sizable snapshot of the SimXpert graphics window.
• Block View - For templates and embedded templates only. Displays a small re-sizable SimXpert
Template Builder graphics window, with actions and connections shown in block view.
Execution
An action can be made optional at runtime by selecting one of the “manual” execution settings.
61
Action Properties dialog box
• Automatic - The action is always executed. The option to skip the action will not be available at
runtime.
• Manual-On - The action will be run by default, but user can toggle the action to skip it during
template execution. This can be done prior to template execution, or during a pause in execution.
• Manual-Off- The action will be skipped by default, but user can toggle the action to run it
during template execution.
In the following examples, “input1” and “input2” are connected to outputs from a prior action:
Required Version
For a linked action, this setting allows you to specify the version of the Action to use. If Any is selected,
the latest version will be located and used whenever the template is opened for editing or execution.
62
Action Properties dialog box
If a Specific version of the action is selected, the current major version number for the linked action is
stored in the template. Whenever the template is opened for editing or execution, the core action is
checked to make sure its version number has not been changed. If it has changed, a warning is issued to
the user indicating that the action instance is incompatible and should be updated to match the latest
version of the core action. See Update, below, and also: Action Data page - Identification
Link
Applicable for certain actions, like Choice, that link possible choices to different actions.
Script Type
For an embedded action, specify the language: Python, RADE, or Existing File.
If Existing File is selected, another line appears in the Property table for scriptFile. Click the file
navigation button on the right side of the Value column, and locate the existing file. (Python, RADE, or
XML)
Edit
Click Edit to open the Action editor for the embedded script. In the case of a linked action, this opens the
Action editing dialog for the Custom Action. Any other instances of the script action are therefore
affected by the changes made.
SimXpert Core Actions cannot be edited and the button will be disabled in that case.
Update
Linked action only. Updates the version of the action to the latest. If Required Version is set to a Specific
version, that field is also updated to the latest.
Reset
Embedded script only. Resets the Properties page to the default values.
Inputs page
The Inputs page displays a table of all the input parameters. The Input Name, Type, default Value, and
Hidden attribute are shown. Input parameter names and types may be reviewed, but not modified from
63
Action Properties dialog box
this page. To modify an input parameter name, type, or to add or delete parameters, click Edit... on
Properties page to open the Action editor.
Default Values
The default input parameter values for the action instance may be modified here, in the Value column.
Note that these are synchronized with any default values set on the Inputs page of the Template Properties
dialog box. Values can be changed from either location. Setting input values for a linked action in a
template does not affect the default values stored in the source Action (*.act file).
For Real parameters that are associated with a model unit (length, time, mass, etc.), values are shown in
the currently selected user units. (e.g., mm, sec, kg, etc.).
Instead of a Value, you may enter an Expression to be evaluated to determine the input’s Value. See
Expressions.
Hiding inputs
If a default Value is set for an input parameter, you can then select the Hidden check box. This will hide
the parameter in the input dialog box during execution of the script. Do this only if you wish to always
use the default value specified. In the following example, “input2” is hidden and cannot be changed.
Outputs page
Click Outputs on left side of Properties panel. Outputs may be reviewed, but not modified from this page.
To modify outputs, click Edit... on Properties page to open the Action editor.
64
Action Properties dialog box
Publish page
Click Publish on left side of Properties panel. (Embedded script only. Not present for linked actions.)
Normally when a template containing an embedded script is saved, a separate action file is not created.
However, from the Publish page of Properties panel, the file location can be set using the Browse icon.
Then click Save to create a separate custom action file.
The new *.act file is a snapshot copy of the embedded script and can be modified and reused in templates,
just like any custom action. The new action is not linked to the original embedded script, which remains
as-is, internal to its parent template.
65
Testing a Template
Testing a Template
Save the template prior to testing. Right-click on a template in the Model Browser tree and select Test
to open the Template Execution window.
Context menus
Delete
Removes the selected Template from the Model Browser, but does not delete any files. Any unsaved
changes will be discarded.
Properties
Opens the Template Properties dialog box.
Save
Save the current Template to its default file location. Any unsaved actions in the current template are also
saved at this time. Note the blue “clock” icon is removed from the template and all of its actions,
indicating that it has been saved.
67
Context menus
Publish
Allows you to Publish a Template from Template Builder to SimManager. Same as using Publish button
in the Template Properties dialog box.
Publish as Resource
Same as using Publish as Resource button in the Template Properties dialog box. The template File is
stored in SimManager and can be retrieved by other users for local execution or for insertion into another
template. A template published as a resource cannot be run in managed execution mode. See Publish
Template as Resource.
Help
Opens a text window displaying the Template Name, Label, Summary, and Detailed description. The text
may not be edited (Go to Template Properties panel to edit), but may be copied. This is the same
information that is shown in the Tool Tip for the template.
68
Context menus
What’s Wrong
Shown only if the selected template has errors, as indicated with red circle icon. Prints a summary of
findings to the Messages window.
Update Report
Checks all action and template instances in the selected template for version compatibility with the latest
version. Prints a summary of findings to the Messages window.
Test
Open Template Execution window for running the template.
Delete
Removes the selected action from the template or Model Browser, but does not delete any files. Any
unsaved changes to the action will be discarded.
69
Context menus
Multiple items may be selected by holding Ctrl key while selecting. Then right-click on one of the
selected items and Delete.
Properties
Opens the Action Properties dialog box.
Save
Saves the selected action.
Publish as Resource
Initiates a connection to SimManager to publish the Action. See Publish an Action from Template Builder
for details.
Update
Using Update command resets the input parameter defaults for this instance of the action to the default
values saved in the source action (*.act) file. It will also update the Version of the action used and the
Required Version (if Specific) to be the latest.
Edit Code...
Opens the Action editor.
Help
For built-in SimXpert actions, it opens a standard SimXpert Help window. For Custom Actions, a text
window is displayed containing the Action Name, Action Label, Action Summary, Action Details, and a
list of input and output parameters and their summaries.
Delete
Removes the selected tool from the template.
Multiple items may be selected by holding Ctrl key while selecting. Then right-click on one of the
selected items and Delete.
70
Context menus
Properties
Opens the Properties dialog box for the particular tool.
Help
Opens a standard SimXpert Help window.
This opens the User Options dialog box. Scroll down to Workspaces and expand Template Builder
Options.
General
On the General options page, you can select defaults and display options:
72
Template Builder Options
• Show Action balloon tips - The action and toolbox tips can be enabled or disabled using the
check box. When enabled, a balloon containing tips about an item will appear whenever the
mouse hovers over the item.
• Input mode for new actions - If Action’s default settings is selected, the prompting behavior for
action instances will be the same as defined in the script action file. If Prompt for Inputs is
checked, the default behavior for prompting will be to prompt just before each action.
• Version reference for new Actions - Select whether to “Use Latest” (always update to the latest
version of actions) or to “Always use the current version,” which was the version when inserted
(or later modified).
• Display Settings - Select large or small icon size and graphics window background color.
• Property Window - If Use dynamic window is selected, a floating property editor is displayed
that always show the properties of the selected item(s). Otherwise a dedicated dialog will appear
only when user double-clicks on an item, or selects Properties from a context menu (right-click).
73
Template Builder Options
Connector
The Connector page in Template Builder Options allows you to specify default settings for connectors.
• Visibility - Using drop-list, the organization of connections in the Model Browser may be
changed so that connections appear under source, destination, in a separate Connections folder,
or hidden altogether.
• Default Connector Style - Spline or orthogonal connector style may be selected.
• Auto-connect Data - The behavior of automatic data connections may be changed. If Match
data type is selected, template builder will attempt to make automatic connection if output
parameter and input parameter types match. If Match parameter name is selected, automatic
connection is made when the parameter names match.
Location
The default path for browsing and storing templates and actions may be specified on Location page.
Multiple paths can be created using Add button so that more than one destination can be searched. One
must be designated as default by selecting a check box in the Default column.
74
Core Action library
Actions toolbox:
Hint: • During macro record, the “recordable” commands are indicated with a red dot.
These recordable commands have a corresponding action in the Actions toolbox.
75
Core Action library
The following tables may be helpful in locating the action corresponding to a specific SimXpert
command or tool. This not a complete list, but provides some examples of where to look in the Actions
toolbox. The left side (Level 1, etc.) shows the menu or toolbox navigation to execute the command in
the Structures workspace. The right column shows the folder navigation in the Actions toolbox of
Template Builder to locate the corresponding action.
File menu:
Edit menu:
View menu
Tools menu
Creating Actions
82
What is an Action?
What is an Action?
An Action is the lowest level building block of a template. It is a black-box entity that performs a specific
task from inputs and generates outputs. An Action is typically a script containing code (Python or
RADE), and input / output parameter definitions.
Inputs are collected prior to executing the action and outputs are passed upon completion. Inputs may
come from other actions, or may be supplied by the user. Outputs may be assigned as inputs to another
action or may be provided to the user upon completion of the template.
An action can be a Custom Action (user-written) or a Core Action (included in the SimXpert Action
library). Both of these are saved as *.act files. An action may also be embedded in a template, in which
case it is not saved as a separate file.
Please refer to Types of objects used in a SimXpert template in the Introduction for a discussion of the
different types of Actions.
83
Creating an Action
Creating an Action
Open the Template Builder workspace
From the entry screen to SimXpert, Click Template Builder from the list of workspaces.
M
If SimXpert is already opened in a different workspace, use the Open Workspace icon at upper right,
and select Template Builder from the list box.
The Template Builder window presents a list of choices for creating and editing Templates.
For creating an Action, select New..., Script Action. This will create a new *.act file which will be stored
in a location specified by the action author. This new action will be reusable in other templates.
84
Creating an Action
Embedded Script - To create a Custom Embedded Action that will be saved as part of the current
template. See Creating an embedded script, for details.
New Script Action - To create a new Custom Action which will be saved as a separate action file, and
will be reusable in other templates. (Same as New..., Script Action, above.) See Creating a new script
action, for details.
Step 3: Type in a Label which will identify the action in the Template Builder and Template Execution
windows.
Step 4: Enter a unique Name for the new Action, which will be the file name. The *.act extension is
added by Template Builder and identifies the file as an action.
Note:
If Name begins with a numeral, an underscore character will be added in front of the name. For example,
if Name is entered as “1MyAction,” it becomes “_1MyAction.act” when the file is saved.
Step 5: Select the Type. This defaults to Python Code.
Step 6: Select Location where the new action will be stored. Use the Browse icon to navigate to the
desired directory.
86
Creating a new script action
Step 7: The Filename field is populated automatically, based on Name and Location selections.
Step 8: Click Ok to open the Action editor.
87
Creating a linked action
Click at the desired location in the Template Builder window to drop the new script icon into the
template.
The Embedded Script Editor is a limited version of the Action editor for script actions. Differences
include:
• No Layout page
• Identification and Publish sections are not present on Data page. Instead, use the Properties panel
to change the embedded action’s name, description, and file location. (e.g., double-click on the
embedded script icon in the template.)
The Data page is devoted to Parameters. The procedure for creating parameters in the Embedded Script
Editor is the same as in the Action Editor. See Action Data page - Parameters for details on creating input
and output parameters.
The Advanced page is identical to the Action Editor window. See Action editor - Advanced page for
details.
90
Creating an embedded script
The Code page is identical to the Action Editor window. See Action editor - Code page for details.
91
Action editor
Action editor
The Action Editor is used to create and modify Custom Actions.
After completing the Create New Action dialog box (or anytime the Edit button is selected in the Action
Properties dialog box), the Action Editor opens. It occupies the entire Template Builder graphics
window.
This editor can be opened at any time by one of the following methods:
• From the entry screen to Template Builder, select Open, Browse... Actions have a file extension
of *.act. Navigate to the file and Open.
• Use the File, Open command from the SimXpert menu. A file browse dialog will assist in
navigating to the file location. Actions have a file extension of *.act. Select the file and Open.
• Click the Controls toolbox and select Browse... Actions have a file extension of *.act.
• If a template containing an instance of the Action is already open, right-click, Edit.
• If the action has already been edited in the current session, it will appear under the Actions
folder in Model Browser tree. Select the action to display the action editor.
92
Action editor
The Action Editor consists of four pages which are accessed by selecting a tab at the bottom of the
window.
Portions of the Data page may be hidden when not in use by clicking the double-arrow buttons, as shown.
94
Action editor - Data page
Icon: Select a new icon to represent the action in the template builder and execution windows, if desired.
Use the Browse icon to navigate to the location of a locally stored image file.
Version: The version will be set to 1.000 for a new script action. Increment the version only if you are
modifying an existing action and only when its behavior has changed to make it incompatible with
Templates that may be using it. This is done by clicking the + button and will result in a major version
number increment (e.g. from 1.000 to 2.000). A dialog box will ask you to confirm that you wish to
increment the version and to enter version comments.
95
Action editor - Data page
Notes: • The minor version number will be incremented automatically each time the Action
is saved. (e.g. from 1.000 to 1.001)
• When using a linked action in a template, the version number of the action is
stored in the template. This facilitates updating templates when an action is
modified.
• The Label and Summary of the action are part of the Tool Tip help that is
displayed when a user is browsing actions in Template Builder.
Location - This box is populated based on the entry in the Create New Action dialog box, when the action
was first created, but may be changed at any time. Use the Browse icon to specify a new folder location.
This will result in another copy of the action being created in the new location.
96
Action editor - Data page
Filename - Based on Location, above, and the Name in the Action Data page - Identification section a
complete file path is established, with a *.act extension. This field may not be edited.
Save - Saves the action to the Location specified. The minor version number will also be incremented
(e.g., from 2.001 to 2.002).
Publish as Resource... - Initiates a connection to SimManager to publish the Action. See Publish an
Action from Template Builder for details.
There are three possible views for the Parameters section, selected from the View drop-down list at the
top of the Parameters section:
97
Action editor - Data page
A new input parameter can be added by clicking the “+” button. A selected parameter can be removed
by clicking the “X” button.
Inputs can be reordered using Ctrl + Drag, selecting the sequence number at the left.
Or to move a selected parameter up or down, click on the Move Up or Move Down button.
To specify additional details (such as the user interface, or limiting selections to discrete values or a
range) you must switch to the Parameter Details view - Input view, below.
Input tab:
On the Input tab, you enter the name, type, constraint, user interface, etc. for the input parameter. See
Creating an Input Parameter for more information.
Advanced tab:
On the Advanced tab, you can add meta data to the parameter. See Creating an Input Parameter,
Advanced tab
99
Action editor - Data page
Object tab:
This tab is only displayed for parameters of type Object. It allows you to select the allowable sub-types
that can be picked from a model during execution, the prompt message displayed to the user, and to
establish a minimum and/or maximum number of objects to be picked. You can also set the option to
allow the user to create new objects during execution.
For details on the entries on this page, please see Creating an Output Parameter.
101
Creating an Input Parameter
The following instructions are shown in the Parameter Details view. Please note that some, but not all,
of the described steps can also be done in the Input Table view.
Step 1: To create an Input parameter, click the green “+” button in the Parameters section of the Data
page. Or select the arrow next to the “+” and select Add Input from the drop-down list.
When a parameter is added it is given a default Name, for example: “input1” and a default type of
“String” and you will see it in the parameter list.
Step 2: Click on any parameter to specify its attributes. A form will appear for defining the parameter.
The form has tabs at the top: Input, Advanced, and (sometimes) Object. First select the Input tab.
Input tab
Identification
Step 3: In the Identification section, enter a Label which is the display label that will appear in the user
interface when the action is run.
102
Creating an Input Parameter
Step 4: Enter the parameter’s Name. This will be the name used in the action’s Python code to refer to
this parameter.
Step 5: Enter the parameter’s Summary. This is a brief description of the parameter and becomes part
of the Tool Tip help that is displayed to users when selecting the action in Template Builder, so it is
important to properly describe each parameter.
Behavior
Step 6: In the Behavior section select the Optional button only if the parameter is not always required.
(By default the Required option is selected.)
Step 7: Select a different “Reset on Apply” behavior, as applicable. (for resetting action input defaults
upon clicking the Apply button in Action Properties panel.) The possible values are:
• Default: Inherit the behavior from the Action. If the Action has ResetOnApply set to “Reset
value to original default value” then the Parameter will be reset on Apply and not stored. If the
Action has ResetOnApply set to “Store previously used values” (default), then the Parameter
will not be reset on Apply and will be stored for later use. This is the default behavior when the
meta data is missing on most Parameters.
• Always: The Parameter will always be reset when Apply is clicked and never stored for later
use. Overrides the Action-level setting.
• Never: The Parameter will not be reset when Apply is clicked and will be stored for later use
(subject to the Object/Point rule above). Overrides the Action-level setting.
Note:
The reset behavior for an action and its parameters described above is only utilized when the action is
run as a tool (on tool ribbon). When run in a template, the defaults set at the template level will be applied.
However stored values from a previous template execution can be run by loading a saved execution file
or importing input values.
103
Creating an Input Parameter
Also see Action editor - Advanced page for selecting the Reset behavior at the Action level.
Definition
Step 8: In the Definition section, select the Type of parameter from the drop-down list. All the valid
parameter types are shown in the image below.
Step 10: Check the List box if the parameter is a list of values or objects.
Step 11: If the Type is Object, Point, Managed Object, CAD Object, or Enterprise Object, these have
sub-types, therefore you should also select the Object type.
104
Creating an Input Parameter
Constraint
Step 12: In the Constraint section of the form, a Constraint can be added to restrict the input to a Range
or Discrete values. By default there is no constraint on the input values, aside from being consistent with
the parameter type.
If a Range constraint is selected, then a lower and upper bound need to be entered.
For a Discrete constraint, you must specify all possible valid Options for the parameter. Use plus (+)
button to add valid options to the discrete options list. Enter a value in the Option column for each. To
remove an option, select it from the list, and click the “X” button.
The Discrete constraint can also be used when creating a “parent” input parameter for the purpose of
creating input Groups. (See also: Group)
Interface
Step 13: Pick an Interface for the parameter from the list box at the bottom of the Parameter Details
window. The user interface options vary according to parameter type. These built-in user Interface
choices allow you to provide the appropriate interface for each input parameter.
105
Creating an Input Parameter
For example, if parameter type is String with a File Chooser interface, it will automatically present the
user with a file browse dialog box during template execution.
With Discrete constraint, choose a User Interface of List, Drop List or Radio Group. For a Range
constraint, Spinner and Slider interfaces are available.
Step 14: Select the Properties for the chosen User Interface from the table to the right of the user
interface list box. The properties vary according to the parameter type and user interface selected.
For example, with parameter type of String, and user interface of File Chooser, one of the available
Properties is a filter, which is used to limit a file selection to only certain file extensions.
Review the section on Parameter Interface for details.
Note: Steps 1-6, and 8-9 can be done in the Input Table view, shown below, but the remaining steps
must be done in the Parameter Details view - Input.
Advanced tab
Step 15: Optionally, select the Advanced tab, as appropriate, for the new Input parameter.
If you have entered a value for the “group” Property in the Interface section on the Input tab, it will appear
in the Meta Data table automatically. (See Group.)
In case a desired attribute is not present in the defaults on the Input tab, you can add more Name - Value
pairs in the Meta Data table by clicking the “+” button. Type in the Name and Value into the table.
106
Creating an Input Parameter
Object tab
Step 16: Optionally, select the Object tab, as appropriate. It is only visible when an Input Parameter’s
type is Object or Point.
Message
Step 18: Type in the prompt message that the user sees when picking this parameter during template
execution.
Sub-filter
Step 19: If picking is to be restricted to a sub-type of the allowable pick type, enter the sub-type in the
Sub-filter box.
Multi-Object Picking
Step 21: Check the Multiple-Entity Picking box, as applicable, to specify the number of objects that may
be picked. Use the spin boxes to set the “Minimum entities required” and “Maximum entities required.”
It can be done in either the Parameter Details view or the Output Table view. The following
instructions are shown in the Parameter Details view, unless otherwise noted.
Step 1: When the Parameter Details view is selected, select the arrow next to the “+” and select Add
output.
When the Output Table view is selected you only need to click the“+” button.
An output parameter of type “String” is created and given a default name, such as “output1.” It is added
to the parameters in the table.
Identification
Step 2: Select the new output parameter in the table on the left side to view the details for the parameter.
Step 3: In the Identification section, enter a Label which is the display label that will appear in the
Execution summary report when the action is run.
Step 4: Enter the parameter’s Name. This will be the name used in the action’s Python code to refer to
this parameter.
Step 5: Enter the parameter’s Summary. This is a brief description of the parameter and becomes part
of the Tool Tip help that is displayed to users when selecting the action in Template Builder.
109
Creating an Output Parameter
Behavior
Step 6: In the Behavior section, check the “Save and Report” box if the output parameter is to be written
to the Execution summary report.
Definition
Step 7: In the Definition section, select the Type of parameter from the drop-down list.
Step 8: In Select “true” for the List attribute, if the output is a list of values or objects.
Step 9: If the Type is Object, Point, Managed Object, CAD Object, or Enterprise Object, these have sub-
types, therefore you should also select the Object type.
110
Creating an Output Parameter
Steps 1-8 can be done in the Output Table view. (Summary is shown as “Description” in this view.)
111
Parameter Interface
Parameter Interface
Interface choices allow you to provide a custom user interface for each Input parameter. When an action
is executed as part of a template, the Interface defined by the template author is presented to the user for
gathering input parameters.
The following sections briefly describe the Interfaces available for each parameter type. The user
interface is specified on the Data page of the Action editor. The Parameter Details view - Input must be
selected.
Selecting an Interface
Click on a Parameter in the table on the left side, then select an Interface for that parameter at the
bottom of the page. Once a user Interface is chosen, each interface has different Properties that may be
set. These properties are listed on the right side of Interface section.
Note that the List option is the same as found in the Definition section of the parameter details.
isReadOnly
Another common property, “isReadOnly”, is selected when the input selection cannot be edited, for
example a file name.
Group
The “group” property is used to identify a parameter as being part of a group or to create a tabbed
interface.
Use the following format: “parent:GroupName” where “parent” is the Name of the parent parameter, and
“GroupName” corresponds with a discrete value of the parent parameter. This is used when some input
parameters and their user interfaces depend on the choice made for another parameter (the parent
parameter). The parent parameter must have the Discrete constraint selected. (See Constraint in “Creating
an Input Parameter.”)
For example let’s say we have “type:RGB” as the value for the “group” property. In the following image,
selection of “RGB” for the parameter “type” results in a different user interface than when “Color” is
selected. The parameters R, G, and B are only shown when the parameter Type is set to “RGB.”
113
Parameter Interface
To group parameters under a tab, use the keyword: tab for the group property, in the following format:
“tab:Name” where the Name corresponds with a group of input parameters to be displayed in a tab
labelled “Name.” Use the same value of the group property for several parameters in order to collect
related parameters under the same tab. In the above example the two tabs “Named” and “Web” were
created in this way.
In another variation of using groups, the parent parameter can have its group property set to a tab. In the
example below, the parameter “Type” is using a Radio Group user interface and its group property is set
as: “tab:custom”
Other Properties are specific to the interface and are mentioned in the following sections for each
parameter type and user interface.
String Parameter
A string parameter is used when an alpha-numeric value is expected. It may be Unconstrained, or may
be constrained to Discrete values.
114
Parameter Interface
Several different User Interface choices are available for a string parameter. The Interfaces for an
Unconstrained String parameter are shown:
The choices are different if a Constraint is selected. Expand each type, below, for a description and
example of each user interface.
Hidden
Use if an interface is not visible to the user, such as when a default value is to be used during execution.
Line Edit
This is the default interface for an unconstrained String. A dialog box is presented to user with a text box
for entering the parameter value.
Properties that can be set for a Line Edit user interface include the typical List and IsReadOnly options.
Another property that can be set is alignment. This property defines the justification of the typed value
within the text box, with settings of AlignLeft, AlignHCenter, and AlignRight. For example the
AlignLeft and AlignRight settings are shown below:
Text Editor
115
Parameter Interface
Opens a larger text edit box for entering the string parameter. Used when a long string is expected.
Color Chooser
Opens a chart with color samples from which to select a color.
\
Symbol Chooser
116
Parameter Interface
Font Chooser
Presents a dialog box with available fonts, styles and sizes for formatting text.
File Chooser
Opens a file selection dialog box. In addition to the List and ReadOnly properties, there is also a Mode
(Open or Save) property and a Filter property. Use the filter to limit valid file extensions.
Folder Chooser
Opens a folder selection dialog box. Used to specify a storage location, for instance. Similar to File
Chooser.
Date Chooser
117
Parameter Interface
Opens a date chooser dialog. Used to select an input or output parameter that contains a date. Date may
be typed in, or scrolling arrows can be used to increase / decrease value for month, day, and year
separately.
Time Chooser
Opens a time chooser dialog. Used to select an input or output parameter that contains a time.
Drop List
This Interface is only available when Constraint is set to Discrete and is the default interface for discrete
constraint. The user clicks the down arrow to display a list of choices.
List
This Interface is only available when Constraint is set to Discrete. Valid Options are presented to the user
in a list.
Radio Group
118
Parameter Interface
This Interface is only available when Constraint is set to Discrete. Valid Options are presented to the user
in a group of option buttons.
Integer Parameter
An Integer parameter is used when a whole number value is expected. An integer parameter may be
Unconstrained, or may be constrained to Discrete values or a Range of values.
User Interface choices for an integer parameter are fewer than a string parameter. Expand each type,
below, for a description and example of each user interface.
Hidden
Use if interface is not visible to user, such as when default value is to be used during execution.
Line Edit
Default for an unconstrained Integer. A dialog box is presented to user with a text box for entering the
integer value.
Drop List
This user interface is only available when Constraint is set to Discrete, and is the default. Valid Options
are presented to the user in a drop-down list, as shown in String Parameter.
List
This user interface is only available when Constraint is set to Discrete. Valid Options are presented to
the user in a list, as shown in String Parameter.
Spinner
119
Parameter Interface
This user interface is only available when Constraint is set to Range. A spin box is presented to the user
with up and down arrows to increase or decrease the value. The user may also type in a value.
Properties for a Spinner user interface include the typical List option, and a Step property, which defines
the increment for the up/down arrows.
Slider
This user interface is only available when Constraint is set to Range. A slider appears with minimum
value at the left and maximum value on the right, corresponding to the upper and lower bounds specified
in the Constraint. The current value is shown to the right of the slider.
A Step property, which defines the increment for the slider tick marks can be specified.
Real Parameter
A real parameter may be Unconstrained, or may be constrained to Discrete values or a Range of values.
The Interface options for Real parameters are similar to those for integers.
Hidden
Select if interface is not visible to user, such as when default value is to be used during execution.
Line Edit
Default for real, unconstrained parameter. A dialog box is presented to user with a text box for entering
parameter. See String Parameter, above.
Unit Value
120
Parameter Interface
Use when the real parameter is associated with a particular unit, such as length, mass, time, etc. A dialog
box is presented to user with a text box for entering the parameter, and the appropriate unit (in the current
model units) is shown.
Set the unit type in the Property section, selecting from the list of available unit Types (Mass, Time,
Length, etc.). The specific unit shown depends on the current user units selected (in Tools, Options, Units
Manager.)
Measured Value
Allows you to measure a distance or angle from the model during execution. The input value is set equal
to the measurement.
Spinner / Slider
These user interfaces are only available when Constraint is set to Range. Same as described in Integer
Parameter, above.
Boolean Parameter
Since only two choices are possible (true or false), user interface choices are similar to other parameter
types with Discrete constraint.
Hidden
Use if the interface is not visible to user, such as when default value is to be used during execution.
Check Box
121
Parameter Interface
Default user interface for boolean type. True / False option is presented to the user in a check box, using
the label defined in parameter table.
Radio Group
True / False options are presented as option buttons.
Enumeration Parameter
When a parameter is assigned the type Enumeration, the Constraint is set to Discrete and cannot be
changed. Valid enumeration Options must then be specified.
User interface choices are as follows:
Hidden
Use if the Interface is not visible to user, such as when default value is to be used during execution.
Radio Group
Valid options are presented to the user in a group of option buttons, as described in String Parameter.
Object parameter
An object parameter is used when a model object, such as Part, Node, or Element is used as input or
output parameter. Object input parameters do not have a constraint option and can only be
Unconstrained. Two user interfaces are available for an object input parameter:
Hidden
Hidden user interface is selected when user selection of object(s) is not desired during execution, such as
when object is passed from a prior action.
122
Parameter Interface
Object Picker
The Object Picker user interface initiates a Pick dialog during template execution. Selected objects are
displayed in a Line Edit text box.
Properties of the Object Picker user interface include the typical List, Group, and isReadOnly options.
See Common Interface Properties.
Point Parameter
A parameter type of Point is a special type of Object, and has similar user interface options.
Hidden
Hidden user interface is selected when user selection of point(s) is not desired during execution, such as
when point is passed from a prior action.
Point Picker
Point Picker user interface is a limited version of the Object Picker. Properties of the Point Picker user
interface include the typical List, Group, and isReadOnly options.
Managed Object
A Managed Object parameter type is an object within a “managed” SimXpert file, that is stored in
SimManager.
The User Interface for a Managed Object is predefined and thus is not selectable. You only have the
option to select a Hidden interface.
Hidden
Hidden user interface is selected when user selection of the Managed Object(s) is not desired during
execution, such as when the object is passed from a prior action.
The Hidden interface include the typical List and Group Properties.
CAD Object
A CAD Object parameter type is a special object type that is limited to CAD geometry objects in
SimDesigner, CATIA, or Pro-E files.
The User Interface for a CAD Object is predefined and thus is not selectable. You only have the option
to select a Hidden interface. See Managed Object, above.
123
Parameter Interface
Enterprise Object
An Enterprise Object parameter type is a special object type that is limited to objects found in a
SimManager database.
The User Interface for an Enterprise Object is predefined and thus is not selectable. You only have the
option to select a Hidden interface. See Managed Object, above. To execute an action that has an
Enterprise Object input parameter, a SimManager connection is required.
124
Action editor - Advanced page
Meta Data
The Meta Data table allows you to change action options or add meta-data that is not included in the
default properties of an action. If any of the options on the Action Options area of the page are changed
to a non-default state, they will be shown in the Meta Data table. The table is displayed in alphabetical
order by meta data Name.
A list of pre-defined meta-data is accessed using the double-left arrow button. Select a Name from the
drop-down list to add it to the Meta Data table. You may need to enter a Value in the table.
• Author Information - add Author, Created date and Modified date to the table.
• Keep Expressions - Override parameter default to keep Expression strings
• Row Label - Identifies the Parameter name to be used as the row label in the Property table.
• Descriptive Label - adds a descriptive label to the Meta Data table.
125
Action editor - Advanced page
You can create additional Meta Data by clicking the “+” button, and populating the Name and Value
columns accordingly. To remove meta data, select a row in the table and click the “X” button.
Action Options
The Action Options area of the Advanced page lists several options, which are initially populated with
defaults. Changing any of the options to a non-default state will result in the option being listed in the
Meta Data table.
• Reset on Apply - Controls ability to re-use the action’s inputs or to reset to default values. (Note:
only for actions executed as a tool (on tool ribbon); when executed in a template, the template
default values are used.)
This option can be set at the individual parameter level if desired. (on Data page) It has three
possible values:
• Reset values to the original default values --The Action's parameters will be reset to the
default values when the Apply button is clicked and the Action's inputs will NOT be saved.
Group input parameters are not reset.
• Retain current input values - Keep current values when the Apply button is clicked. Once
the dialog box is closed, the values are not remembered and the defaults are restored.
• Remember input values for later use - Keep current values when the Apply button is clicked
AND reuse the same values later within the same session of the program. Note: Object and
Point input parameters are never stored for later use, except polymorphic object inputs that
currently have a numeric value.
• Macro Recording - specifies how to handle multiple sequential instances of an action during
macro recording:
• Unique instance for each execution - to keep sequential instances of this Action as separate
instances when recorded in a macro.
• Aggregate sequential executions into a single instance - combine sequential instances of
this Action to one when recorded in a macro.
• Recording Pick Gestures - specifies whether or not to record the view and screen location of
picks:
• Record Pick Gesture data in a macro - Select to record Gesture data for this action’s inputs
when recording a macro.
• Record object ids - Select to suppress recording of Gesture data and use the picked objects’
IDs instead. Requires valid IDs for successful playback
• List Variables - Specifies how list variables are to be handles.
• Use native python lists (default) - Select to use native Python lists as variables in the script
code implementation.
• Use SimXpert Object Lists - Select this option to use the SimXpert ObjectList class (e.g.,
NodeList, ElementList, etc.) for variables in the script code implementation. May provide
better performance for very large lists.
• Units (Python only) - Controls the use of system units or user units for dimensioned values:
• Use system units for dimensioned input values - Select this option to use the system (MKS)
unit system for dimensioned input values in the script code.
• Use current session units for dimensioned input values - Select this option to automatically
convert the dimensioned input values from system (MKS) unit system to the current session
unit system.
127
Action editor - Advanced page
Documentation
Displays the action’s Summary, which is populated based on Data page entries.
If the Summary is changed here on the Advanced page, the modified Summary will be shown on the Data
page as well. In addition, a Description box is available here to add details about the action.
128
Action editor - Layout page
The Layout page allows you to customize the appearance of the User Interface for each parameter. It also
provides for you to add documentation and meta-data to the action. It is organized into five sections:
Layout, Preview, Documentation, Meta Data, and Categories.
Layout
The Layout section allows you to specify features of the user interface.
Embedded - Check box to create the layout as part of the action (*.act) file instead of a separate file. Un-
check box to save as a *.ui file for further editing in Qt Designer or text editor, if desired.
Create - Click Create button to create a custom form for Template inputs. It is saved as a *.ui file for
further editing in Qt Designer or text editor, if desired.
Add... - Add a layout file to the list, using a file browse dialog box.
Remove - Select a layout from the list and click the Remove button to delete it from the list.
Preview - Select to Preview the saved layout. Close when finished with preview.
129
Action editor - Layout page
Edit... - Opens a text editor or other program associated with the *.ui file. Knowledge of the xml
formatting codes is needed.
Preview
This area of the Layout page shows how the contents of the action input dialog will appear to the user
upon execution.
130
Action editor - Code page
Entering Code
Knowledge of Python or RADE scripting is needed to create code. See Python Scripting Language and
RADE Scripting Language for details on each code and syntax.
Step 1: It is recommended to complete the Data page first, including Input and Output parameters. Then
select the Code tab at bottom of Action Properties dialog box.
Step 2: Click Update button to automatically add the input and output parameter statements to the script
editor window.
The auto-generated code in Python looks as follows, with parameters and other declarations at the top
and output parameter calls at the bottom:
# # CODE FENCE BEGIN: Declarations
import RIDL
RIDL.loadModule("rgen_ridl")
context = SX.ScriptDelegate.current()
if (not context):
SX.showErrorMsg("The script must be executed in a Process.")
raise "Error"
inputs = context.getInputs()
outputs = context.getOutputs()
NumBolts = int(inputs.getInt("NumBolts")) # () Number of Bolts
AttachLocs =
SX.ActionUtilities.getObject(inputs.getString("AttachLocs"), "")
AttStyle = inputs.getString("AttStyle") # () Style of Attachment
Mass = inputs.getDouble("Mass") # () Mass of accessory
CG_Loc =
SX.ActionUtilities.getObject(inputs.getString("CG_Loc"), "")
# # CODE FENCE END Declarations
Begin adding script code into the window. (See Using Script Editor.)
Step 4: Type or copy / paste the code (e.g. Python) into the Code page of the Action editor or the Script
Editor window, just after the line:
# # CODE FENCE END: Declarations
and before the statement:
# # CODE FENCE BEGIN: Outputs
Use the editing toolbars as needed: Cut / Copy / Paste, Un-do and Re-do. (Note: The script type cannot
be changed, as this was set when action was first created.)
Step 5: If using Script Editor, click the Save icon at upper left to save the code. Then close the Script
Editor window.
If Script Editor was not used, save the action by right-clicking on it in Model Browser and Save.
Testing an action
An Action must be tested as part of a template.
132
Action editor - Code page
Insert the action into a template and make any necessary connections. (See Creating a new template.)
Right-click on a template in Model Browser and select Test.
The Template Execution window is opened. See Running a Template for details.
133
Editing an existing Action
To open an existing action, look under Open... to locate the desired action. Recently used actions may
appear in the Open menu. Hovering the mouse over each icon will bring up the file name. Actions have
a file extension of *.act. If the action is not seen on the list, use the Browse... command to locate the
action file.
Script Actions
Editing is disabled for all the Core Actions that are packaged with SimXpert. Custom Actions (user-
written) may be edited. There are several ways to open a Custom Action for editing:
• Actions may be opened from the entry screen to Template Builder: Open, Browse... Actions
have a file extension of *.act. Navigate to the file and Open.
• If a template containing an instance of the Action is already open, double-clicking on any
instance of the Action in a template will open the Properties dialog box for the script action.
From there, click Edit... to open the Action editor.
• Use the File, Open command from the SimXpert menu to locate the Action. A file browse
dialog will assist in navigating to the file location. Actions have a file extension of *.act. Select
the file and Open.
134
Editing an existing Action
• Click the Controls toolbox and select Browse... tool. Actions have a file extension of *.act.
Navigate to the file and Open.
• Click on an action in the Actions folder of the Model Browser tree to open the Action editor
(available only if action has been opened in the current session.)
The Action Editor opens up in the graphics window. There are three tabs across the bottom. Make the
desired changes to Data, Layout, or Code pages. Use the procedure described in the Action editor section
to modify the action. Make sure to Save the action when complete. (from Data tab)
Caution: Note that if any script action is modified, all instances of the action will also receive the
modifications. Make sure this is intended before modifying any script actions.
A copy of a script action can be made by opening it for editing then giving it a different Name. To avoid
confusion, it should be given a new Label also. Click Ok to save under the new name.
Details on editing script actions are found in the Action editor section of this User’s Guide.
135
Converting a script to an action
Step 4: Another line appears in the Property table for scriptFile. Click the file navigation button on the
right side of the Value column, and navigate to the existing file. Valid file types are *.py, *.rdl,
and *.xml
Step 5: Go to Publish page and Save.
Step 8: Delete extra parameter initializing statements, if existing. Delete OH / VH sections, which have
been replaced by User Interface definitions.
137
Using Script Editor
1 2
3
138
Using Script Editor
Right-click on an object or region of the Script Editor window to show a context menu. The menu will
vary according to the object selected.
Script edit window context menu:
In addition, the Open Directory Tree command opens the Directory Tree view at the left side of the
window.
Edit menu
The Edit menu has Cut / Copy / Paste, as well as Un-do and Re-do commands for editing script text in
the script edit window. You can increase or decrease the font size and turn on / off the line numbers. You
can also create and find Bookmarks in the script.
For RADE scripts only, there is an Inputs and Outputs... command on the Edit menu to create
parameters.
140
Using Script Editor
Select Inputs or Outputs tab, then click New to create a new parameter.
Specify the Input name, Data Type, Object Type (if applicable), and Description. (Note that once the
Inputs and Outputs command has been used to create parameters, it is assumed that the script is an action
and can then only be executed as part of a template.)
Debug menu
The Python Debugger commands can be accessed from the Debug menu in Script Editor.
Toolbars
The toolbars contain icons for quick access to script editing tools. Move the mouse over each icon to get
a popup description of each.
141
Using Script Editor
Toolbars and the Debug Window may be hidden / shown by right-clicking in the toolbar area to bring up
the toolbar context menu and checking the toolbars you wish to show:
The “Tools” toolbar has the most common commands from the File and Edit menus, and an additional
icon to Run a script.
The “Debug Tools” toolbar contains several commands related to the Python debugger tool. These are
discussed in Using the Python Debugger.
The “Language” toolbar consists of a drop-down list to select the scripting language. This is done for new
files before adding script.
142
Using Script Editor
The menus (File, Edit, and Debug) and the directory tree are not present. File management capabilities
are accessed from the Action Editor. Debug windows are not shown in this limited form of the script
editor, as it is intended only as a code editing tool for the current action. Debugging of an action is
accessed in the Template Execution window.
Tools for editing text, such as cut, copy, paste, undo, and redo are available from this window.
143
Using the Python Debugger
The Debugger and Script Editor can also be invoked from the Template Execution window for Custom
Actions. Use the “Step Into” control button to activate the Debugger. See Template Execution Template
execution toolbar, in this guide.
Debug commands
Use the Debug menu or the Toolbars in Script Editor to access the following debugger commands.
Initially only the “Start Debugging” and “Toggle Breakpoint” commands are enabled. Once debugging
is started the rest of the commands become available:
- Start Debugging - Only visible when the debugger is not running. Start executing the script in
debug mode. The execution will continue to the end or until it encounters any breakpoint.
- Stop Debugging - Only visible when the debugger is running. Stop the debugging and further
execution.
- Restart - Stop the debugging and restart debugging the same script from the beginning.
- Continue - Continue running the script until the end or it encounters any breakpoint.
- Step Over - Step over the function. Start debugging the script from beginning if not already in
debug mode.
- Step In - Step into the function. You will be able to view and run the function in debug mode,
even if contained in a different file or module.
- Step Out - Step out of the function. Returns to the execution point of the file in script editor.
144
Using the Python Debugger
- Run To Cursor - It applies a temporary breakpoint at the cursor position and continues the
execution until it encounters it or any other breakpoint.
- Jump To Cursor - Set the execution point at the cursor position. It must be only in current stack
frame.
When the debugger is running you can click on any variable or function and navigate its attributes in a
menu tree. Upon selecting an attribute, it will be printed in the Output tab of the Debug window.
The values of a variable can be read and set by hovering the mouse over the variable in the editor.
Reading a specific variable can be exactly captured by manually selecting it in the editor.
Caution:
Note that the manually selected text is executed to return the results which, in some cases, might change
the state of the debugged program (e.g., through function call).
The attributes of the variable (dir()) is available in the pop-up menu which, after clicking, gives its value
in the Output tab of Debug windows. The breakpoint and execution point information will come if the
mouse pointer is beyond the right-most end of the available text in editor.
The current script must be saved before debugging. In the debug mode the editor will be read-only.
Debug windows
The Debug window, when activated, is shown at the bottom of the Script Editor window. If hidden, use
the toolbar context menu to activate it: check Debug Windows, as discussed in Toolbars.
There are four tabs that can be shown or hidden by selecting Debug menu > Debug Windows, then
checking /un-checking the windows as desired.
Any of the tabs can be docked as a separate window. Right-click on the tab to open a context menu and
select Dock. Note: you can also show or hide windows from this menu.
In the example below the Watch window is docked. You can detach and move any docked tabs or the
main Debug window using click-and-drag on the left side bar:
146
Using the Python Debugger
Output
All the outputs are redirected to this window including stdout, stderr, debugger output and errors.
The filters can be applied to enable/disable these outputs. Right-click in the Debug window to access the
context menu of this window. Select Output Filter, then check the desired output types.
You can also Select All the text from the window and Copy it. Then you can paste it into any application
for saving.
Breakpoint
Lists all the added breakpoints from different files. It can be navigated by double-clicking on it. A
particular breakpoint can be disabled by deselecting its active check box.
147
Using the Python Debugger
Breakpoints can be removed by selecting them (using Ctrl or Shift key for multiple breakpoint selection),
then right-click on the selection, and Delete Breakpoint.
Stack
It shows the stackframes. The current stackframe can be set up/down by double-clicking on it. Each
stackfame's associated global and local variable are shown in the child node of the tree view.
Watch
Variables can be watched by typing their names into the Name column. Their values will update
dynamically while debugging. Their values can also be set by changing the corresponding Value column.
Watches can be removed by selecting them (using Ctrl or Shift key for multiple watch selection), then
right-click on the selection, and Delete Watch.
148
Using the Python Debugger
Run button
At the bottom of the Debug window you can enter one or more native python commands then click the
Run button. Any python command can be executed in the current context. The result, if any, is printed to
the Output tab.
The multiple commands can be separated by a semi-colon “;”or through a multi-line editor. (Multi-line
editing can be toggled on / off by clicking the button “...” to the right of the Run text box.)
The Run button is also used for other purposes by giving prefixes as below.
“?” or “HELP” for reading the debugger help.
“=” or “EVAL:” for evaluating any expression.
“!” or “DEBUG:” for executing debug commands similar to pdb debugger commands set.
The history of the commands can be accessed using up/down keys. For an empty command, the
previously executed command will be run if available.
149
Python (and RADE) Scripting Tools
Macro Record
The Macro Record feature can be used to capture the code associated with the SimXpert commands
executed during Macro Recording. Macro Record always creates a *.proc (template) file, which can then
be edited in Template Builder workspace. If the Format is selected as “Python” it also saves the
associated Python script. This is an experimental capability. Set the environment variable:
‘SIMX_PYTHON_EXPERIMENTAL’ to ‘activate’. Please review the auto-generated comments at the
top of the recorded script for limitations and other information on using the script.
See Recording a Macro in the Templates section of this User Guide for details.
SimXpert API
Script /action authors have access to most of SimXpert’s Application Programming Interface (API). See
the SimXpert API Documentation for the complete library of available SimXpert classes and functions.
150
Python (and RADE) Scripting Tools
(Go to Help > SimTemplate Help > Template Reference. Select either Structures/ Thermal / Crash
or Motion workspace.)
Actions
Most GUI commands and tools have corresponding Actions, which are available from the Actions
toolbox in Template Builder workspace. For a novice template author, using the Core Actions is best,
before attempting to write your own scripts. See Inserting objects in a template for details on using Core
Actions.
API calls
In addition to the actions provided, a large library of objects and functions are available in from
SimXpert’s API. These range from high-level complex tasks to simple functions, which can be invoked
in a Python (or RADE) script. The availability of this library minimizes the need for the action author to
write extensive code.
• Using the Macros dialog box: In SimXpert a saved script can be invoked from the Tools menu,
Macro, then Macros. (or by using the Ctrl-F8 button) This opens a selection dialog box to
locate the saved script file: Recorded macro (*.proc), RADE (*.rdl) or Python (*.py) script).
g
• Scripts that are contained within Actions can only be run as part of a template. Place the action
into a template. It may be a temporary template for testing purposes. Save. Open the Template
Execution window. Click on the desired action containing the script. Click the Run Selection
Action button.
• To invoke a RADE script using a command line during a SimXpert session, simply type the
following command in the Expression or ID’s text box, located on the Pick menu:
process_file full-path-name
• To invoke a RADE script during start-up is possible, but is for advanced users, as it requires an
understanding of SimXpert’s directory structure and environment variables. For example, you
could modify the startup shortcut by adding a script to it:
C:\MSC.Software\SimXpert\2010\WINNT\bin\simxpert32.bat -ridl
C:\my_script.rdl
152
Python Scripting Language
What is Python?
Python is a popular object-oriented programming language. It is a public-domain language and as such,
manuals and examples are readily available. The Python interpreter and standard library are freely
available in source or binary form for all major platforms from the Python Web site: www.python.org.
The web site should also be consulted for the most recent Python language reference material.
Python is a high-level interpreted language, and thus no compilation and linking is necessary. It has high-
level data types built in, such as flexible arrays and dictionaries. Python allows you to split your program
into modules that can be reused in other Python programs. It comes with a large collection of standard
modules. Python is extensible, making it possible to link Python scripts to the SimXpert API.
Python code statements to be executed are typically contained inside functions. A function may require
input values or objects. After a function has been called upon to be executed, it returns outputs to the
caller.
Function Declaration
A function declaration defines a function and is of the form:
def functname(argument1, argument2):
python code statement
another code statement
Contained within the parenthesis are the arguments, or parameters for the function, and can be either
inputs or outputs. The suite of statements following the colon must be indented the same amount.
Optionally, a series of short statements on one line may be separated by a semi-colon.
Class Definition
Data with similar attributes can be grouped into a “class.” A class is a data type which can contain
“members” (attributes) and “methods” (member functions). A base class may contain other derived
153
Python Scripting Language
classes, which inherit all the properties of the base class. A derived class can have additional unique
properties of its own.
In the following example, a new derived class, Class_xyz is created. It inherits the attributes of the
base class, BaseClassName.
The class declaration is followed by an indented block that includes definition of the variables x and
y, then the member function, func_do_something. Additional member functions can follow (as in
func2, shown).
Data Types
Some of the Python Data Types are as follows:
Number
Integer (plain, long and booleans)
Floating point (double-precision)
Complex
Sequence
Immutable types:
string - Characters
unicode - Unicode code units
tuples - comma-separated lists of items
Mutable types:
List - comma-separated list of expressions in square brackets. See also: Lists, in Python
Syntax Details.
Mappings
154
Python Scripting Language
dictionary - an unordered set of key: value pairs, with each key being unique
Set - an unordered grouping of immutable values, without duplicates
See www.python.org for more discussion of data types.
Variables
Variables do not have to be declared. The equal sign (=) is used to assign a value to a variable. The value
may contain an arithmetic operation.
width = 20
height = 5*9
A value can be assigned to several variables simultaneously:
x = y = z = 0 # Zero x, y and z
a, b = 0, 1 #a=0, b=1
Commenting
Python comments begin with a hash character, “#” which may appear at the start of a line or after a code
statement.
Reserved Keywords
The reserved keywords cannot be used as names for variables, functions, or classes.
155
Python Syntax Details
Code Blocks
Code blocks are defined by using the same indentation for each line in the block of code. The tab
character is usually interpreted as a fixed number of space characters. It is advisable not to mix space
characters and tabs when indenting code.
Control Blocks
See www.python.org for details on Python control blocks.
Memory Management
Memory management in Python is automatic. There is no need to manually allocate and free memory.
Numeric Operators
= Assignment
+ Addition
- Subtraction
* Multiplication
/ Division
// Floored Division
% Remainder (x % y gives remainder of x/y)
** Power (x**y is x to the power of y)
pow(x, y) Power (x to the power of y)
More at www.python.org...
Logical Operators
156
Python Syntax Details
Unary Operators
- Reverse sign / negate (numeric)
+ Unchanged value (numeric)
~ Bitwise inversion (Integers only)
Lists
A list is a compound data type used to group values together. The list items are contained in square
brackets, comma-separated. List items need not all have the same type.
The expressions in the list are assigned consecutive numerical indices, starting with 0. For example:
a = ['red', 'blue', 100, 1234]
#results in:
#a[0]=red, a[1]=blue, a[2]=100, a[3]=1234
Notes on lists:
1. Native Python lists --
Starting with version R3.1, all list inputs and outputs for Python-implemented Script Actions are
by default native python lists. If CLex-based lists are desired, this must be specified in the action.
See Action Editor.
If you have existing Python-implemented actions that were created in R3.0 or prior, please note
the following:
• When you update the code of an existing Action, the input & output parameter declarations
for list parameters are changed to the Python list format. (This refers to the use of Update
button on the Code page of Action editor.)
• The user code will need to be updated to use the native python list API rather than the CLex-
API. A warning message will be shown in the message window to alert you to this situation.
157
Python Syntax Details
• If you wish to suppress this updating and retain the “CLex” list objects (e.g., NodeList,
StringList, etc.) please add the “NativeLists=false” meta tag to your Action. (Layout page)
This will cause it to retain / revert to the CLex-based lists.
• In connection with this, a new Python module has been added: SimXUtil.py. This has some
API's that will make it easy to convert between a native Python list and a CLex-based list.
• RADE-implemented Script Actions are not affected by this change.
• User code that declares lists outside of the “CODE FENCE” declarations area is not affected.
(In other words, lists that were created in the script without the use of + button on Parameters
section of Data page in Action editor.)
2. Python lists vs. SimXpert API “ObjectLists”
One potential area of confusion is the distinction between native python lists and those created
using a constructor of one of the XXXList classes in the SimXpert API. (NodeList, for example)
An instance of a XXXList object created using a constructor in the SimXpert XXXList class is
not recognized by the Python interpreter as a List. If a “list” object is created in this way, then you
have the choice to:
• Convert it to a Python list. Then you can use all the standard list functions and operations in
Python. An example code snippet to make a Python list from a CLex XXXList is as follows:
python_list_out=[]
for n in range( int(myXXXList.length() ) ):
python_list_out.append(myXXXList.at(n))
• Use the member functions of the API class to operate on the list, rather than Python list
operations. (These include functions such as “at, insert, remove, index,” etc.) Refer to the
Template Reference in the SimTemplate help menu. Some additional conversion utilities are
available in the Python module SimXUtil.py
3. List Copying --
Copying of a list cannot be done by simply assigning variables, as in
py_list_out = py_ list_in;
It is necessary to loop through the list and copy each item in the list, as shown in the example
below:
import RIDL
py_list_in=['red', 'blue', 100, 1234]
py_list_out=[]
# Do not simply assign list variables...
# py_list_out = py_ list_in <-- invalid
The above example shows copying of one native python list to another. The following shows the
copying of a SimXpert list class to a native python list. (Note: You can use the function
listFromCLexList in the SimXUtil module to accomplish the same thing.)
# Do not simply assign list variables...
# outstrlist = strlist;
# outobjlist = objlist;
Built-in Functions
There are hundreds of built-in functions to perform mathematical functions, string operations, list
operations, file handling, error handling, etc. There are many more functions contained in standard
modules, which can easily be accessed using the import command to import a module and all of its
member functions.
Many custom modules are available from the Python user community. See www.python.org for
information on built-in functions, standard modules, and custom modules.
159
Python Tutorials
Python Tutorials
A few examples are provided to demonstrate how to write Python scripts and execute them in SimXpert.
These scripts are similar to the RADE scripts provided in RADE Tutorials. They demonstrate how to call
the various functions in the SimXpert API that are needed to perform many tasks in SimXpert. (for
example, sending a string to the Message window). These tutorials cover the following:
• Sending a string to the SimXpert Message window.
• Demonstration of Object Oriented Programming concepts
• List handling
• Creation/Modification/Deletion of entities (Nodes & Elements)
• GUI (menus, spreadsheets, etc.)
• Entity Picking
• Enquiring the SimXpert database (e.g. give me all warped elements)
• Vector usage
• Nearest neighbors (find nearest entity to location)
• File IO for parsing files
• Geometry creation
• Projection of a location on a curve
• Advanced Picking
• Create a new script action to query a model for the node count, and use it in a template.
To execute the scripts provided, open the Script Editor in the SimXpert Structures workspace. (See
Using Script Editor. Make sure Python is selected from the drop-down list.
The script files are located in <SimXpert Installation>/help/PartFiles/scripts. Or you can cut and paste
from the tutorials into the Script Editor window. Also check that any indentations shown are present in
Script Editor. These are an important aspect of the formatting.
Tutorial 17 is intended to be performed in the Template Builder workspace.
160
Python Tutorials
##
# Legendary HelloWorld program
##
# ShowMsg is a function in SimX API
# note it is preceded by SX.
SX.ShowMsg("Hello World", "green")
SX.ShowMsg("Hello World", "red")
SX.ShowMsg("Hello World", "blue")
Step 2: Click the Run icon. You should see the message “Code Executed Successfully” at the bottom
of the Script Editor window.
Step 3: Check the SimXpert Messages window. You should see “Hello World” in three different colors.
Step 4: To save a copy of the file to your own directory, click the File Save icon in the Script Editor
window.
import RIDL
#
# create a new class
class CMessage:
# attributes of the class
# These variables will have the same value in all instances
# of the CMessage class:
161
Python Tutorials
obj2.show("violet")
# finally execute the function Demonstrate_OOP
Demonstrate_OOP()
Step 2: Click the Run icon. You should see some messages print to the window as the various instances
of the class are created and functions are executed.
Step 3: To save a copy of the file to your own directory, click the File Save icon in the Script Editor
window.
def ListBasics():
i=0;
# instantiate a SimXpert list object.
# Below is a integer list (IntList).
# Similarly you can have ElementList, NodeList,
# and many more XXXList
#
list = SX.IntList();
#
# insert some items in the list
list.insert(0)
list.insert(3)
list.insert(5)
list.insert(10)
# loop through the list
for i in range(list.length()):
SX.ShowMsg("IntList["+ str(i)+"]= "+ str(int(list.at(i))))
# create a Python list of mixed data types
table = []
table.insert(0,"MSC");
table.insert(1,"SimXpert");
163
Python Tutorials
table.insert(3,float(22.0/7.0));
for i in range(len(table)):
# This prints to the console window
print table[i]
# This prints to the Messages region in SimXpert
SX.ShowMsg("What is in table is: "+str(table),'blue')
# with python list, you can print the whole list as a string
# finally execute the function ListBasics
ListBasics();
Step 2: Run the script by clicking the Run icon in the Script Editor window. You should see the values
of the IntList object and the native python list printed to the Messages region of SimXpert. If
you have the console window open, the list values are printed there also.
Step 3: To save a copy of the file to your own directory, click the File Save icon in the Script Editor
window.
Tip: Note on copying lists: Copying of a list cannot be done by simply assigning variables, as in:
py_list_out = py_ list_in;
It is necessary to loop through the list and copy each item in the list, as discussed in Python Syntax
Details.
Step 2: Check the path in the “action= ...” statement near the bottom, to be sure it is pointing to a valid
action. The path to the action is relative to <SimX Installation>/WINNT/plugins. You can
change it to point to one of your own actions, if desired, using relative or absolute path.
Step 3: Run the script by clicking the Run icon in the Script Editor window.
Step 4: After running the script, check the SimXpert menu bar for My Meny Py, then execute the Show
Msg command from the menu. You should see “My First Button” in the Messages region of
SimXpert.
Size = 10.0
GridsX=5
GridsY=5
##
SX.ShowMsg("Node spacing is " + str(Size))
SX.ShowMsg("Number of nodes in x-direction: " + str(GridsX))
SX.ShowMsg("Number of nodes in y-direction: " + str(GridsY))
Step 3: Run the script by clicking the Run icon in the Script Editor window. It will create a grid pattern
of nodes and print some information to the SimXpert Messages region.
nodes = None;
oh_name = None;
oh = None;
oh_title = None;
oh_msg = None;
if (not oh_name):
oh_name = "nodesOH";
if (not oh_msg):
oh_msg = "Pick Nodes";
if (not oh_title):
oh_title = "Pick Nodes";
# Using the Object Helper for picking
# This may become obsolete in future releases
oh = SX.CLexObjectHelper(oh_name);
oh.setPickTitle(oh_title);
oh.setPickMsg(oh_msg);
oh.insertPickType("NODE");
oh.setMinMaxPick(1,0);
oh.ForceContiguous = 0;
oh.PickBoundary = 0;
#clear picked objects if any
oh.clearPickedObjects();
# setup function displays the picking dialog after defining
# its parameters
if(not oh.setup()):
SX.ShowErrorMsg("Setup of input helper failed");
# gets the nodes that were picked by user
nodes = oh.getNodeList();
if(nodes.isEmpty()):
SX.ShowMsg("No nodes were picked")
return;
SX.ShowMsg("Nodes selected:")
for i in range(int(nodes.length())):
# here is how you get the node ID
id = nodes.at(int(i)).getAppId()
# prints the node ID to the console window
print str(int(id))
SX.ShowMsg(str(int(id)))
# create a new instance of ElementList
elements = SX.ElementList();
# gets the associated elements from the picked nodes
# and puts them in the new ElementList
SX.getElementsFromNodeList(nodes, elements);
# TODO - check delete call
# SIMX entity deletion
for i in range(int(elements.length())):
SX.deleteObject(elements.at(i).__cast__("CLexObject"))
for i in range(int(nodes.length())):
SX.deleteObject(nodes.at(i).__cast__("CLexObject"))
SX.ShowMsg("Attached elements deleted")
#update the canvas
SX.drawAllCanvases();
# finally execute the function DeleteElements
DeleteElements()
167
Python Tutorials
Step 3: Run the script by clicking the Run icon in the Script Editor window. You will have to pick some
nodes and confirm the selection. The elements attached to the picked nodes will be deleted.
Step 3: Run the script by clicking the Run icon in the Script Editor window. It should mesh all the
surfaces.
import RIDL
RIDL.loadModule("rgen_ridl");
RIDL.loadModule("mesh_ridl");
RIDL.loadModule("rader_ridl")
RIDL.loadModule("gui")
def Enquiry():
# Use CLexSofyEnv class to get model information
model = SX.CLexSofyEnv.getCurrentModel();
# Create an instance of ElementList. (It is empty now)
shells = SX.ElementList();
# Put all the shell elements into "shells"
model.getElements(shells, SX.__CLEXELEMENT, SX.SHELL, "", True,
True);
# create an instance of CLexString
warp_str = SX.CLexString();
# gets string data by prompting the user
SX.GetString("Enter Max. Warpage",warp_str);
# cancels if the string is blank
if (warp_str.data() == "" or warp_str.data() == "CANCEL"):
return;
# prints the entered value to the Message window
SX.ShowMsg("Max warpage entered: " + warp_str.data(),"Black")
SX.ShowMsg("All elements above this are highlighted","Blue")
# converts the string to real
maxwarp = float(warp_str.data());
len=shells.length();
# loops through all shell elements
# checks the warpage and compares against user inputted max value
# highlights the element if it exceeds the specified warp angle
for i in range(int(len)):
elem = shells.at(int(i))
if(float(elem.__cast__("CLexShellElement").warpage()) > maxwarp):
SX.HighlightEntity(elem);
Enquiry();
Step 3: Run the script by clicking the Run icon in the Script Editor window.
Step 4: In the dialog box, enter a value for warpage to check. All elements with warpage above this
value will be highlighted in the graphics window.
Step 5: You can clear the highlights using View > Clear Highlights from the SimXpert menu.
import RIDL
master_list=['dog','35.','woof','cat','9.','meow','bird','.3','chirp'
,'horse']
169
Python Tutorials
nCols = 3
nRows = len(master_list)/nCols+2
ss=SX.CLexSpreadSheet("Animal Data")
ss.setNumRows(nRows)
ss.setNumColumns(nCols)
ss.addTopLabel("title")
ss.setTopLabel("title","My Own Spreadsheet")
ss.setColumnLabels(3,["Animal","Avg Weight (lbs)","Call"])
#ss.setRowLabels(4, [ "Name", "Thickness", "Demo Combo", "Push
Button" ] );
ss.setVisibleRows(10)
ss.setColumnStretchable(0,True)
ss.setColumnStretchable(1,True)
ss.setColumnStretchable(2,True)
#ss.setSorting(0)
ss.createGraphics()
list_index=0
# force 3 columns of data
cchk=int(len(master_list)/3)*3
if len(master_list)>cchk:
for nblank in range(cchk+3-int(len(master_list))):
master_list.append('BLANK')
# nested loop to set the rows and columns of data from master_list
for n in range(nRows-1):
for j in range(nCols):
SX.ShowMsg('what is n: '+str(n))
SX.ShowMsg('what is j: '+str(j))
#SX.ShowMsg('what is row_num: '+str(row_num))
#SX.ShowMsg('what is col_num: '+str(col_num))
SX.ShowMsg('what is list_index: '+str(list_index))
SX.ShowMsg('what is value: '+str(master_list[list_index]))
# Fill cells
ss.setCell(n,j,master_list[list_index])
#col_num += 1
list_index += 1
ss.show()
# Here we are setting the cell contents directly.
# Set a breakpoint here if using debugger:
ss.setCell(3,1,'800.')
ss.setCell(3,2,'nay')
# Sorts by the first column, in ascending order,
# keeping row data together
ss.sortColumn(0,1,1)
Step 2: Set a breakpoint in the file at the line (near the bottom):
ss.setCell(3,1,’800.’)
as indicated in the script’s comments. This is done by placing the cursor at the location and
pressing F9 or click the Toggle Breakpoint icon in Script Editor.
Step 3: Start the debugger by clicking the Start Debugging button. It executes to the point where the
spreadsheet is displayed.
170
Python Tutorials
Step 4: Use the Step Over button to execute each remaining line of code, watching as the spreadsheet
changes. The yellow (or orange) highlight indicates the current execution point. See Using the
Python Debugger for more information.
Step 5: Click Exit in the Spreadsheet to close it.
import RIDL
# define a function that creates temp graphics objects
def CreateTempGraphics_CB():
# Create a temporary line
lineGraphics = SX.CLexLineGraphicsObject.new(
0, 0, 0, 0.002, 0.002, 0.002);
# Create an axis
axisGraphics = SX.CLexArrowGraphicsObject.new(
0, 0, 0, 0, 0, 1, 0.001);
173
Python Tutorials
Step 3: Run the script by clicking the Run icon in the Script Editor window.
Step 4: The line, axis, and text objects will be displayed temporarily. These objects can be cleared using
View > Clear Highlights.
import SCA
import types
import RIDL
RIDL.loadModule("rader_ridl")
RIDL.loadModule("charting_ridl")
workspace = SX.getGuiHandle().getWorkspace()
chartTitle = chart.getTitle ()
chartSubtitle = chart.getSubtitle ()
chartBorderColor = chart.getBorderColor ()
chartLegend = chart.getLegend ()
chartDataAxis = chart.getDataAxis ()
chartLabelAxis = chart.getLabelAxis ()
#
chart.setBorderVisibility (True)
chart.setBorderLineStyle (3) # s/b enum
chart.setBorderLineWeight (2)
chart.setDisplayValues (False)
if chart:
#====== create first data series ================================
barSet1 = chart.createBarSet ()
if barSet1:
barSet1.setLegendText ('Subcase 1')
data1 = barSet1.getData ()
if data1:
dList1 = SX.DoubleList.new ()
for v in DataSet1:
dList1.insert (v)
data1.setValues (dList1)
#======= create 2nd data series ================================
barSet2 = chart.createBarSet ()
if barSet2:
barSet2.setLegendText ('Subcase 2')
data2 = barSet2.getData ()
if data2:
dList2 = SX.DoubleList.new ()
for v in DataSet2:
dList2.insert (v)
data2.setValues (dList2)
#====== set title===============================================
if chartTitle:
chartTitle.setVisibility (True)
# set title text
chartTitle.setText ('Displacements')
chartTitleFont = chartTitle.getFont ()
# set title size
chartTitle.setPointSize(16)
chartTitle.setAlignment (5) #mcs s/b enum
chartTitleColor = chartTitle.getColor ()
if chartTitleColor:
# set chart title to magenta
chartTitleColor.setRGB (255, 0, 255)
#==== set sub-title =======================================
if chartSubtitle:
chartSubtitle.setVisibility (True)
chartSubtitle.setText ('by Subcase')
chartSubtitleFont = chartSubtitle.getFont ()
chartSubtitle.setAlignment (5) #mcs s/b enum
chartSubtitleColor = chartSubtitle.getColor ()
if chartSubtitleColor:
175
Python Tutorials
dAxisLabelsColor.setRGB (0,80,0)
#==== set label axis ========================================
if chartLabelAxis:
# set size of labels
chartLabelAxis.setLabelsPointSize (12)
color = chartLabelAxis.getColor ()
if color:
# set label-axis labels to purple
color.setRGB (128, 0, 128)
#CLexChartFont* getLabelsFont ()
lAxisTitle = chartLabelAxis.getTitle ()
if lAxisTitle:
lAxisTitle.setText ("Label Axis")
color = chartLabelAxis.getTicColor ()
if color:
color.setRGB (0, 0, 255)
chartLabelAxis.setTicLineStyle (4) # s/b enum
chartLabelAxis.setTicLineWeight (3)
chartLabelAxis.setPrimaryGridVisibility (True)
color = chartLabelAxis.getPrimaryGridColor ()
if color:
color.setRGB (0, 0, 255)
chartLabelAxis.setPrimaryGridLineStyle (3) # s/b enum
chartLabelAxis.setPrimaryGridLineWeight (3)
color = chartLabelAxis.getSecondaryGridColor ()
if color:
color.setRGB (0, 0, 255)
chartLabelAxis.setSecondaryGridVisibility (True)
chartLabelAxis.setSecondaryGridLineStyle (4) # s/b enum
chartLabelAxis.setSecondaryGridLineWeight (3)
color = chartLabelAxis.getLabelsColor ();
if color:
color.setRGB (0, 0, 255)
#chartLabelAxis.setPlacement (const ChtAx2DPlacement placement)
j=0
for l in range (len(DataSet1)):
j=l+1
# loop to set label text
chartLabelAxis.setLabel (l, 0, 'Location %0d' % j)
#=== display the chart =========================================
chart.showIt(True)
chart.refresh ()
Step 3: Run the script by clicking the Run icon in the Script Editor window.
Step 4: The script will produce a bar chart like this:
177
Python Tutorials
In a similar way, you can also create other chart types, such as X-Y plots, polar charts, scatter plots, and
fringed bar charts.
def CurveExample():
curves = None;
oh_name = None;
oh = None;
179
Python Tutorials
oh_title = None;
oh_msg = None;
if (not oh_name): oh_name = "curvesOH";
if (not oh_msg): oh_msg = "Pick curves...";
if (not oh_title): oh_title = "Pick curves";
oh = SX.CLexObjectHelper(oh_name);
oh.setPickTitle(oh_title);
oh.setPickMsg(oh_msg);
oh.insertPickType("CURVE");
oh.setMinMaxPick(1,0);
oh.ForceContiguous = 0;
oh.PickBoundary = 0;
#clear picked objects if any
oh.clearPickedObjects();
if(not oh.setup()):
SX.ShowErrorMsg("Setup of input helper -- failed");
curves = oh.getCurveList();
if(curves.isEmpty()):
return;
curve = curves.at(0);
SX.drawAllCanvases();
CurveExample();
Step 3: Run the script by clicking the Run icon in the Script Editor window. You will be prompted to
pick curve(s). Only the first picked curve is used, the rest are ignored.
Step 4: Upon confirming your selection, a node is created and a temporary arrow is highlighted to mark
the tangent at that location. You can clear the arrow by selecting View > Clear Highlights from
the menu.
180
Python Tutorials
i=0
len = pp.length();
for i in range (len):
elem = pp[i];
SX.cast(elem, "CLexElement");
elems.insert(elem);
SX.CLexPickDialog.resetPickLists();
# Get connected elements to these elements & add them to the pick
elems = SX.ElementList.new();
#SX.mortal(elems);
nodes = SX.NodeList.new();
#SX.mortal(nodes);
print("----", ttype(pp));
cast(pp, "ElementList");
getNodesFromElementList(pp, nodes);
getElementsFromNodeList(nodes, elems);
def ComplexPicking_CB():
SX.CLexPickDialog.reset();
# History initialization
#CLexPickDialog:TurnPickHistoryOn();
SX.CLexPickDialog.setPickTitle("Delete Elements");
#SX.CLexPickDialog.insertPickItem("__PICK_NODES");
__PICK_NODES=1
p = SX.CLexPickType.new(__PICK_NODES, "Nodes");
SX.CLexPickDialog.insertPickItem(p);
# setMultiPickStyle
SX.CLexPickDialog.setSinglePickStyle();
SX.CLexPickDialog.setProcessingFunction("DelElemsProcessFunc");
SX.CLexPickDialog.setDoneFunction("DelElemsDoneFunc");
182
Python Tutorials
Step 3: Run the script by clicking the Run icon in the Script Editor window.
Step 4: You will be prompted to pick a node whose connected elements will be deleted. Select several
nodes, then confirm the selection with Done or middle mouse click. The highlighted elements
are then deleted.
Step 5: Compare this code to that in Python Tutorial 6. Both scripts perform essentially the same action
but this one has many more settings to control the picking. It also immediately highlights the
elements that are connected to the picked nodes during picking.
If you want to test a script to see how fast it runs, insert the following Python code. Place the top section
above your code, and the bottom section after your code. It will print the start, finish, and elapsed times
to the console window. It also shows you how to get the current date and time:
# How to check the time it takes for your code
import time
import decimal
t1 = time.ctime();
s = time.clock();
#
#insert your code here
#
e = time.clock();
t = e-s;
print "Time Taken = "
print "Start s = " + str(s)
print "End e = " + str(e)
print "Time difference in scientific notation = "+ str(t)
print "Time difference in decimal system = "+ str(
183
Python Tutorials
decimal.Decimal(str(t)))
t2 = time.ctime();
print "Initial date and time : "+ str(t1)
print "Final date and time : "+ str(t2)
#
#FAST:
# if you are inserting something in the list, mentioning the size
# of the list in the constructor makes it faster
nodes = SX.NodeList(num_nodes);
for... :
nodes.insert(n);
#-----------------------------------------------------------
• Deleting Objects
#-----------------------------------------------------------
#SLOW:
nodes = SX.NodeList();
#
#FAST:
nodes = SX.NodeList();
#some code
nodes.delete();
# explicitly delete the object instead of mortal
#
#BE CAREFUL THOUGH. IF delete IS NOT CALLED PROPERLY WILL RESULT
#IN CRASHES OR MEMORY LEAKS
#
#
################ NEVER NEVER DO ################
nodes = model.getNodeList();
nodes.delete(); # <== VERY VERY DANGEROUS
#AS YOU ARE MESSING SIMXPERT's POINTERS !
#---------------------------------------------------------
Step 3: Go to Publish page and select a Workspace for which the template will be applicable, such as
Structures. Change file location, if desired. Click OK to close Properties.
Step 4: On Controls toolbox, select New Script Action. In the dialog, type in model_node_count as
the Name, and select Python Code from the drop-down list for code Type. Click Ok.
Step 5: The Action Editor now opens across the entire graphics window. Select the Data tab at bottom.
There are no input parameters.
Step 6: Switch View to Output Table. Click + to add an output. Change Name to NodeCount and Type
to Real.
Step 7: Select Code tab at bottom. Click Update button and note that some “Code Fence” statements
are added automatically.
Step 8: Code can be typed directly in the window, or click Edit button to open Script Editor. After the
definitions of inputs there is a statement:
# CODE FENCE END: Declarations
# Enter your code here
# CODE FENCE BEGIN: Outputs
It is between the two above “Code Fence” statements that the Python code will be placed. Type
or copy / paste the following between the two code fence statements above:
model1 = CLexSofyEnv.getCurrentModel();
# same as RADE,everything in pkg files
dbname = SX.model1.getDbName();
SX.ShowMsg ("Database Name - " + dbname);
nodelist1 = model1.getNodeList();
NodeCount = nodelist1.length(); #get the Node count
Completed script:
The completed script should look like this:
# CODE FENCE BEGIN: Declarations
import RIDL
RIDL.loadModule("rgen_ridl")
context = SX.ScriptDelegate.current();
if (not context):
SX.showErrorMsg("The script must be executed in a Process.");
raise "Error";
inputs = context.getInputs();
outputs = context.getOutputs();
NodeCount = 0; # () NodeCount
# CODE FENCE END: Declarations
model1 = SX.CLexSofyEnv.getCurrentModel();
# same as RADE,everything in pkg files
dbname = model1.getDbName();
SX.ShowMsg ("Database Name - " + dbname);
nodelist1 = model1.getNodeList();
NodeCount = nodelist1.length(); #get the Node count
outputs.setDouble("NodeCount", NodeCount);
# CODE FENCE END: Outputs
What is RADE?
Rapid Application Development Environment (RADE) is a powerful tool embedded in SimXpert to:
Add and Customize SimXpert's Functions
Integrate other commercial applications to SimXpert
Allow users to use SimXpert as a Pre/Post tool for their internal applications and technologies
Automate tasks and procedures
RADE is an interpretive environment. RADE is an Object Oriented (OO) Language, whose syntax is
very similar to C++. Additionally, C/C++ shared libraries (objects and members) can be easily wrapped
into RADE, thus making RADE an extendable Language.
Unlike Python, RADE is a proprietary code used by SimXpert.
Function Declaration
A function declaration defines a function and is of the form:
function classname:functionname(argument1, argument2)
{
rade code statement;
more rade code;
}
If the function is not a member of a class, then the classname: is omitted. Contained within the
parenthesis are the arguments, or parameters for the function, and can be either inputs or outputs.
The curly brackets contain the statements to be executed. Each statement is terminated with a semi-colon.
Commenting
RADE uses C++ like syntax for commenting your RADE Programs.
// comment here
Class Definition
Data with similar attributes can be grouped into a “class.” A class is a data type which can contain
“members” (attributes) and “methods” (functions). A base class may contain other derived classes, which
188
RADE Scripting Language
inherit all the properties of the base class. A derived class can have additional unique properties of its
own.
In the following example, the global variables var1 and var2 for the new class, ClassXX are defined,
followed by the class declaration, then the member function, func_do_something. Additional
member functions can follow.
global ClassXX = {
var1 = NULL,
var2 = "Blue"
};
class(ClassXX);
function ClassXX:func_do_something(arg1, arg2)
{some code statement;
}
CLexStatusLog
CLexField
CLexQualityEnhancer
CLexShapeFun
CLexGUITriad
CLexPostUtils
CLexObject
CLexFieldMeshSurface
CLexBox
CLexScene
CLexSofyStream
CLexMeshElement
CLexSofyEnv
CLexMorphControl
CLexColorBar
Data Types
RADE has dynamic type checking: As soon as a value is assigned to a variable, it gets a type. RADE has
5 Data Types:
function
number
char * (string)
table: can have numeric as well as non-numeric fields
void * (pointer): used to store C/C++ values.
Reserved Keywords
and for or
break function return
case global switch
continue if then
default local while
do NULL
else not
190
RADE Scripting Language
The reserved keywords cannot be used as names for variables, functions, or classes.
191
RADE Syntax Details
Control Blocks
Syntax for the various RADE control blocks are as follows:
function func_name() { blocks }
if (condition expression)
repeat
{ block } until (condition)
switch(condition)
case const1 : { . . break; } . . default : { . . break; } }
The for, while, do and do-while support continue statement, continue statements are
not allowed in a switch statement
Variables
Variables must explicitly be declared as local or global.
For consistency and stability, the use of Global variables should be kept to a minimum to reduce conflicts
with SimXpert and other supplier provided software.
Variables do not have types. Types are dictated by the values they hold. Evaluation is done at run time.
local a = "astring"; // type of variable a is string
a = 1.0; // type of variable a is number
C-style escapes are allowed with a '\'.
Strings are represented by "astring" or 'astring'
Similarly multiple initialized variable can be assigned as follows:
i, v = 0, 1; // i = 0 v = 1
i,j += 1, 3; // adds 1 to i and 3 to j
m,n ++; // increments m and n by 1
Memory Management
Memory management in RADE is automatic. All memory for 'local' variables is automatically managed.
Exception: when a user uses “new”
Nodes = NodeList:new(10000)
then the memory management is under programmer's control. In this case the statement
Nodes:delete()
would delete the allocated memory.
Arithmetic Operators
193
RADE Syntax Details
Logical Operators
== Check Equality Condition: works with Real, Integer and Strings
!= Not Equal Condition Checker
<= Less than or Equal to Condition Checker
=> Greater than or Equal to Condition Checker
< Less than condition checker
> Greater than condition checker
&& Logical And || Logical Or
Unary Operators
- Reverse sign (negate)
! Logical not
Tables
Table constructors are expressions that create tables. Every time a constructor is evaluated, a new table
is created. Constructors can be used to create empty tables, or to create a table and initialize some fields.
The expressions in the list are assigned consecutive numerical indices, starting with 1. For example:
local a = {"v1", "v2", 34} is same as:
194
RADE Syntax Details
TABLE Functions
looptable(table, function) - calls function for each field of table
looptablei(table, function) - calls function for each numeric field of table
loopvar(function)
next(table, index) - traverses a table (initially index should be NULL)
nextvar(name)
Built-in Functions
assert(v, [msg]) - similar to C function
clock() - returns the approximate cpu time in seconds
collectgarbage() - force a garbage collection cycle
date([format]) - follows the same rules as C function strftime
exit([code]) - executes the C exit function
getenv("varname") - gets the value of the environment variable
print(v1, v2, ...) - prints any number of arguments to stdout
process_file (" file_name ") - execute a file within this RADE environment
process_string (" ... ") - execute a string within this RADE environment
tostring(e) - converts the given argument to a string representation
tonumber(e) - **tries** to convert argument to number
type(variable) - returns the variable type
seterrormethod(method) - sets the error handler and returns the old handler
system("command") - executes a system command
length(table) - returns the length of numeric indices of table
insert(table, [, pos], value - inserts a value in a table optionally at a position which by
default is at the end
remove(table, [, pos] - removes a value from a table optionally from a position which by
default is at the end
195
RADE Syntax Details
sorttable(table [,function]) - sorts the numerical fields of a table optionally with the help
of a sorting
Mathematical Functions
sin(x) - x in degrees, cos(x), tan(x)
asin(y), acos(y), atan(y), atan2(number, number)
deg(number) - converts radians to degrees
rad(number) - converts degrees to radians
PI - has the value of PI
abs(val) - returns absolute value
min (val1, val2, ..., valx) - returns min value
max (val1, val2, ..., valx) - returns max value
ceil (val) - returns the next higher integer
floor (val) - returns the next lower integer
log(number), log10(number)
mod (val2,val1) - returns the remainder of the expression (val2/val1)
sqrt(number)
NULL - Null Value
rand([integer n]) - when called with no arguments returns a random real number in the range
[0,1] ; when called with a number n, Random returns a random integer in the range [1,n]
srand(number) - reset the random-number generator to a random starting point
Binary Operations
band(int n1, int n2) - returns n1 & n2
bor(int n1, int n2) - returns n1 | n2
beor(int n1, int n2) - returns n1 ^ n2
lshift(int v, int i) - returns v << i
rshift(int v, int i) - returns v >> i
String Functions
strlen(str) - returns the length of the string
substr (str,i,[j]) - returns a substring starting at the ith location and ending at the jth location.
196
RADE Syntax Details
strstr(str,pattern[,init]) - returns the index where the pattern match was found.
e.g: print(strfind("Hello There","There")) - this will print - 7.
tolower(str) - returns a copy of str with all characters changed to lower case.
toupper(str) - returns a copy of str with all characters changed to upper case.
strdupn (s, n) - Returns a string that is the concatenation of n copies of the string s.
tochar(number) - converts an ascii number to a character
ascii(char) - converts an character to ascii number
sprintf(format_string, e1, e2, ...) - returns a string specified by the format string.
Same as the printf family of standard C functions.
The options/modifiers *, l, L, n, p, h are not supported
There is an extra option, q - this option formats a string in a form suitable to be safely read back
by the RADE interpreter; that is, the string is written between double quotes, and all double
quotes, returns and backslashes in the string are correctly escaped when written. e.g.,
sprintf('%q', 'a string with "quotes" and \n new line') - will produce
the string: "a string with \"quotes\" and \ new line"
strrepl (s, pattern, replacement [, n]) - Returns a copy of s, where all occurrences
of the pattern have been replaced by a replacement string. This function also returns, as a second value,
the total number of substitutions made.
PATTERN RECOGNITION
RADE uses 'Regular Expressions' for Pattern Recognition. The following combinations are allowed in
describing a character class:
. (a dot) - represents all characters
%a - represents all letters
%c - represents all control characters
%d - represents all digits
%l - represents all lower case letters
%p - represents all punctuation characters
%s - represents all space characters
%u - represents all upper case letters
%w - represents all alphanumeric characters
197
RADE Syntax Details
File IO Functions
All input and output operations are done, over two file handles. These are called:
_INPUT(reading)
_OUTPUT(writing).
The available global variables are:
_STDIN
_STDOUT
_STDERR
File handle is a user data containing the file stream FILE*, a distinctive tag is created by the I/O library.
Available functions:
openfile(filename, mode)
closefile (handle)
readfrom (filename)
writeto (filename)
appendto (filename)
remove (filename)
rename (name1, name2)
flush (filehandle)
seek (filehandle [, whence] [, offset])
tmpname ()
write ([filehandle, ] value1, ...)
198
RADE Tutorials
RADE Tutorials
RADE Tutorials
Several scripts are provided to demonstrate how RADE is used to perform certain actions in SimXpert.
Please review the previous section on RADE syntax for more information on the RADE scripting
language. The following topics are included in the RADE Tutorials.
• Sending a string to the SimXpert Message window.
• Demonstration of Object Oriented Programming concepts
• List handling
• Creation/Modification/Deletion of entities (Nodes & Elements)
• GUI (menus, spreadsheets, etc.)
• Entity Picking
• Enquiring the SimXpert database (e.g. give me all warped elements)
• Vector usage (cross, dot, etc.)
• Nearest neighbors (find nearest entity to location)
• File IO for parsing files
• Geometry
• Spline creation
• Projection of a location on a curve
These tutorials can be done in the Script Editor window, which is accessible from Tools menu, then
Macro, and Script Editor.
Select RADE from the language drop-down list. Each tutorial can be run by copying and pasting the
indicated text into Script Editor window and clicking Run button.
The tutorials are also available as a set of *.rdl files and if you have access to these files, the File Open
command may be used in Script Editor to run each tutorial. Comments in each tutorial are marked by “//”
or multi-line comments may appear as “/* ... */”
199
RADE Tutorials
/*
* Legendary HelloWorld program
*/
ShowMsg("Hello World");
ShowMsg("Hello World", "red");
ShowMsg("Hello World", "blue");
Step 2: Click the Run icon.
Step 3: To save a copy of the file, click the File Save icon in the Script Editor window.
#debug
global CMessage = {
msg_ = NULL,
color_ = "blue"
};
// msg_ and color_ are global variables for the class
/
class(CMessage);
// new defines constructor to create an instance of a class;
// can be called with one or two parameters: str and (optionally) clr
function CMessage:new(str)
{
local lm = {
msg_ = str,
200
RADE Tutorials
}
instance(lm, CMessage);
return lm;
}
function CMessage:getMsg(str)
{
return this.msg_;
}
function Demonstrate_OOP()
{
local my_msg = CMessage:new("Hello MSC");
my_msg:show();
my_msg.msg_ = "xxxxxxxxx";
my_msg:show("red");
my_msg:delete();
my_msg:show("red");
}
Demonstrate_OOP();
201
RADE Tutorials
Step 2: Run the script by clicking the Run icon in the Script Editor window. If desired, this file can be
saved by clicking the Save icon in Script Editor.
function ListBasics_CB()
{
local i;
// Table usage
// General RADE tables can contain mixed data types.
// Initialize a table
local table = { };
// The first item is given index of 1, not 0
insert(table, "MSC");
insert(table, "SimXpert");
insert(table, 22/7);
// but index of 0 can be assigned
table[0] = "zero";
202
RADE Tutorials
Step 2: Run the script by clicking the Run icon in the Script Editor window. If desired, this file can be
saved by clicking the Save icon in Script Editor.
* to execute a function
*/
function AddMyMenu()
{
local my_menu = gui:getTopMenu():findChild("My Menu");
if(not my_menu) {
// Check for existence of My Menu. If not existing, add My Menu
my_menu = TopMenuItem:new("My Menu");
}
// Check for existence of Show Msg on My Menu. If not existing,
// create it and assign the function ShowMessage_CB.
local pb;
if(not my_menu:findChild("Show Msg")) {
pb = PushButtonItem:new(my_menu, "Show Msg", "ShowMessage_CB");
}
}
// Execute the function AddMyMenu
AddMyMenu();
Step 2: Run the script by clicking the Run icon in the Script Editor window.
Step 3: After running the script, check the SimXpert menu bar for My Menu, then execute Show Msg
command from menu.
Note that the equivalent script in Python is not valid. When scripting in Python you can assign an Action
to a menu button, but not a function. See Python Tutorial 4 - Menus.
function CreateNodeGrid_CB()
{
local i, j, x, y, z = 0, 0, 0.0, 0.0, 0.0;
for(i=0; i<5; i++) {
for(j=0; j<5; j++) {
// system unit is m. dividing by 1000
204
RADE Tutorials
function CreateElements_CB()
{
// Ask the user to pick nodes
local nodes = NodeList:new(); mortal(nodes);
pickNodes(nodes, NULL, 4, "Pick 4 Nodes");
if(nodes:length() < 4) {
ShowErrorMsg("Pick at least 4 nodes");
return;
}
UpdateCollectionList();
drawAllCanvases();
}
function AddEntitiesMenu()
{
local my_menu = gui:getTopMenu():findChild("My Menu");
if(not my_menu) {
my_menu = TopMenuItem:new("My Menu");
}
AddEntitiesMenu();
Step 3: Run the script by clicking the Run icon in the Script Editor window. This file can be saved as
5-entity.rdl if desired.
Step 4: After running the script, check the SimXpert menu bar for My Menu > Create Entities, then
execute Nodes and Elements commands from menu. It will create a grid pattern of nodes, then
one element from four picked nodes.
#debug
function DeleteElements_CB()
{
// Ask the user to pick nodes
local nodes = NodeList:new(); mortal(nodes);
pickNodes(nodes, NULL, 0, "Pick Nodes to delete");
if(nodes:isEmpty()) { return; }
local i;
for(i=0; i<nodes:length(); i++) {
local id = nodes[i]:getAppId();
print(id);
}
deleteObjects(nodes);
if(not my_menu:findChild("Picking")) {
local pb = PushButtonItem:new(my_menu, "Picking",
"DeleteElements_CB");
}
}
AddPickingMenu();
Step 3: Run the script by clicking the Run icon in the Script Editor window.
Step 4: After running the script, check the SimXpert menu bar for My Menu, then execute the Picking
command from the menu.
Step 5: You will be prompted to pick nodes. Upon confirming, all elements connected to the picked
nodes will be deleted.
function MeshSurfaces_CB()
{
// get the current scene
207
RADE Tutorials
drawAllCanvases();
}
function AddMeshMenu()
{
// looks for top menu named My Menu
// and if not existing creates it
// looks for a child menu item named Mesh and if not existing,
// creates it and assigns the function MeshSurfaces_CB to it
if(not my_menu:findChild("Mesh")) {
local pb = PushButtonItem:new(my_menu, "Mesh",
"MeshSurfaces_CB");
}
}
// Execute the function AddMeshMenu
AddMeshMenu();
Step 4: Run the script by clicking the Run icon in the Script Editor window.
Step 5: After running the script, check the SimXpert menu bar for My Menu, then execute Mesh
command from menu.
Step 2: In Script Editor, open the file: 8-enquiry.rdl. Or Copy / Paste the text below into the Script
Editor window:
/*
* - Get all QUADs in the model
* - Get a warpage value from the user
* - Highlight elements with warpage greater than the above value
*/
/*
function CLexShellElement:warpage()
{
return 10;
}
*/
function Enquiry_CB()
{
// get the current model (you will usually have only ONE model)
// all FE data digging starts at the model (CLexModel)
local model = CLexSofyEnv:getCurrentModel();
function AddEnquiryMenu()
{
local my_menu = gui:getTopMenu():findChild("My Menu");
209
RADE Tutorials
if(not my_menu) {
my_menu = TopMenuItem:new("My Menu");
}
local pb = my_menu:findChild("Enquiry");
if(not pb) {
pb = PushButtonItem:new(my_menu, "Enquiry", "Enquiry_CB");
}
}
//Execute the function
AddEnquiryMenu();
Step 3: Run the script by clicking the Run icon in the Script Editor window.
Step 4: After running the script, check the SimXpert menu bar for My Menu, then execute the Enquiry
command from the menu. You should see the warped elements highlighted and a message in the
Messages window.
function PartInfoApplyCB(ss)
{
ss.apply = True;
ShowMsg("Apply pressed")
//ss.partName = ss:getCell(0, 0);
//ss.thickness = ss:getCell(1, 0);
ss:exit();
}
function PartInfoExitCB(ss)
{
ShowMsg("Exit button pressed");
}
function PartInfoComboCB ()
{
}
function BrowseCB(pb)
{
ShowMsg("Inside Browse Callback !");
210
RADE Tutorials
ss:setCell(0, 0, part:getName());
ss:setCell(1, 0, part:thickness());
ss:setCellWidget(2, 0, cb);
ss:setCellWidget(3, 1, pb);
ss.apply = False;
211
RADE Tutorials
ss:manage();
// pops up the spreadsheet
ShowMsg("After Manage");
if(ss.apply == True) {
//print("--------");
//print(ss:getCell(0, 0));
//part:setName(ss:getCell(0, 0));
ShowMsg("After Apply Pressed");
ShowMsg("Selected File is: " + ss.selectedFile);
}
UpdateCollectionList();
}
// prompt user to pick a part then input it to PartInfoSpreadsheet
function Spreadsheet_CB()
{
local parts = PartList:new(); mortal(parts);
pickParts(parts, NULL, 1, "Pick A Part");
if(not parts:isEmpty()) {
PartInfoSpreadSheet(parts[0]);
}
}
function AddSpreadsheetMenu()
{
local my_menu = gui:getTopMenu():findChild("My Menu");
if(not my_menu) {
my_menu = TopMenuItem:new("My Menu");
}
if(not my_menu:findChild("Spreadsheet")) {
local pb = PushButtonItem:new(my_menu, "Spreadsheet",
"Spreadsheet_CB");
}
}
AddSpreadsheetMenu();
// end of script
Step 3: Run the script by clicking the Run icon in the Script Editor window.
Step 4: After running the script, check the SimXpert menu bar for My Menu, then execute the
Spreadsheet command from the menu.
Step 5: You will be prompted to pick a Part, then the spreadsheet / table is created. Try out the Browse,
Apply, and Exit buttons to see the effect of each.
STL - This tutorial shows how to read and parse an external file, then create SimXpert entities. In this
case triangular shell elements are created from the STL (stereolithography) file, which represents a
surface as a series of triangular patches defined by three vertices and a unit normal.
For this tutorial a demo file named sample.stl is needed. It is located in the <SimXpert
Installation>/help/PartFiles/scripts folder. Or use any valid *.stl file.
Step 1: Open the Structures or Crash Workspace and clear the database as needed (File > New).
Step 2: Set length units to meters (Tools > Options > Units)
Step 3: In Script Editor, open the file: 10-read-stl.rdl. Or Copy / Paste the text below into the Script
Editor window:
Step 4: Type or Copy / Paste the text below into the Script Editor window:
/*
* - demonstrates how to use the file open dialog box
* - reading a file
* - parsing (some pattern recognition concepts)
* - CLexWCoordinate
*/
function ReadSTL_CB()
{
// Create some CLexString objects to hold the file name,
// desired extensions, working directory, etc.
local fname = CLexString:new(); mortal(fname);
local pattern = CLexString:new("{ *.stl *.rdl }");
mortal(pattern);
local workdir = CLexString:new(); mortal(workdir);
local fstring = CLexString:new("unnamed.stl"); mortal(fstring);
// Present a file open dialog to the user
GetFile(
pattern,
"STL File Name: ?",
fname,
workdir,
fstring,
False
);
// Show error message if no file is supplied or user cancels
if(fname:data() == "CANCEL" or fname:data() == "") {
ShowWarningMsg("STL Read Attempt Cancelled !!");
return;
}
// call the function ReadSTL, defined below
ReadSTL(fname:data());
}
function ReadSTL(file)
{
// query the current model and get the current part
// If no part exists, create a part.
local model = CLexSofyEnv:getCurrentModel()
local part = CLexSofyEnv:getCurrentPart();
if(not part) {
213
RADE Tutorials
}
}
}
ShowMsg("# Elements Created = " + cnt);
ShowMsg("Done Reading STL File. Cleaning up ...");
drawAllCanvases();
UpdateCollectionList();
FillScreen();
IdleCursor();
}
// Adds a menu item to execute ReadSTL_CB
function AddSTLMenu()
{
local my_menu = gui:getTopMenu():findChild("My Menu");
if(not my_menu) {
my_menu = TopMenuItem:new("My Menu");
}
if(not my_menu:findChild("Read STL")) {
local pb = PushButtonItem:new(my_menu, "Read STL",
"ReadSTL_CB");
}
}
// execute the function AddSTLMenu
AddSTLMenu();
Step 5: Run the script by clicking the Run icon in the Script Editor window.
Step 6: After running the script, check the SimXpert menu bar for My Menu, then execute Read STL
command from the menu.
Step 7: When prompted for a file, select “sample.stl” or any valid *.stl file.
Step 8: Upon completion you should see a partial representation of a surface with triangular elements.
*/
#debug
function CreateTempGraphics_CB()
{
// Create a temporary line
local lineGraphics = CLexLineGraphicsObject:new(
0, 0, 0, 0.002, 0.002, 0.002);
// Create an axis
local axisGraphics = CLexArrowGraphicsObject:new(
0, 0, 0, 0, 0, 1, 0.001);
function AddGraphicsMenu()
{
local my_menu = gui:getTopMenu():findChild("My Menu");
if(not my_menu) {
my_menu = TopMenuItem:new("My Menu");
}
if(not my_menu:findChild("Graphics")) {
local pb = PushButtonItem:new(my_menu, "Graphics",
"CreateTempGraphics_CB");
}
}
AddGraphicsMenu();
Step 3: Run the script by clicking the Run icon in the Script Editor window.
Step 4: After running the script, check the SimXpert menu bar for My Menu, then select the Graphics
command from the menu.
Step 5: The line, axis, and text objects will be displayed temporarily. These objects can be cleared using
View > Clear Highlights.
Grapher- Shows how to invoke the SimXpert grapher to create an X-Y plot. This may become obsolete
in future versions. See Python Tutorial 12 - Graphs - 2D Bar Chart for an example of newer API calls.
Step 1: In Script Editor, open the file: 12-grapher.rdl. Or Copy / Paste the text below into the Script
Editor window:
#debug
load("grapher_ridl");
function GrapherTestExit(plotter)
{
plotter:delete();
}
function CreateGrapher_CB()
{
local plotter = SGView:new(gui);
plotter:setExitCB("GrapherTestExit");
local canvas = plotter:currentCanvas();
canvas:setXLabel("X");
canvas:setYLabel("Y");
canvas:setTitle("Title");
// canvas:resize(width, height); if you want to resize
// canvas:setXTickPrecision(2); pixel precision
canvas:scaleToFit();
plotter:show();
}
function AddGrapherMenu()
{
local my_menu = gui:getTopMenu():findChild("My Menu");
if(not my_menu) {
my_menu = TopMenuItem:new("My Menu");
}
if(not my_menu:findChild("Grapher")) {
local pb = PushButtonItem:new(my_menu, "Grapher",
"CreateGrapher_CB");
}
}
AddGrapherMenu();
Step 2: Run the script by clicking the Run icon in the Script Editor window.
Step 3: After running the script, check the SimXpert menu bar for My Menu, then execute Grapher
from the menu.
217
RADE Tutorials
Step 4: Try adding data points to the above code to change the look of the graph and run again.
function CreateSplineCB()
{
while(1) {
local coords = CoordList:new(); mortal(coords);
pickLocations(coords, 0, "Pick locations of the spline");
if(coords:isEmpty()) { return; }
CreateSpline(coords);
}
}
function AddSplineMenu()
{
local my_menu = gui:getTopMenu():findChild("My Menu");
if(not my_menu) {
my_menu = TopMenuItem:new("My Menu");
}
Step 3: Run the script by clicking the Run icon in the Script Editor window.
218
RADE Tutorials
Step 4: After running the script, check the SimXpert menu bar for My Menu, then execute Create
Spline command from the menu.
Step 5: The Pick panel will open and you will be prompted to pick locations through which to create
the spline. In the Pick panel, select the type of entity you will be picking (Points or Location on
Curve. Or select “XYZ” to type in the coordinates.)
Step 6: Pick from the screen or enter the locations, then click the Done button in the Pick dialog. The
spline is immediately created. This is similar to using the Line/Spline tool on the Geometry tool
ribbon.
Step 7: The pick panel will remain open if you wish to create additional splines. Click Done, then Exit
when finished.
Step 3: Run the script by clicking the Run icon in the Script Editor window.
Step 4: After running the script, check the SimXpert menu bar for My Menu, then execute Pt. on
Curve command from the menu.
Step 5: You will be prompted to pick 1curve. If more than one curve is picked, only the first picked
curve is used, the rest are ignored.
Step 6: Upon confirming your selection, a node is created and a temporary arrow is highlighted to mark
the tangent at that location. You can clear the arrow by selecting View > Clear Highlights from
the menu.
function DelElemsProcessFunc(pp)
{
if(pp:isEmpty()) { return; }
local node = pp:last();
cast(node, "CLexNode")
{
if(pp:isEmpty()) { return; }
// Get connected elements & add them to the pick
local elems = ElementList:new(); mortal(elems);
local nodes = NodeList:new(); mortal(nodes);
cast(pp, "ElementList");
getNodesFromElementList(pp, nodes);
getElementsFromNodeList(nodes, elems);
// Remove already picked elements from the pick dialog
CLexPickDialog:resetPickLists();
// Add these elements to pick
local i, len = 0, elems:length();
for(i=0; i<len; i++) {
CLexPickDialog:insertPickedObject(elems[i]);
}
CLexPickDialog:getNumPickedList():insert(len);
}
function ComplexPicking_CB()
{
CLexPickDialog:reset();
// History initialization
//CLexPickDialog:TurnPickHistoryOn();
CLexPickDialog:setPickTitle("Delete Elements");
CLexPickDialog:insertPickItem(__PICK_NODES);
CLexPickDialog:setSinglePickStyle();// setMultiPickStyle
CLexPickDialog:setProcessingFunction("DelElemsProcessFunc");
CLexPickDialog:setDoneFunction("DelElemsDoneFunc");
CLexPickDialog:manageChoice(False, "Delete Nodes Also", "Delete
Nodes Also");
//CLexPickDialog:setExtraRejectLastFunction("CLexPickDialog_Gene
ricHistoryRejectLast");
//CLexPickDialog:setExtraExitFunction("CLexPickDialog_GenericHis
toryExit");
//CLexPickDialog:setExtraExitFunction("");
CLexPickDialog:setAnyFunction("AddElemsToPick_CB","+");
CLexPickDialog:manageEvents();
ShowMsg("Pick a Node whose connected elements will be deleted");
}
function AddComplexPickingMenu()
{
local my_menu = gui:getTopMenu():findChild("My Menu");
if(not my_menu) {
my_menu = TopMenuItem:new("My Menu");
}
if(not my_menu:findChild("Complex Picking")) {
local pb = PushButtonItem:new(my_menu, "Complex Picking",
"ComplexPicking_CB");
}
}
AddComplexPickingMenu()
Step 3: Run the script by clicking the Run icon in the Script Editor window.
222
RADE Tutorials
Step 4: After running the script, check the SimXpert menu bar for My Menu, then execute Complex
Picking command from menu.
Step 5: You will be prompted to pick a node whose connected elements will be deleted. Select several
nodes, then confirm the selection with Done or middle mouse click. The highlighted elements
are then deleted.
Step 6: Compare this code to that in RADE Tutorial 6. Both scripts perform essentially the same action
but this one has many more settings to control the picking. It also immediately highlights the
elements that are connected to the picked nodes during picking.
If you want to test a script to see how fast it runs, insert the following RADE code. Place the top section
above your code, and the bottom section after your code. It will print the start, finish, and elapsed times
to the console window. It also shows you how to get the current date and time:
How to check the time it takes for your code:
local s = clock();
//
... your code here ...
//
local e = clock();
print("time taken = ", (e - s));
//-------------------------------------------------------------
//SLOW:
for(i=0; i<nodes:length(); i++)
//FAST:
local len = nodes:length();
for(i=0; i<len; i++)
//-------------------------------------------------------------
//
//-------------------------------------------------------------
//SLOW:
for(...){
local vec = CLexWCoordinate:new(); mortal(vec);
}
//FAST:
223
RADE Tutorials
• Deleting Objects
//-----------------------------------------------------------
//SLOW:
local nodes = NodeList:new(); mortal(nodes);
//FAST:
224
RADE Tutorials
Template Execution
226
Open Template Execution window
Other workspaces
From the workspace toolboxes panel, select the Templates tool ribbon to browse the available templates
for the workspace. Recently accessed templates may appear in the toolbox. Click on a template tool to
open the Template Execution window.
If the desired template is not shown in the list, use the Browse tool to locate a template that is stored
locally.
Use Retrieve or Run Published Template... tool to access SimManager and open a published Template
from there. In the first case, the template is retrieved and results files are not managed in SimManager.
But when using the Run Published Template...tool, the option exists to run remotely and manage results
227
Open Template Execution window
files using SimManager Enterprise edition. When “Managed” execution is selected, a Process object is
created in the SimManager database, and the inputs and outputs are captured in SimManager. (See
Retrieve and Run a Template.)
228
Running a Template
Running a Template
Unit Validation
As soon as a template is opened in the Execution window, the current model units are checked against
the unit system stored in the template. If a mismatch exists, you will be prompted to change the units.
Select Yes to automatically change the current unit system to be consistent with the template. The
Messages window will display a confirmation of the change in unit system.
Begin Execution
You may need to change some settings before running. For example:
• Set Options
• Pause at selected Actions
• Toggle automatic execution of Actions.
Use the Template execution toolbar buttons to control the execution and/or the view during execution.
229
Running a Template
Those actions set to prompt “At Execution of Parent” will prompt for inputs before starting template
execution. Those set to “At Execution of Action” will not prompt for input parameters until that action
is reached in the template execution. (See Action Properties dialog box.)
Inputs may already be populated from one of the following sources:
• Default values were set at the template or action level.
• An Input is connected to an Output of a prior action.
• Inputs were saved during macro recording.
• Inputs were saved during a prior execution of the template.
In the case of pre-populated inputs, verify that the entries are correct. If not, clear or Reject the selections
and re-enter them.
Enter the appropriate inputs and choices in the text boxes provided, or select objects from the SimXpert
model. A Pick button indicates that the object can be picked from the current model. Click the button to
initiate a pick panel.
230
Running a Template
When picking is active, the dialog box will be minimized. Click the middle-mouse button in graphics
window to finish picking and return to the input dialog box.
Click OK to continue Template execution after providing all inputs. Depending on the prompting
behavior assigned to each action, additional dialog boxes may appear prior to each action.
Note: When running a recorded macro or template with saved inputs, selection of objects may
occur automatically. You should be prepared to check the selections and verify them. If
incorrect objects are auto-selected, they must be rejected or cleared before proceeding.
If the Un-do command has been used, then the Re-do icon becomes activated. The Un-do can then be
reversed to return to the original state.
Action Icons
When View Chart is activated, the flowchart of the template is displayed, similar to the view in Template
Builder. As each action in the Template is executed it becomes highlighted in the execution window.
231
Running a Template
A yellow square outlines the current action, indicating the action is being executed or possibly paused,
waiting for input.
A real-time graphical view of the model status may also be seen for certain actions, when the icon has
been designated as a graphics snapshot. Right-click on a snapshot icon to access SimXpert view
manipulation commands (Pan, Zoom, etc.)
Click Fit button to resize the icons to fill the window. Use Zoom icon and scroll bars to view any part of
the template in detail.
Status messages
A small message area appears on the toolbar of the Template Execution window, giving the current status.
In Tree view, the status of the template and each action in the template is displayed.
232
Running a Template
Watch the SimXpert Messages window for additional status and prompting messages.
233
Template execution toolbar
The toolbar icons, from left to right, are described in detail below:
Options
Click the Options icon at upper left of Template Execution window to access a list of options.
View Tree
234
Template execution toolbar
Select View Tree to show the tree view of the template execution.
View Chart
Select View Chart to show flowchart view of the template execution.
Auto Save
235
Template execution toolbar
Automatically saves a Template file corresponding to the executed template, and containing all the
selections and inputs made by the user during the run. The template file is saved after each action in the
template is completed.
Template Inputs
Opens a dialog box with all the undefined inputs for the Template. Default values can be changed here,
prior to execution.
Execution Report
Opens a Execution Report dialog box showing all the output parameters for the Template. If the template
has already been executed, shows the status of the execution, and the values of output parameters.
Batch execution
Allows the Template to be executed with inputs contained in a comma-separated value (*.csv) file. The
CSV file typically contains multiple sets of inputs, such that the Template can be run several times with
different input values.
236
Template execution toolbar
A *.csv file editor and execution control buttons are provided in a separate window when running a batch
execution. The *.csv file can be edited prior to starting the batch execution. See Batch execution of
templates, below.
Reset
Resets the status of each action to “Un-executed.” Also resets counters for any simple or for-each loops.
Useful if it is desired to re-start a template execution.
A file browse dialog box allows navigation to the location of the saved template file, typically in the
Process\Executed folder. Select a *.proc file in Executed folder to open.
Upon selecting the file, the input parameter values are imported. The Template can be run again using
the saved input parameters, or they can be modified before executing, using Template Inputs on Options
menu.
When used together with Use Saved Inputs in Options menu, clicking Run button causes template to
execute using the saved values from the imported file. If Prompt for Inputs is not checked, the template
will run without stopping to confirm the input parameters. The saved values are used instead.
237
Template execution toolbar
Save
After a Template has been executed, the Save button becomes available. Click Save to store a template
(*.proc file) containing the inputs used during the most recent execution.
\
A template file is saved to the default location of: <SimXpert install directory>\Process\Execution. The
file name is by default the original file name with a date and time stamp appended to the name.
When running a Template in iterative mode, multiple execution files can be stored for each Template. A
saved Template execution can be recalled using the Import Input Values command, or by simply
navigating the directory structure when Browsing for a template to execute.
Run / continue
Select this button to begin Template execution. If execution is currently paused, select it to continue the
execution.
To run only one action at a time, first select an action in the current Template. Click the Run Selected
Action button to run only the selected action. Template execution then pauses at the next action.
Step into
Activate the Python debugger and step into the code of the current action. (Only available for Custom
Actions.) A Script Editor window will open, with a breakpoint exactly on the first line of user written
Python script code. You can edit the code and use all of the Debugger features, such as watching
variables, monitoring outputs, and stepping in / out / over functions. You can open multiple script files in
the Script Editor window and copy / paste code from one to the other. See Using Script Editor in the
Creating Actions section of this guide for details on using the Python debugger.
Continue to here
First select an action in the current template. Click the Continue to Here button to run the Template
from its current location up to the selected action. Execution will pause at the selected action.
238
Template execution toolbar
Pause
While Template is executing, use pause button to temporarily halt execution. To resume execution click
run / continue button. Or click Step Into to enter debugging mode.
Stop
While Template is executing, use stop button to halt execution of the Template. Use this button only if
you do not intend to continue.
Pause at selected
This button will set a breakpoint at any action in the template. Prior to running a Template, select an
action where a pause is desired, then click Pause at selected button to create a breakpoint. A green
square on outside the action icon indicates that a breakpoint has been set there.
While running the template, execution will pause at that location. Use the Run / continue button to
resume execution. Or click Step Into to enter debugging mode.
Select an action, then select the Toggle automatic execution icon from toolbar to make the selected
action optional, or to toggle back to automatic mode for the action. This icon is not available when an
action was designated as Automatic in the Action Properties dialog box by the template author.
Fit
239
Template execution toolbar
Click the Fit button to fit the entire template inside the Chart view of the Template Execution window.
(Only applicable when View Chart is selected in Options.)
Zoom In
Click the Zoom In button to enlarge all the icons in the in the Chart view of the Template Execution
window. (Only applicable when View Chart is selected in Options.)
Zoom Out
Click the Fit button to reduce the size of all the icons in the in the Chart view of the Template Execution
window. (Only applicable when View Chart is selected in Options.)
Edit
Click the Edit button on the toolbar at upper right of Template Execution window to edit the Template
in the Template Builder workspace.
The current Template is opened in the Template Builder workspace.
See Creating a new template in this user guide for details on creating & editing templates.
240
Batch execution of templates
A separate Batch Execution window appears in which the *.csv file containing the input values can be
edited and saved. Then the batch execution can be initiated.
Select the Batch input file containing the input data for batch execution. This is a *.csv file, which may
have been created in Template Builder while editing the template file. See Template Properties dialog
box > Publish > Create .csv file for details on creating the CSV input file.
Select the Template that corresponds to the selected *.csv file.
The Output file will be populated automatically.
241
Batch execution of templates
Select the check box to “Save a snapshot of the Template after each execution,” if desired. This will
create a separate template file for each execution.
SimManager Interface
244
SimManager Introduction
SimManager Introduction
Introduction
A complete Simulation Data Management solution is possible when SimXpert is coupled with
SimManager. Integrated Best Practices capture in the form of SimXpert Templates are best managed in
an enterprise-wide data and knowledge management package such as SimManager. This allows sharing
and life-cycle management of templates and all related data files.
An expert analyst can create a SimXpert template for executing an analysis procedure and “publish” it to
SimManager. Other analysts and designers throughout the enterprise can “retrieve” the template and use
it for their particular design phase or product line. SimManager is used to manage the roles of users as
authors or consumers of templates and designate the access and editing permissions for each. The audit
trail of Template modifications is automatically tracked in SimManager and users can obtain pedigree
information on published templates.
SimManager also allows direct integration to MSC Patran, Easy5, MD Adams, MSC SimXpert, and
MSC SimDesigner. Models, data, and (where enabled) templates that are published to SimManager can
be accessed from these applications. Thus an analysis best practice procedure captured as a template by
an expert user in SimXpert can be run by other users throughout an organization. In many cases, the user
may not need any knowledge of SimXpert to run a template in batch mode from SimXpert or the
SimManager Web user interface. Likewise, design files, models, and results files can be made available
to other users enterprise-wide.
There are several commands and tools in SimXpert that interact with SimManager. Most of the analysis
workspaces (Structures, Thermal, Crash, etc.) all share common interfaces with SimManager. The
Template Builder has some unique interfaces relating to creating and publishing templates. A summary
of these interfaces follows:
Toolbar
The SimManager toolbar allows access to SimManager from the SimXpert session, including ability to
login, logoff, publish data, retrieve data, and open the SimManager web portal.
The SimManager toolbar is found in all SimXpert workspaces, but the Template Builder toolbar is
slightly different from the other workspaces. See SimManager Toolbar section for more details on the
SimManager toolbar commands.
Published Toolbox
Actions and templates are retrieved from SimManager for insertion into a template or for editing using
the Retrieve commands, in the Published toolbox. See Creating a new template for more details.
Publishing of completed templates to SimManager is done from the Template Properties dialog box.
or from the Model Browser.
See Also:
Click “?” in the Model Browser to open the Quick Reference help for the Model Browser, then expand
the Enterprise Tab section for details.
248
SimManager Toolbar
SimManager Toolbar
The SimManager toolbar allows access to SimManager from the SimXpert session, including ability to
login, logoff, and open the SimManager web client.
The SimManager toolbar is found in all SimXpert workspaces, but the Template Builder toolbar is
slightly different from the other workspaces. If the SimManager toolbar is not present, right-click in the
toolbar area and place a check by SimManager to turn on the toolbar.
The SimManager toolbar allows access to SimManager from the SimXpert session. In Template Builder
workspace the toolbar commands include Logon, Logoff, Web Client, and Run Published.
In the other analysis workspaces the toolbar is slightly different. The Logon, Logoff, and Web Client
toolbars are present, as in Template Builder. In addition there are Browse, Publish Data and Retrieve
Data commands.
Logon
To connect to SimManager, click the Logon icon on the SimManager toolbar.
A login dialog box is opened. Enter a valid User Name and Password.
Enter the address of the SimManager server, as provided by your system administrator. It will be a URL
similar to “http://simmanager-server:8989/SimManager.”
249
SimManager Toolbar
Click Ok to login.
Logoff
Click the Logoff icon to disconnect from SimManager.
Run Published
This toolbar command is only present in Template Builder workspace. It allows you to select a template
from SimManager to open and run locally using the Template Execution window.
A navigation panel provides access to the Projects in SimManager and filters the view according to
Template objects stored there. Upon locating a template, it may be saved to disk and executed. See
Retrieve and Run a Template for details.
Publish Data
This toolbar command is not present in Template Builder workspace but is present in all other analysis
workspaces (Structures, Motion, etc.) Click Publish Data icon on SimManager toolbar to open a publish
dialog box.
The current SimXpert model will be published, along with associated data files (analysis decks, results
files, images) to SimManager. The items to be published will be associated with an existing Project and
design variant in SimManager. See Publish Other Simulation Data, below for details.
Retrieve Data
This toolbar command is not present in Template Builder workspace but is present in all other analysis
workspaces (Structures, Motion, etc.) Select Retrieve Data icon to initiate a SimManager retrieve dialog
box. This allows navigation in SimManager to locate the Project, Design, and Simulation files of interest.
Browse Database
This toolbar command allows you to navigate SimManager database, to view all types of objects stored
there, and to retrieve them.
Browse allows viewing and retrieval of CAD files, design variants, SimActivities, and many other object
types. This is somewhat different than the Retrieve Data command, which is limited to analysis models
and related data.
See Also:
See the Structures workspace Quick Reference Guide for details. (Help > Quick Reference > Structures
>File menu)
Web Client
Opens the SimManager web client in a browser window.
A login screen may appear first. Enter a valid User Name and Password and click Login.
252
SimManager Toolbar
The SimManager web user interface opens to the Home page of My Workspace, which presents a
dashboard view of your data and recent activity. The widgets displayed include My Executable Projects,
My Models, My Folders, etc. From the customizable Home page you can use the links to go directly to
any object listed. Or you can expand any of the widgets into a full page list of objects.
The workspace tabs provide different views of the objects in SimManager and tools that are specific to a
particular task or role.
The Administration Workspace is visible to authorized managers and methods experts. A manager can
create Projects and specify the access controls for projects in the Administration tasks.
253
SimManager Toolbar
A methods expert can manage the publishing of Procedures (such as SimXpert templates) and Resources
(such as SimXpert Actions) in the Methods tasks.
There are many capabilities to query and navigate the database. You may copy objects to the clipboard
for quick access and usage in other tasks. It is also possible to find relationships between data such as
parent /child relationships, release status, object revision history, etc.
Refer to the SimManager 2010 User’s Guide for further information on using the web user interface.
254
Publishing from SimXpert to SimManager
If the correct Project under which the template is to be published is not already populated, click Select.
A Project selection dialog box is displayed.
Project Selection
256
Publishing from SimXpert to SimManager
Scroll through the project list and select a Project. Click Submit.
You are returned to the Publish Template dialog box.
Action Classifications
Select all action Classifications that are valid for this template from the “Available” list. Click the right-
arrow button to move the selected classifications to the “Assigned” list. Execution of this template in
SimManager will require that the Project and Template have at least one action classification in common.
257
Publishing from SimXpert to SimManager
Resource Files
The Resource Files table lists all the Custom Actions and sub-templates within the parent template. The
Resource Status column indicates the publication status of each resource (action or template). If any
resource is not yet published, or has been modified since the last publication, it will be published along
with the parent template. Core Actions from the SimXpert action library are not published as resources.
You have the opportunity to add or remove resources using the Copy, Add, and Delete buttons above the
table.
After modifying and saving the action, go to the Data sheet and click the Publish as Resource... button
to initiate a connection to SimManager.
Project selection
Click Select to choose a Project. In the Project selection dialog box. Scroll to locate the Project and select
it. Click Submit.
Upon selecting the Publish Data icon, the Compound Publish dialog box opens. It is a two-page tabbed
dialog which opens to the Basic Inputs tab.
262
Publishing from SimXpert to SimManager
Basic Inputs
Model Information
A Model File is required. If a SimXpert model is already open, it will be populated with the current
model. Otherwise you may need to Browse to an analysis model file on your local system.
The Model Type may be auto-populated based on the file name extension. If it is not correct, select the
model type from the list.
263
Publishing from SimXpert to SimManager
The Model Name will be populated based on the selected file, but can be changed.
Optionally, enter a Description of the model.
Project / Study
A Project is required in which to publish the model and related files. Click Select to choose the
appropriate Project in SimManager.
Select a Study, as appropriate (optional).
Item / Variant
A model must be published in the context of an Item and Variant, which establish the model as pertaining
to a particular iteration of the part or assembly being evaluated.
Click Select to choose the Variant associated with the Model and data being published. The Item will be
filled in once Variant is selected.
New Item
If an Item corresponding to the part or assembly does not yet exist, you can create one by clicking New.
The Create Item dialog box is a four-page tabbed interface. You will be creating an Item, along with an
initial Variant. Select each of the tabs and complete the appropriate fields before finally clicking Submit.
• Item Inputs
Enter the basic information about the new Item This information will be applicable to the Item
and all Variants that are created under the Item.
264
Publishing from SimXpert to SimManager
• Variant Inputs
Enter the basic information about the new Variant. This information will be applicable to this
Variant only.
Image
An Image File will be created from the current model, if loaded. Or you can select a file.
Model Files
Additional Model Files can be attached to the Analysis Model. These are files that may be needed to
support the main model file. But this area is not intended for input decks, results, or key results. See
Advanced Inputs, below.
Use the Copy, Add, and Remove icons as needed to add the auxiliary model files. Each time the Add or
Copy button is pressed, a new line in the Model Files table is added. Use the Browse button to locate the
file. A Role is required for each.
Don’t submit yet. If you have Input deck, Results Files, and/or Key Result Images to attach to the
Analysis Model you need to select the Advanced Inputs tab to create these objects.
267
Publishing from SimXpert to SimManager
Advanced Inputs
The Advanced Inputs tab allows you to create additional objects in SimManager such as Design Model
Input Deck, Result, and Key Result. These objects are directly related to the analysis model. They will
be published together as a group and the relationships between all the objects will be preserved. Select
the appropriate Add... button to attach a model or result.
You can also add custom Attributes to further describe the model and related set of data.
• Add Result
269
Publishing from SimXpert to SimManager
Add Attributes
Click the Add icon above the Text, Real, or Number Attributes table to add an attribute.
Publish
Finally after defining all the related objects and attributes, click Submit to publish the analysis model
and related files.
270
Retrieving from SimManager
Retrieve Data
From any SimXpert workspace (except Template Builder), a Model along with related input deck,
results file, and key result images can be retrieved from SimManager. These file types are the same as
published using the Publish Data command from the toolbar. (See Publish Other Simulation Data.)
Select the Retrieve Data button in SimManager toolbar.
This brings up a Retrieve Model dialog box to locate the data in SimManager.
271
Retrieving from SimManager
In the Model field, click Select to open an object selection dialog box. This tabbed interface allows you
to browse the SimManager database either by using a table or tree.
Using Table
Using Tree
272
Retrieving from SimManager
Retrieve Template
To retrieve an action or template from SimManager for editing, use the Retrieve Template or Retrieve
Resource tool in the Controls toolbox.
A SimManager Login Dialog may appear. Enter the appropriate User Name and Password.
The Select Template dialog box will appear. Scroll through the table to locate the desired Template. You
can sort the columns by clicking on a column heading. Select a Template and click Submit.
The retrieved template is opened for editing in the Template Builder window.
273
Retrieving from SimManager
Retrieve Resource
To retrieve an action from SimManager for editing, use the Retrieve Resource tool in the Controls
toolbox.
A SimManager Login Dialog may appear. Enter the appropriate User Name and Password.
The Select Resource dialog box will appear. Locate and select the desired Resource and click Submit.
Use the Published toolbox, and select Retrieve Template or Retrieve Resource to initiate retrieval of
actions or templates from the SimManager database.
The selection dialog box is the same as shown above in Retrieve and edit - actions or templates.
Once retrieved, the mouse pointer will change to an outline of the object’s icon, indicating that it can be
placed into the template by clicking in the graphics window.
Hint: • If you use the Refresh tool first, then all available templates and actions will be
shown in the Published toolbox and it will not be necessary to use the Object
Selection dialog to navigate the SimManager database.
See also: Inserting objects in a template for more details on adding actions to a template.
275
Retrieve and Run a Template
Run Published
The Run Published action is used to retrieve a published Template from SimManager and run it. There
are options for running “managed” or “unmanaged” and for selecting the location of execution (client or
server).
Managed execution
In Managed execution modes, a SimManager Process object is created. The Process object contains all
the data pertaining to the execution (for example, inputs, outputs, date / time, and user). Templates that
are not interactive in nature are suited for managed execution and server execution. These template
collect all the needed inputs prior to execution. The template will be executed without the appearance of
the Template Execution window. Then upon completion the template outputs are stored in SimManager.
They can then be used to create SimManager objects, such as Results and Key Results.
Unmanaged execution
In “un-managed” execution mode, a Process object is NOT created in the SimManager database upon
execution of the template. Therefore the inputs and outputs are not captured in the SimManager.
To use the Run Published action in the Template Builder workspace, select the Run Published icon from
the SimManager toolbar.
If the correct Project is not shown, click Select to open a Project Selection dialog.
Select a Queue, if configured.
Select a Launch Mode.
277
Retrieve and Run a Template
Process SOD
When executing of a procedure using one of the “Managed” modes of execution, a Process object is
created. See Managed execution. The Single Object Display (SOD) of the Process is displayed.
278
Retrieve and Run a Template
Depending on the extent of interactive actions in the template, you may need to supply inputs, and control
the procedure execution using the Actions menu commands. You can pause, continue, kill, or rerun the
template.
279
Retrieve and Run a Template
See Also:
See the SimManager 2010 User’s Guide (login required) for details on Process execution and the Process
SOD.
Select the template and click Submit to execute the selected template
The template is opened in the Template Execution window. Click Run button to begin execution.
See Running a Template in Template Execution chapter of this User Guide for details.
281
Enterprise SimManager options
A
action data 93
identification 94
parameters 96
publish 95
action editor 91
code page 130
data page
identification 94
parameter interface 111
parameters 96
data sheet 93
layout page 128
action instance
required version 61
action options 125
action properties dialog box 57
actions
connecting 37
creating 83
creating (summary) 32
definition 82
editing 91, 133
embedded script 88
entering code 130
execution option 60
inserting in a template 26
instances of 87
linked 87
new script action 85
properties 57
saving and publishing 95
version 94
B
balloon tips 17
batch execution 240
boolean parameter 120
branching 39
building a template
284
steps used 8
C
CADobject parameter 122
choice tool 39
configure SimManager 281
connection tool 37
controls toolbox
about 36
choice 39
connection 37
file 47
for-each loop 43
message 50
prompt 49
simple loop 41
while loop 45
create csv 54
create layout 55
creating a template
steps used 8
creating an action 83
creating an embedded script 88
csv file 54
csv input 240
D
definitions 5
discrete constraint 104
E
editing
actions 91
editing actions 133
embedded template 30
enterprise object parameter 123
enumeration parameter 121
F
file tool 47
I
input and output parameters 96
input parameter
285
S
script editor 137
Scripting tools 149
scripts
converting to action 135
running 150
writing 137
search tools 18
settings 71
SimManager
administrative options 281
browse 270
introduction 244
publishing from SimXpert 254
retrieve and run template 275
toolbar 248
string parameter 113
T
template
batch execution 240
controls toolbox 36
inserting into another template 29
options 71
properties 51
retrieve and run from SimManager 275
testing 65
template builder workspace
context menus 66
creating templates 21
editing templates 19
introduction 2
settings 71
tools 5
window 14
template execution window 226
icons 233
import input values 236
options 233
python debugger 237
288