Sie sind auf Seite 1von 288

1

Template Builder Workspace Guide


Introduction
2
Overview of Template Builder workspace

Overview of Template Builder workspace


The Template Builder workspace in SimXpert is a graphical authoring environment for creating
SimXpert Templates. A SimXpert Template can automate repetitive tasks, define CAE methods, and
perform simulations. The CAE expert will find the Template Builder workspace a useful tool for
capturing and sharing knowledge and best practices across the enterprise.

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.

Creating Templates with Macro Recording


The Macro Record feature of SimXpert can be used to record commands during a SimXpert session in
any workspace. The recorded macro is a SimXpert Template that contains a series of actions representing
the commands executed and the inputs provided. The recorded Template can then be edited in the
Template Builder Workspace.
3
Overview of Template Builder workspace

Opening Template Builder workspace


From the entry screen to SimXpert, select Template Builder to open Template Builder workspace.

Using Template Builder workspace


In the Template Builder workspace, templates can be created from scratch using the building blocks
called actions. Most SimXpert commands are available to the template author as actions in the Core
Action library. This reduces the need to write code to call SimXpert commands in a template. Or you can
create your own Custom Actions, which will require some ability to write scripts.
In the Template Builder workspace, a set of Toolboxes are provided to quickly assemble a process flow.

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

Types of objects used in a SimXpert template


A few terms are essential for Template Builder workspace users:

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:

There are three types of Actions:

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

Embedded Custom Action


An Embedded Custom action (also called an Embedded Script) is an action that it is wholly contained in
a template and is not available as a reusable action. An Embedded Script is like a Custom Action in many
respects, but it is not saved as a separate *.act file. Rather, it is saved as part of the parent template file
(*.proc).
An Embedded Script is used in cases where re-use of the script is not anticipated. It can be written in
Python, RADE, or can utilize an existing script file.

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

Controls and Connections


Additional tools are provided in Template Builder to connect actions together, pass data, prompt for
inputs, allow branching, and set up iterative loops. See Controls toolbox for details.
8
Overview of typical steps used

Overview of typical steps used


The following is an overview of the typical steps used to create a SimXpert template in the Template
Builder workspace:

Step 1: Create a new SimXpert Template


Use Macro Record to create a template by executing SimXpert commands. (See Recording a Macro.)
Open the recorded macro in Template Builder for further editing.

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.

Step 2: Position actions and templates in the workspace


Select and drop existing Core and Custom Actions from the Actions toolbox into the template builder
window. Likewise, place existing templates from the Templates toolbox into the new template.
Published actions and templates can be retrieved from SimManager and placed into the current template
using the Published toolbox. See Inserting objects in a template for details.
9
Overview of typical steps used

Step 3: Add new script actions


Advanced users may wish to create their own Custom Actions. (Python, RADE). A script editor and a
Python debugger are provided to aid in the creation of scripts.

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.

Step 4: Add user prompts & inputs


Additional tools are provided to add prompts for the user to supply data and files during template
execution. The File and Prompt tools on Controls toolbox are used to gather input files and strings,
respectively.
10
Overview of typical steps used

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.

Step 5: Add connections, branching, and looping


Connections are created using the Connection tool to control the sequence of execution and to pass data
between actions. When a connection is made, outputs parameters of one action can be automatically
provided as inputs to a downstream action. Edit each connection to select the parameters to be passed.
Use the Choice tool to create branching, where the template execution proceeds in different directions,
depending on the value of the choice.

Three Loop tools are provided to repeat a group of actions until some condition is satisfied.

See Controls toolbox for details.

Step 6: Check and set Properties for all template objects


Double-clicking on any template object will open the Properties dialog box for that object. It is
recommended to check the Properties for each object in the template (actions, sub-templates, and
connections) before testing.
11
Overview of typical steps used

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.

Step 7: Save & Execute the SimXpert Template


While creating a SimXpert template, it can be tested using the Template Execution window. Once
completed and saved, the template becomes available in the appropriate workspace(s). The Template
Execution window can be opened from any SimXpert workspace. See Testing a Template for details.
12
Overview of typical steps used

Step 8: Publish the SimXpert Template to SimManager


Templates can be published to SimManager from the Properties dialog box. This allows other users
throughout an organization to run the published Template. Custom Actions may also be published as
Resources.

See Publishing from SimXpert to SimManager for details.


13

Creating Templates
14
Template Builder Workspace window

Template Builder Workspace window

Open Template Builder


From the entry screen to SimXpert, select Template Builder.
M

If SimXpert is already opened in a different workspace, use the Workspace selector and select Template
Builder from the list.

Getting around in Template Builder


The main areas of the Template Builder workspace are shown in the image:
15
Template Builder Workspace window

Menus and Toolbars


The Template Builder workspace has a limited set of SimXpert commands and toolbars, containing only
those that might be needed during template building and testing. Refer to the Quick Reference Guide for
help on menu commands. (Help > Quick Reference > Template Builder.)

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

Editing an existing template


Upon opening the Template Builder workspace, you have the option to create a new template or action,
or to open an existing one. If a template file is already existing, such as a recorded macro, use the
following steps to open and edit the template file.
Step 1: From the entry screen select Open... Browse. (Or if the template has recently been accessed, it
may appear on the list just below the Browse command.)

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

Creating a new template

Using Macro Record


An easy way to get started with creating templates is to “record” all or part of a template using Macro,
Record (on Tools menu in other workspaces). This is a good option when the template will consist
primarily of standard SimXpert commands and tools. Macro recording creates a template file format
(*.proc) which can then be edited in Template Builder. See Recording a Macro section of this User Guide
for details on recording a macro.

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 4: Select a Location (directory) to save the macro.


Step 5: If it is desired to always execute the template in the current unit system, check the Record
current unit system box. Otherwise MKS (meters- kilograms- seconds) is assumed. Upon playback, the
current model units settings will be changed to MKS.
Step 6: Click Ok to begin recording.

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

• Picking from Model Browser


• Picking from input dialog lists (Object selection fields have a drop-down list to the right of the
selection field containing candidate objects that satisfy the input filters.)
• Picking using the legacy Pick Dialog. This dialog appears when you right-click in Menu area and
select Pick from the list. (The Pick Filters toolbar is supported, except as noted above.)
Objects may need to be manually selected during playback if one of the above picking methods is used.
26
Inserting objects in a template

Inserting objects in a template


Inserting
There are several different executable object types that can be placed into a template. Most commonly, a
template consists of actions, but it may also contain other SimXpert templates, embedded scripts and
embedded templates. In some cases the objects are present on the author’s local machine, and in other
cases they may be published templates and actions in SimManager.
The Template Builder toolboxes are used to locate the particular object type to insert in the template. Use
Search Tools feature to locate any template, action, or tool that exists in the default search paths of
SimXpert.
Once the item has been located and selected, click on the location in the graphics window to place the
object.

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.

Using existing Actions


Step 1: To link existing Core or Custom Actions into the new template, click on the Actions toolbox icon
to display the actions stored on the local machine. Action files (file extension *.act) currently on user’s
machine in certain default directories will be shown as tools or folders in the Actions toolbox.
Step 2: Select an Action from the toolbox or use Search Tools tool to locate an action.
27
Inserting objects in a template

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.

Using a Template within a Template


An existing template may be used as a component within another template.
Step 1: Select Templates toolbox to display all the Templates stored in certain default directories. Select
a Template from the list.

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

Using Embedded Templates


The Embedded Template control creates a new (blank) template within a template. This is similar to an
embedded script, but may incorporate additional complexity that is not possible in an action.
When the parent template is saved, by default the embedded template is not saved as a separate file, but
instead is wholly contained in the parent template. (However, the option to save the embedded template
as a separate file is available in the Properties dialog, Publish page.) An embedded template may not be
published to SimManager, except as part of its parent.
Step 1: From Controls toolbox, select Embedded Template to create a new template that will be
embedded in the current (parent) 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.

Using published objects from SimManager


If SimManager is configured, published templates and actions may be retrieved and linked into
templates. When executing a template containing instances of published actions and templates, a
connection to SimManager will be required.
Use Retrieve Template and Retrieve Resource on the Published toolbox for retrieving templates and
actions, respectively.
31
Inserting objects in a template

See Retrieve and insert into template in the SimManager Interface section for details.
See Retrieving from SimManager for details on the SimManager interface.

Using tools from Controls toolbox


Additional template objects may be added from the Controls toolbox. These include tools to add choice
(branching), loops, prompts, and file-open dialogs. The Search feature can be used to find the desired tool
using a text string match. See Controls toolbox.
32
Creating an Action

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

New Script Action


A new Custom Action may be created, which can then be inserted into the current template being edited.
The steps to create a new script action are briefly described below. Full details are found in Creating a
new script action.

Step 1: From Controls toolbox, select New Script 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

Creating an embedded template from existing actions


An Embedded Template can be created from two or more existing action instances in a template. This is
usually done to reduce the complexity of the display in a large template.
Step 1: Select the first action in the new embedded template.
Step 2: Holding the Ctrl key, select the last action in the sub-template.
Step 3: Right-click on one of the selected actions and select Create Embedded Template.

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

Simple Loop tool


A Simple Loop repeats a portion of a template until a certain integer “count” is reached. The number of
iterations is an Input to the simple loop action. It may come from a prior action’s output, or a prompt will
be made to input this value.
Step 1: From Controls toolbox, select 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 11: Click Ok to close the Properties dialog box.


Step 12: Finally check each Connection to be sure the outputs from each action in the loop are being
passed to the appropriate inputs of another action. (Right-click on a connection and select Properties.)
If the count input comes from a preceding action, make sure to establish the data connector.
43
For-Each Loop tool

For-Each Loop tool


The “For-Each” Loop tool is very similar to the Simple Loop. In this case the input to the loop is a List.
The loop is repeated for each item in the list. The output of the loop is the current item.
Step 1: From Controls toolbox, select For-Each Loop tool.

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 6: Click Ok to save and close the Properties dialog box.


44
For-Each Loop tool

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.

Step 7: Click Ok to save and close the Properties dialog box.


Step 8: Check all Connections, and parameters being passed from one loop action to another. Note that
one of the Loop inputs, operand1 or operand2, must be connected from an action inside the loop to the
While Loop action.
47
File tool

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 3: Double-click on the new FilePrompt action to open Properties page.


Step 4: On Properties page, enter a Name and Summary at the top.
Select options for the loop tool at upper right: Prompt for Inputs, Display, and Execution.
Step 5: In Value column, enter the appropriate values for each Property. For text entries, double-click in
the text box to edit.

• prompt - Message given to user during Template execution


• isReadonly - Check the box if the text box is read-only during template execution. User can
review, but not change the contents. For example, to force use of file Browse instead of allowing
user to type in the file name.
• Mode - Select from these possible modes:
Open - the specified file is to be opened
48
File tool

Save - when a file is to be saved to the specified file name.


Open Many - when multiple files are to be selected for opening
Folder - when a directory is to be input
• filter - Enter one or more strings to restrict file name to certain extensions, e.g. “*.xmt.”

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

Template Properties dialog box


The Template Properties dialog box is used to display and modify the attributes of the current template.
Double-click on a Template in the Model Browser to open the Properties window. Or Right-click and
select Properties from context menu. The Properties dialog box has four pages, indicated at the left side
of the panel.

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

Action Properties dialog box

Checking Action Properties


Before testing a template, the Properties for each object (actions, controls, etc.) should be reviewed and
modified as needed. Double-click on a linked action in the Model Browser or graphics window to open
the Action Properties dialog box. (Or, right-click on the linked action, and select Properties.)
The Properties dialog box opens on the Properties page by default.

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.

Each page is discussed in the sections that follow.

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

Enter a summary of the action. Not editable for linked action.

Prompt for Inputs


Different Prompting behavior may be selected:

• 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.

Show Connected Inputs


By default, an input parameter is hidden in the input dialog box during execution if it is connected to an
output parameter from a prior action. If, however, you wish to show the input and allow the user to
modify it, the Show Connected Inputs check box must be checked. (This is only available when Prompt
for Inputs is set to “At execution of Action.”)

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.

See Running a Template for details.


66
Context menus

Context menus

Template context menu


Right-click on a Template in the Model Browser or graphics window to access the template context
menu.

Create .csv file


Creates a *.csv file containing input parameters and default values. Used to set up Batch execution of
templates.

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.

Expand all / Collapse all


Expands any templates and actions that are currently collapsed. If the selected template is expanded, then
it is collapsed down to the template name.

Action context menu


Right-click on an action instance in the Templates portion of Model Browser or the graphics window
to access the action context menu.

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.

Tool context menu


Right-click on an instance of any of the tools from Controls toolbox (File, Prompt, etc.) in the Model
Browser or graphics window to access a context menu.

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.

Workspace Toolbox context menu


Right-click in a blank area of the graphics window to access the workspace toolbox context menu. This
is a convenient way to access the toolbox from anywhere in the template window.
.
71
Template Builder Options

Template Builder Options


To specify options for the Template Builder workspace, select Tools, Options from the menu bar.

This opens the User Options dialog box. Scroll down to Workspaces and expand Template Builder
Options.

The Template Builder Options consist of three pages:

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

Core Action library


SimXpert has a library of built-in Core Actions corresponding to commands and tools in the SimXpert
user interface. The Core Actions may be used in templates as described above, in Using existing Actions.
They may not, however, be edited.
Structures workspace tool:

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:

Level1 Level2 Level3 Actions toolbox navigation


File New AppFrame / File / New
File Open AppFrame/ File/ Open
File Save AppFrame/ File/ Save
File Save As AppFrame/ File/ Save As
File Import SimXpertDatabase, AppFrame/ File/ Import Database
Sofy database, Patran
File Import Import as Parasolid AppFrame/ File/ Import as Parasolid
File Import Parasolid, CATIA, AppFrame/ File/ Import Geometry
Pro/Engineer, UG NX
File Import Nastran AppFrame/ File/ Import Solver
File Import MCF, MWF, MWF- AppFrame / File / Import Connections
ANSA, MWF-UG
File Import SimXpertAssembly AppFrame/ File/ Import Database
File Export Parasolid, Iges Model AppFrame/ File/ Export Geometry
File Export Nastran Multiple AppFrame/ File/ Export Multiple
File Export Nastran Scene AppFrame / File / Export Solver
File Export User Scenes AppFrame / File / Export Solver
File Export MCF AppFrame / File / Export MCF
File Export MWF, MWF-ANSA, AppFrame / File / Export Connections
MWF-UG
File Attach Results Results Entities, Model Results / ResultFileTools /
Data, Both, Detach
File Print AppFrame / Misc / Print
76
Core Action library

Edit menu:

Level1 Level2 Level3 Actions toolbox navigation


Edit Delete AppFrame / Edit / Delete
Edit Visibility Show, Hide, etc. AppFrame / Edit / Set Object Visibility
Edit Move to Current AppFrame / Edit / Manage Entity
Selection Container
Edit Manage Group AppFrame / Edit / Manage Entity
Container
Edit Manage AppFrame / Edit / Manage Entity
SubAssembly Container
Edit Properties AppFrame / Edit / Properties
Edit Update Model AppFrame / Edit / Update Model

View menu

Level1 Level2 Level3 Actions toolbox navigation


View Display Fill, Zoom, Pan, Rotate AppFrame/View /Set View
View Render Geom Shaded w/ AppFrame/View / Render Modes
Edges
View Render FE... various AppFrame/View / Render Modes
View Render Edge color, etc. AppFrame/View / Render Modes
View Model Views (various) AppFrame/View / Set Named View
View Custom Views Create AppFrame/View / Add Named View
View Entity Display Geom, Elem’s, etc. AppFrame/View / Entity Display
View Clear Labels AppFrame/ Tools / Clear Labels

Tools menu

Level1 Level2 Level3 Actions toolbox navigation


Tools Part Rename Duplicates Actions / PartActions/ Rename Dups.
Tools Statistics AppFrame/ Tools
Tools Transform Rotate AppFrame/ Tools
Tools Scene Combined Mass AppFrame/ Tools / Scene Properties
Properties
Tools Options AppFrame/ Tools /Set Options
77
Core Action library

Geometry tool ribbon / toolbox:

Level1 Level2 Level3 Actions toolbox navigation


Construction Coord Cartesian Actions\LCSActions
Geom
Construction Coord Cylindrical Actions\LCSActions
Geom
Construction Coord Spherical Actions\LCSActions
Geom
Curve all tools Actions\GeometryActions
Surface Filler, Stitch, Loft, Actions\GeometryActions
etc.
Surface MidSurface Actions\MidSurface
Solid all tools Actions\GeometryActions and
Actions\SGMActions
Tools Cleanup Actions\GeometryActions

Meshing tool ribbon / toolbox

Level1 Level2 Level3 Actions toolbox navigation


Automesh all tools Actions\MeshActions
FEM based all tools Actions\MeshActions
Features all tools Actions\MeshActions
Edit all tools Actions\MeshActions
Misc most tools Actions\MeshActions
Misc Control Actions\GeometryActions

Quality tool ribbon / toolbox

Level1 Level2 Level3 Actions toolbox navigation


Plots all tools Actions\ElementActions
Checks all tools Actions\ElementActions
Edit / Fix all tools Actions\ElementActions
Elements
78
Core Action library

Nodes / Elements tool ribbon / toolbox

Level1 Level2 Level3 Actions toolbox navigation


Create Node, SPoint Actions\NodeActions
Modify all tools Actions\NodeActions
Elements all tools Actions\ElementCreateActions or
Actions\ElementActions
1D Elements all tools Actions\ElementCreateActions or
Actions\ElementActions

Materials and Properties tool ribbon / toolbox

Level1 Level2 Level3 Actions toolbox navigation


Material Modeling/StructMat or
Modeling/ThermMat
0D Properties Modeling/StructProp
1D Properties Modeling/StructProp
2D Properties Modeling/StructProp
3D Properties Modeling/StructProp

LBC’s tool ribbon / toolbox

Level1 Level2 Level3 Actions toolbox navigation


Constraints all tools Modeling\StructureLBC
Loads all tools Modeling\StructureLBC
Pressure all tools Modeling\StructureLBC
Heat Transfer all tools Modeling\StructureLBC
Initial all tools Modeling\StructureLBC
Conditions
Global all tools Modeling\StructureLBC
LBC Set LBC Set Modeling\StructureLBC
Contact all tools Modeling\StructureLBC

Tables tool ribbon / toolbox

Level1 Level2 Level3 Actions toolbox navigation


Tables all tools Modeling/Tables
79
Core Action library

Assemble tool ribbon

Level1 Level2 Level3 Actions toolbox navigation


Parts all tools Actions\PartActions
Group all tools Modeling\Group
Nastran Sets all tools Modeling\NastranSet
MPCs all tools Modeling\Joints
Rigid all tools Modeling\Connectors
Connectors
Interpolation all tools Modeling\Connectors
Flexible all tools Modeling\Connectors
Connectors
Joints all tools Modeling\Joints
Connector Utils all tools Modeling\Joints
Bolt all tools Actions\BoltModel
Connections all tools ConnectionRegistry

Results tool ribbon / toolbox

Level1 Level2 Level3 Actions toolbox navigation


Results most tools Results\StatePlotTools
Results Chart Charting and Results\ChartTools

Model Browser context menus (right-click)

Level1 Level2 Level3 Actions toolbox navigation


Statistics AppFrame\Tools
Custom AppFrame\Edit
Attributes
Properties AppFrame\Edit
80
Core Action library
81

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

From inside Template Builder


Once in the template editing mode, then use Controls toolbox to create a new 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.

Once a selection is made, an editing window appears.


85
Creating a new script action

Creating a new script action


Advanced users can create their own custom script actions. Knowledge of scripting in Python language
(or RADE) is required for creating scripts.The script consists of input and output definitions in XML
format, and script code, such as Python. After creating the new script action, it is saved as a *.act file that
will be available to insert into any Template.

Create New Action dialog box


Step 1: From the Controls toolbox, select New Script Action tool to create a new Custom Action.

Step 2: A Create New Action dialog box appears.

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

Creating a linked action


Multiple Templates may utilize the same Action. A linked action instance is created when an existing
Action is used in a template. The action instance in the template is linked to the original *.act file. The
code, inputs, and outputs are all defined in the *.act file and are the same for all instances of the action.
The display icon, Input default values and prompting behavior may, however, be set for each instance of
an action and this information will be stored in the Template containing the linked action instance.
See Using existing Actions for details.
88
Creating an embedded script

Creating an embedded script


A template may contain an embedded script, which is saved as part of the Template and will not appear
separately as an action in the Actions toolbox when the template is saved. Knowledge of scripting in
Python or RADE language is required for creating scripts. The script consists of input and output
parameter definitions and script code, such as Python. An embedded script is written in cases where re-
use of the script is not anticipated.

Insert Embedded Script into Template


In the Controls toolbox, select Embedded Script to insert a Custom Embedded Action into the current
Template being edited.

Click at the desired location in the Template Builder window to drop the new script icon into the
template.

Define Embedded Script Properties


Open the Properties dialog box by double-clicking on script in the Model Browser. The script Properties
panel opens.

Select the Properties page (default) from left side.


Provide a Name and Summary for the new embedded action.
Select the scriptType: Python, RADE, or Existing file.
By default, when the template containing the embedded script is saved, the embedded script is saved as
part of the template and not as a separate file. The option to save the embedded script as a separate action
file is available, however, and is found on the Publish page of the Properties panel.
See also: Action Properties dialog box
89
Creating an embedded script

Open embedded script editor


Click the Edit button to open the embedded script editor. (This can also be opened at any time by right-
clicking on the embedded script icon and selecting Edit from the context menu.)
This dialog box consists of a Data page, an Advanced page, and a Code page, selected using the tabs in
the lower left corner.

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.

For details, refer to the section on each page:


• Action editor - Data page
• Action editor - Advanced page
• Action editor - Layout page
• Action editor - Code page
93
Action editor - Data page

Action editor - Data page


The Data page of the Action editor can be accessed by selecting the Data tab at the bottom of the page.

It consists of three sections:


• Identification data about the action, such as name, and summary. See Action Data page -
Identification
• Publish section, where the local file path for saving the action is defined. The option to Publish a
script action to SimManager is also available. See Action Data page - Publish
• Parameters section for adding and removing input & output parameters. The user interfaces
for gathering inputs during template execution are also defined here. See Action Data page -
Parameters

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

Action Data page - Identification


The Identification portion of the Data page allows you to modify the name, label, and other information
about the action.
Label: Identifies the action in the graphics window and Model Browser. This is populated from the
Create New Action dialog box, but may be modified, if desired.
Name: Identifies the file name of the action (*.act extension will be added). This is populated from the
Create New Action dialog box, but may be modified, if desired. Modification of the Name field will
result in a new action file being created upon Save.
Summary: Add a brief summary of the action. This will be particularly useful if the action is to be
published and/or used by others.

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.

Action Data page - Publish


The Publish section of the Action editor is in the upper right corner of the Data page.

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.

Action Data page - Parameters


The Parameters portion of the Data page is used to create and edit inputs and outputs for the action.

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

Input Table view


The Input Table view presents the input parameters in a simple tabular view. Each row displays an input
parameter and its attributes. The following attributes are displayed by column: Name, Label, Type,
Default Value, Required, and Description. See Creating an Input Parameter for details on each attribute
shown in the Input Table.
These values can be edited directly by typing in the table fields. Click in any field and begin typing to
overwrite the entire contents. Or double-click in a field and place the cursor at the edit point to make
changes without overwriting. Or highlight portions of the contents to be replaced.

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.

Output Table view


The Output Table view is similar to the Input Table view, but “List” and “Report” attributes are added,
whereas “Default Value” and “Required” attributes are not present for outputs. Otherwise refer to Input
Table view for details on creating, moving, and editing parameters in the table.

See Also: Creating an Output Parameter.


98
Action editor - Data page

Parameter Details view - Input


When the Parameter Details view is selected, all the details of an input parameter (selected on the left
side) are displayed on right side of the page.
For an input parameter this view contains two or three tabs. For details on entering data on the Input,
Advanced, and Object tabs, which are summarized below. Please see Creating an Input Parameter for
more details.

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.

Parameter Details view - Output


When an output parameter is selected, the Parameter Details view is displayed as follows:
100
Action editor - Data page

For details on the entries on this page, please see Creating an Output Parameter.
101
Creating an Input Parameter

Creating an Input Parameter


An input parameter is created on the Data tab of the Action editing window.

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 9: Enter a Default value in the text box, as applicable.

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.

Allowable Pick Types


Step 17: If an Object Type was selected in Step 11, it will be pre-selected. To allow multiple Object types,
check the box for each valid object type in the Allowable Pick Types table.
A second check box will appear to the left of each checked box. Check the left box if you wish picking
of that object type to be activated by default during execution.
Click Allow All button to activate all Object types and place checks in each selection box.
Click Clear button to clear all check boxes and start over. Then re-select the allowable pick types.
107
Creating an Input Parameter

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.

Enable Contiguous pick mode


Step 20: If applicable, check the box for Enable Contiguous Pick mode, which will automatically turn
on contiguous picking for this parameter during action execution. This is useful for selecting adjacent
objects in a region or along an edge. For example, selecting all the nodes around a hole by picking only
one node.

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.”

Allow user to create new objects


Step 22: Check the “Allow user to create new objects” box if an action or template exists to create the
new object. Use the file Browse icon to locate the action (*.act) or template (*.proc) file in which the
new object is defined.
108
Creating an Output Parameter

Creating an Output Parameter


An output parameter is created on the Data tab of the Action editing window.

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.

Common Interface Properties


List
A List property is shown for most user interfaces, and is selected when the parameter is a list of values
or objects. When the action is using Python code, checking the List box will result in creation of a native
Python list. (When using RADE, you will get the SimXpert API object list functions.) To force use of
SimXpert API object list functions, this can be done on the Advanced tab at the bottom of the dialog. See
Action editor - Advanced page.)
112
Parameter Interface

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.
\

Line Style / Line Weight


Graphical chooser for line style and thickness.

Symbol Chooser
116
Parameter Interface

Presents a list of symbols for selection.

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.

Date & Time Chooser


Opens a dialog containing Date Chooser (above), and Time Chooser (above). Used to select an input
parameter that contains a date and 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.

See String Parameter for additional details.

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.

Drop List / List


These user interfaces are only available when Constraint is set to Discrete. Same as described in String
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.

Drop List / List


These user interfaces are same as shown in String Parameter. A true/ false option is presented in a drop
list or list.

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.

Drop List / List


These user interfaces are same as described in String Parameter.

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

Action editor - Advanced page


Select the Advanced tab at the bottom of the Action editor to modify the Action Options, add Meta Data,
or add detailed documentation.

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

• IsModifyingGeometry - Identifies the Action as modifying geometry.


• Shutdown History - Purges the undo history before execution of the Action
• Turn Off History - Disables undo history for this Action.

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.

The available options are as follows:


• Allow dynamic inputs - Turns on and off dynamic inputs. When on, allows simple undefined
inputs to be set at run time. (Outputs from other actions can be connected arbitrarily to the
Action.) The implementation must handle the getting and setting of the extra inputs.
• AutoExecute - When on, the action will automatically execute when pre-selection satisfies all
inputs.
126
Action editor - Advanced page

• 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

Action editor - Layout page


Select the Layout tab at bottom of the Action editor.

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

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

# Enter your code here

# # CODE FENCE BEGIN: Outputs


# # CODE FENCE END Outputs
Step 3: Notice the “Enter your code here” comment. This is where your python code is placed. Type
or copy / paste directly onto the Code page.
131
Action editor - Code page

Or click the Edit button to open Script Editor.

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

Editing an existing Action

Template Builder entry screen


When Template Builder is opened, the editing window has a list of options.

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.

Editing in Template Builder


Embedded Script
In Template Builder, open the template containing the embedded custom action. (File, Open). The
selected template opens in Template Builder and is seen in the graphics window and Model Browser.
• Locate the embedded script to be edited in the graphics window or Model Browser. Right-click
the embedded script action icon and select Edit... from the context menu.

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

Converting a script to an action


A Python or RADE script can be converted to a SimXpert Action. Python scripts typically have a file
extension of *.py.

Use existing script file as an embedded script


Step 1: Open the template for editing that will contain the embedded script.
Step 2: Select Controls toolbox, then Embedded Script.
Step 3: Double-click the embedded script icon to open Properties. Select scriptType as Existing File.

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.

Create an action by modifying existing script


This is preferred because it takes advantage of the new features of the Template Builder workspace,
including the new input user interfaces and data connections from one action to another.
Step 1: Open the existing script in the Script Editor (or any text editor) and keep the window open.
Step 2: Create a new Embedded Script or a New Script Action. Open the Properties panel. Enter the
file Name and Label for the action. (See Creating an Action.)
Step 3: Examine the code in the text editor window and identify the input variable names that you wish
to be supplied by the user or connected from a prior action. (In RADE, these may use OH / VH
statements).
Step 4: Go to the Data tab of Properties dialog and select Input Parameters from drop-list. Click Plus
(+) to add Inputs that exactly match the Name and Type of the inputs identified in Step 3. (See Creating
an Input Parameter.)

Step 5: Repeat for Outputs. (See Creating an Output Parameter.)


Step 6: Select the Code tab at bottom, and click Update button to add “Code Fence” sections for Inputs
and Outputs.
Step 7: Copy / Paste the Python or RADE code from the other window into the Code page, after the
“Code Fence (input)” statements. (See Action editor - Code page.)
136
Converting a script to an action

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

Using Script Editor

Script Editor window


The Script Editor tool is available in SimXpert for convenience of editing and running Python (*.py) and
RADE (*.rdl) scripts. To open Script Editor in any SimXpert workspace, click Tools menu, then Macro,
and Script Editor.
In addition to the menus and toolbars at the top of the window, the Script Editor window consists of three
regions:
1. Directory tree view - It shows the list of files in the selected directory and selected filter. Select
File > Open Directory Tree to show this. Right-click in the tree to access context menu & set filter.
2. Script Edit window - By default only this Script Edit window is shown initially. Each opened
file is displayed on a tab at the top. Select a tab to view and edit the contents of the file.
3. Debug Windows - Tabs to view and query information from the Python debugger. The Debug
windows are hidden by default but can be shown by right-clicking in the menu bar and selecting
Debug Windows. Not available for RADE scripts. See also: Debug windows.

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:

Directory tree context menu:

Script Editor Menus and Toolbars


File menu
The Script Editor has a set of file management and editing tools for scripts. The File menu has typical
New, Open, Close, Save and Save As commands for managing your script files. (*.py and *.rdl)
139
Using Script Editor

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.

These are discussed in Using the Python Debugger

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

Script Editor inside Action Editor


A limited Script Editor can be opened in Template Builder from Action editor by clicking Code tab, then
Edit button.

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

Using the Python Debugger


The Script Editor window has a built-in Python debugger, which is available only when the language
selected is Python. The debugger allows you to set breakpoints, pause, continue, step into functions, and
to monitor the value of variables during execution. To view a brief video on the Python Debugger, click
here.

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.

- Toggle Breakpoint - Add or Remove a breakpoint. It is also available in non-debug mode.


Usually you will want to add breakpoints prior to starting the debugger.

- Pause - Pauses the debugging.

- 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.

- Show Next Statement - Show the current execution point.

- Debug Full Screen - Toggle to full screen mode.

Debugging in script edit window


The script edit window shows Breakpoints in red highlights. The current execution point is highlighted
in yellow color. Bookmarks are indicated by shaded line numbers.
145
Using the Python Debugger

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

The tabs in the Debug window display the following information:

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

Python (and RADE) Scripting Tools


Depending on the preference and skill of the template author, there are different options for writing
Python (and RADE) scripts. Some knowledge of Python or RADE is required to create scripts, either as
actions or as stand-alone scripts.

Scripting in Action Editor


The Template Builder workspace can be used to create actions consisting of Python or RADE code. In
this case, the Action editor has many tools to assist the author. This is the recommended tool for new
scripts.
The creation of input and output parameters is facilitated using the Parameters section of the action
editing dialog. Using this tool, the name, type (string, real, etc.), and default values of parameters can be
specified. A flexible User Interface tool also allows the author to customize the UI for gathering inputs
from the user upon execution of the action. Creating parameters and their user interfaces does not require
any knowledge of Python or RADE. (See Action Data page - Parameters.)
The Code page provides access to a limited version of the Script Editor tool. Python or RADE code can
be typed directly into Script Editor, or copied and pasted from another window. (See Action editor - Code
page). See RADE Scripting Language or Python Scripting Language for scripting language details.

Scripting in other SimXpert workspaces


Script Editor
The Script Editor can be opened in any SimXpert workspace to create, edit, and test scripts in Python or
RADE code. (Go to Tools menu, Macros, Script Editor) However, actions may not be run stand-alone,
but must be part of a template. See Using Script Editor for more details.

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.

Invoking Scripts in SimXpert


There are several ways to invoke scripts in SimXpert.
• Using Script Editor: Saved scripts and Macros can be run from the Script Editor window. Go to
Tools > Macro > Script Editor to open the Script Editor.
Select script type (Python or RADE) from drop list. Use File, Open in Script Editor window to
locate and open the desired *.rdl, *.py or *.xml file containing the script.
Click the Run icon (green arrow) to begin execution. However a RADE script that was built in
Template Builder, as part of an action, may only be run in Template Execution window.
151
Python (and RADE) Scripting Tools

• 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

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.

Overview of Python Syntax


This is not a comprehensive documentation of Python syntax. Consult the Python Web site:
www.python.org, for complete documentation.

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.

Use of SimX API & RADE functions


All API available to RADE programmers via *.pkg files are also available to Python programmers.
RADE based global variables are not available explicitly to python. All RADE extensions of classes
(RADE-only methods) are not available explicitly to python.
Use an import statement at the top of the action code to call the appropriate RADE *.pkg file.

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).

SimXpert's Object (Class) Hierarchy


See Overview of RADE Syntax.

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

and else in try


as except is while
assert exec lambda with
break finally not yield
class for or
continue from pass
def global print
del if raise
elif import return

The reserved keywords cannot be used as names for variables, functions, or classes.
155
Python Syntax Details

Python Syntax Details


Importing Files
A script file, or module, containing python code can be imported.
import filename
Once imported, the functions contained in the imported file can be called:
filename.funct1(param1,param2)
To import only certain functions from a module:
from filename import funct1, funct2

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

== Check Equality Condition: works with numbers 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
is [not] Object identity (with not, negated object identity)
[not] in Membership test / negated membership test (Sequences only)

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 correct way to copy one python list to another


#
for i in range(len(py_list_in)):
py_list_out.append(py_list_in[i])
SX.ShowMsg('The output list copy is ' + str(py_list_out))
158
Python Syntax Details

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;

# The correct way: do a copy


len = strlist.length()
i=0
while i<len:
outstrlist.insert(strlist.at(i))
i = i + 1

# For ObjectList, use the AddLists API


SX.AddLists(objlist, outobjlist);

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

Python Tutorial 1 - Hello World


Hello World - This script sends the message “Hello World” to the Message window in the SimXpert
session (at bottom of screen) in three different colors.
Step 1: In the Script Editor window, open the file:
<SimXpert Installation>/help/PartFiles/scripts/Python/1-hello.py
OR Copy / Paste the text below into the Script Editor window:
#debug
import RIDL

##
# 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.

Python Tutorial 2 - Object Oriented Programming Concepts


This script shows some features of object oriented programming. It shows how to create classes in Python
and to define methods (member functions) of the class.
Step 1: In the Script Editor window, open the file:
<SimXpert Installation>/help/PartFiles/scripts/Python/2-oop-python.py
OR Copy / Paste the text below into the Script Editor window:
#
# * Object Oriented Programming concepts
# * - Data storage in objects
# * - Giving messages to objects to do something
# * - Default parameters handled by messages
#

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

__msg_ = 'default message'


__color__="Blue"
#
# Methods (functions) of the class
# All have self as a mandatory first argument.
#
# __****__ is usually a special class method.
# __init__ is a class constructor
#
def __init__(self,str='created CMessage instance', clr="Green"):
# displays a message upon creating an instance
SX.ShowMsg(str,clr);
#
# function that allows you to set the value of __msg_
def setMsg(self,str):
self.__msg_ = str
#
# function that returns the value of __msg_
def getMsg(self,str):
return self.__msg_
# function show uses the current value of variables __msg_
# and __color__ by default,
# but you can change the color by supplying it as an input
def show(self,color=__color__):
SX.ShowMsg(self.__msg_, color)
#
# A function that demonstrates some CMessage class methods
# Note: the indentation is moved left; it is not a method of CMessage
def Demonstrate_OOP():
# create an instance of CMessage class
# actually is using __init__ ; self argument is omitted
# since only one argument is given it is assumed as str
my_msg = CMessage("my_msg created")
# now call the show function; it uses __msg_ as the string
my_msg.show()
# now call the setMsg function; it can change the string
# but not the color
my_msg.setMsg("My Hello World")
my_msg.show()
my_msg.show("red")
my_msg.setMsg("a new message")
# use the return value of getMsg as input argument
# for ShowMsg (SimX API)
SX.ShowMsg(my_msg.getMsg(str),"black")
# creating another instance of CMessage with no arguments -
# uses defaults
obj1 = CMessage()
# using default parameter values for show
obj1.show()
# creating another instance of CMessage
obj2 = CMessage("obj2 created")
obj2.show("orange")
# note the following does not work for changing __msg_
obj2.__msg_="changed message"
162
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.

Python Tutorial 3 - List Handling


List Handling - This tutorial shows how to use the various SimXpert XXXList classes, using IntList as
an example. It also shows the how to create a native Python list of mixed data types.
Step 1: In the Script Editor window, open the file:
<SimXpert Installation>/help/PartFiles/scripts/Python/3-list.py
OR Copy / Paste the text below into the Script Editor window:
#debug
#
# Using Python to call SimXpert XXXList API's.
# Creating native python lists.
#
import SCA
import types
import RIDL
RIDL.loadModule("rader_ridl")
RIDL.loadModule("utils")

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.

Python Tutorial 4 - Menus


Creating menus - Create your own menu item in SimXpert that executes a Custom Action.The menu
item is named from the action’s label inside the *.act file.
Step 1: In the Script Editor window, open the file:
<SimXpert Installation>/help/PartFiles/scripts/Python/4-menu-action.py
OR Copy / Paste the text below into the Script Editor window:
#
# Adding menus to SIMX
#
# import some modules that are used in this script
import RIDL
RIDL.loadModule("rader_ridl")
RIDL.loadModule("gui")
#
#defining a new function
def AddMyMenu():
#
# getGuiHandle returns object of type CLexGuiModel.
# getTopMenu is member function of CLexGuiModel class,
# that returns the pointer of CLexGuiTopMenu (the top level menu)
# findChild is a member function of CLexGuiTopMenu class,
# that returns pointer of MenuItem
# This is a good example of use of "." as separator
# to call a member function
164
Python Tutorials

# of the returned object of the previous function call:


#
my_menu = SX.getGuiHandle().getTopMenu().findChild("My Menu Py");
#
# If the return of findChild is null, i.e. "My Menu Py" does not
# exist, a new top-level menu gets created
#
if(not my_menu):
my_menu = SX.TopMenuItem("My Menu Py")
#
# "action" is an instance of the CLexAction class
# (the return of createActionTool function)
#
action= SX.CLexToolbox.createActionTool(
"../../help/PartFiles/scripts/Python/_4_menu_ShowMsg.act")
# You can continue a long line by opening a ( or { or [
# then continue the statement & closing brackets on next line.
#
# After creating "action," you can call the member functions
# of class CLexAction, such as "addTo" as seen here:
action.addTo(my_menu);
# Finally, execute the function AddMyMenu:
AddMyMenu()

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.

Python Tutorial 5 - SimX Entity Creation


Entity - In this tutorial, you will create a rectangular grid of nodes.
Step 1: You will need to switch to the Structures workspace and clear the database (File > New).
Step 2: In the Script Editor window, open the file:
<SimXpert Installation>/help/PartFiles/scripts/Python/5-entity-create-nodes.py
OR Copy / Paste the text below into the Script Editor window:
import RIDL
RIDL.loadModule("rgen_ridl");
#
# This script can be run from Script Editor
# It creates a rectangular pattern of nodes
# Before running you can change the three variables below
#
165
Python Tutorials

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))

# Initialize the variables for the loop


i=0
j=0
x=0.0
y=0.0
z=0.0
# Loop to create nodes in x-dir until i reaches GridsX
for i in range(GridsX):
# nested loop to create nodes in y-dir
for j in range(GridsY):
# set coordinates of node
x = i * Size;
y = j * Size;
z = 0.0;
# create a node
SX.CLexNode(x, y, z)
# Fit the screen
SX.FillScreen()
# Redraw the graphics window
SX.drawAllCanvases()
SX.ShowMsg("New nodes created")

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.

Python Tutorial 6 - Picking with Object Helper


Picking - This script demonstrates entity picking using the Object Helper and deleting of objects. Note
that you could use the Action editor to set up a custom pick interface. But if you want to write the code
yourself, here is an example. It prompts the user to pick some nodes, then deletes the elements that are
attached to the selected nodes.
Step 1: Open any model containing some elements in the Structures Workspace.
Step 2: Open the file 6-picking-deleting.py in Script Editor. Or Copy / Paste the text below into the
Script Editor window:
import RIDL
RIDL.loadModule("rgen_ridl");
RIDL.loadModule('input_helper_ridl');
# defining a function named DeleteElements
def DeleteElements():
# Ask the user to pick nodes
# using the ObjectHelper class
166
Python Tutorials

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.

Python Tutorial 7 - Mesh


Mesh - This script meshes all surfaces in a model.
For this tutorial you will also need the a geometry file containing surfaces, such as piston.x_t, located in
the <SimXpert Installation>/help/PartFiles folder.
Step 1: Use File, Import, Parasolid to open the geometry file piston.x_t in the Structures Workspace.
Or you can use any model containing Surfaces.
Step 2: Open the file 7-mesh-surfs.py in Script Editor. Or Copy / Paste the text below into the Script
Editor window:
import RIDL
RIDL.loadModule("rgen_ridl");
RIDL.loadModule("ps_interface")
RIDL.loadModule("gui")
RIDL.loadModule("utils")
# define a function named MeshSurfaces
def MeshSurfaces():
# get the current scene
scene = SX.CLexSofyEnv.getCurrentScene();
# get the scenes surfaces
surfs = SX.SurfaceList();
scene.getSceneSurfaces(surfs);
# mesh the surfaces
len = surfs.length();
for i in range(len):
surfs.at(i).mesh();
SX.RADE_objcall("mesh","CLexSurface",surfs.at(i));
# detach the mesh from the geometry to do anything on the mesh
for i in range(len):
surfs.at(i).detachFemEntities();
SX.drawAllCanvases();
# finally execute the new function
MeshSurfaces()

Step 3: Run the script by clicking the Run icon in the Script Editor window. It should mesh all the
surfaces.

Python Tutorial 8 - Enquiry


Enquiry - This script demonstrates how to get information from a model. It prompts the user for a
warpage value, then highlights all elements above this value.
Step 1: In the Structures or Crash Workspace, open a model that contains some shell elements.
Step 2: Open the file 8-enquiry-warp-highlight.py in Script Editor. Or Copy / Paste the text below
into the Script Editor window:
168
Python Tutorials

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.

Python Tutorial 9 - Spreadsheet


Spreadsheet - This script demonstrates how to use the CLexSpreadsheet class to create a table of data.
Step 1: Open the file 9-spreadsheet.py in Script Editor. Or Copy / Paste the text below into the Script
Editor window

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.

Python Tutorial 10 - Read STL


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 the Script Editor window, open the file 10-read-stl-python.py. Or Copy / Paste the text
below into the Script Editor window:

# import some modules in order to access their functions


import RIDL
RIDL.loadModule("rgen_ridl");
# modules for regular expressions and strings
import re, string
#
def ReadSTL_CB():
# Create some CLexString objects to hold the file name, desired
extensions,
# working directory, etc.
fname = SX.CLexString();
pattern = SX.CLexString("{ *.stl *.rdl }");
workdir = SX.CLexString();
fstring = SX.CLexString("unnamed.stl");
# Present a file open dialog to the user
SX.GetFile(pattern,
"STL File Name: ?",fname,workdir,fstring,False);
if(fname.data() == "CANCEL" or fname.data() == ""):
SX.ShowWarningMsg("STL Read Attempt Cancelled !!");
return;
# passes the file name string to the function ReadSTL
ReadSTL(fname.data());
# function to parse the STL file, create nodes, then elements
def ReadSTL(file):
# Query the current model and get the current part
# If no part exists, create a part.
model = SX.CLexSofyEnv.getCurrentModel()
part = SX.CLexSofyEnv.getCurrentPart();
if(not part):
part = SX.CreatePart(model, "STL_PART");
SX.CLexSofyEnv.setCurrentPart(part);
171
Python Tutorials

# parse the stl file


SX.SoBusyCursor();
# Keywork - opens the file
stlFile = open(file,"r")
# create three sets of coordinates
p1 = SX.CLexWCoordinate();
p2 = SX.CLexWCoordinate();
p3 = SX.CLexWCoordinate();
# to count the number of elements created
cnt = 0;
a=[]
while True:
# Returns the whole line, & increment the file pointer
# to the next line
line = stlFile.readline()
line = line.strip()
if(not line):
break;
if (string.find(line.strip(),"outer loop")!= -1):
# read vertex 1
line = stlFile.readline()
# pattern searching using re module
# returns a MatchObject instance or None
m = re.search('vertex (\S+) (\S+) (\S+)',line)
# if m not null, creates a tuple of the above subgroups
if (m): a = m.groups()
if(a!=[]):
# converts string to float and from mm to m
v1= float(a[0])/1000.0
v2= float(a[1])/1000.0
v3= float(a[2])/1000.0
print str(v1)+"\t"+str(v2)+"\t"+str(v3)
# sets the values of the CLexWCoordinate object
p1.setValues(v1, v2, v3);
# read vertex 2
line = stlFile.readline()
m = re.search('vertex (\S+) (\S+) (\S+)',line)
if (m): a = m.groups()
if (a!=[]):
v1= float(a[0])/1000.0
v2= float(a[1])/1000.0
v3= float(a[2])/1000.0
print str(v1)+"\t"+str(v2)+"\t"+str(v3)
p2.setValues(v1, v2, v3);
# read vertex 3
line = stlFile.readline()
m = re.search('vertex (\S+) (\S+) (\S+)',line)
if (m): a = m.groups()
if (a!=[]):
#if(b != None):
v1= float(a[0])/1000.0
v2= float(a[1])/1000.0
v3= float(a[2])/1000.0
print str(v1)+"\t"+str(v2)+"\t"+str(v3)
172
Python Tutorials

p3.setValues(v1, v2, v3);


# create the three node objects from coordinates
n1 = SX.CLexNode(p1);
n2 = SX.CLexNode(p2);
n3 = SX.CLexNode(p3);
# creates the tria shell element
SX.CreateTria3ElementFromSofyName(
n1, n2, n3, part);
cnt = cnt +1
stlFile.close()
SX.ShowMsg("# Elements Created = " + str(cnt));
SX.ShowMsg("Done Reading STL File. Cleaning up ...");
# Merge coincident nodes
elems = part.getElementList();
nodes = SX.NodeList();
SX.getNodesFromElementList(elems, nodes);
SX.MergeCoincidentNodes(nodes, False, 0.0000001, True, False);
# delete unreferenced nodes
for i in range(int(nodes.length())):
SX.deleteObject(nodes.at(i));
SX.drawAllCanvases();
SX.UpdateCollectionList();
SX.FillScreen();
SX.IdleCursor();
# execute ReadSTL_CB function
ReadSTL_CB();
#
Step 4: Run the script by clicking the Run icon in the Script Editor window.
Step 5: When prompted for a file, select “sample.stl” or any valid *.stl file.
Step 6: Upon completion you should see a partial representation of a surface with triangular elements.
Step 7: Check the console window and notice the coordinates of each vertex were printed to the window
using the “print” statements.

Python Tutorial 11 - Graphics


Graphics - This script shows you how to create temporary graphics objects.
Step 1: Open the Structures or Crash Workspace and clear the database as needed (File > New).
Step 2: In Script Editor, open the file: 11-temp-graphics.py. Or Copy / Paste the text below into the
Script Editor window:

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

# Create a text label


textGraphics = SX.CLexTextGraphicsObject.new(
"Look here", 0, 0, 0.001 );
# get the scene, then get the highlighted objects
graphicsContainer = (
SX.CLexSofyEnv.getCurrentScene().getHighlightsGraphicsContainer())
# if you have a long line, open parenthesis; close on next line
#
# insert the three new objects into the
# list of hightlighted objects
graphicsContainer.insert(lineGraphics);
graphicsContainer.insert(axisGraphics);
graphicsContainer.insert(textGraphics);
# refresh the display
SX.FillScreen();
SX.drawAllCanvases();
#
# Execute the function
CreateTempGraphics_CB()

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.

Python Tutorial 12 - Graphs - 2D Bar Chart


Graphics - This script shows you how to create a 2D bar chart and to set features such as title, legend,
axis labels and their associated colors and sizes. These API calls are in the same family as those used
when you select Results > Chart from the tool ribbon
Step 1: Open the Structures or Crash Workspace and clear the database as needed (File > New).
Step 2: In Script Editor, open the file: 12-graph-bar.py. Or Copy / Paste the text below into the Script
Editor window:

import SCA
import types
import RIDL

SX.ShowMsg("Creating a bar chart from python")

RIDL.loadModule("rader_ridl")
RIDL.loadModule("charting_ridl")

workspace = SX.getGuiHandle().getWorkspace()

DataSet1 = (1.1, 3.4, 2.6)


DataSet2 = (0.9, 3.2, 2.2)
#===== create new chart; set title bar text ======================
chart = SX.CLexBarChart2D.new(workspace, '2D Bar Chart')
if chart:
174
Python Tutorials

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

# set subtitle color to cyan


chartSubtitleColor.setRGB (0, 255, 255)
#==== set legend ==============================================
if chartLegend:
chartLegend.setVisibility (True)
# locates legend at bottom center; other possible values:
# 1- top right, 2- top left, 3- top center,
# 4- bottom right, 5- bottom left
chartLegend.setPlacement (6) #mcs s/b enum
chartLegend.setInsideChart (False)
chartLegend.setBorder (True)
chartLegend.setFilled (True)
legendFont = chartLegend.getFont ()
legendBorderColor = chartLegend.getBorderColor ()
if legendBorderColor:
# set legend border to black
legendBorderColor.setRGB (0, 0, 0)
legendFillColor = chartLegend.getFillColor ()
if legendFillColor:
# set legend fill to grey
legendFillColor.setRGB (200, 200, 200)
#===== set data axis =========================================
if chartDataAxis:
chartDataAxis.setPlacement (1) #mcs s/b enum
chartDataAxis.setScale (1) #mcs s/b enum
# auto calculate the upper limit
chartDataAxis.setAutoUpper (True)
# set the lower limit to 0.0
chartDataAxis.setAutoLower (0)
chartDataAxis.setLowerLimit (0.0)
#dAxisLabelsFont = chartDataAxis.getLabelsFont ()
dAxisTitle = chartDataAxis.getTitle ()
if dAxisTitle:
dAxisTitle.setText ("Total Displacement (mm)")
dAxisTicColor = chartDataAxis.getTicColor ()
if dAxisTicColor:
dAxisTicColor.setRGB (255, 255, 0)
chartDataAxis.setPrimaryGridVisibility (True)
dAxisPrimaryGridColor = chartDataAxis.getPrimaryGridColor ()
if dAxisPrimaryGridColor:
# set primary grid lines to lime
dAxisPrimaryGridColor.setRGB (0, 255, 0)
chartDataAxis.setPrimaryGridLineStyle (2) # mcs s/b enum
chartDataAxis.setPrimaryGridLineWeight (2)
dAxisSecondayGridColor = chartDataAxis.getSecondaryGridColor ()
if dAxisSecondayGridColor:
# set secondary grid lines to yellow
dAxisSecondayGridColor.setRGB (255, 255, 0)
chartDataAxis.setSecondaryGridVisibility (True)
chartDataAxis.setSecondaryGridLineStyle (3) #mcs s/b enum
chartDataAxis.setSecondaryGridLineWeight (2)
dAxisLabelsColor = chartDataAxis.getLabelsColor ()
if dAxisLabelsColor:
# set data axis labels to dark green
176
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.

Python Tutorial 13 - Create Spline


Create Spline - This tutorial shows how to create geometry, in this case splines (smooth curves).
Step 1: Open any model containing locations, such as nodes, geometry points in the Stuctures
workspace.
Step 2: In Script Editor, open the file: 13-CreateSpline.py. Or Copy / Paste the text below into the
Script Editor window:
import RIDL
RIDL.loadModule("rgen_ridl");
RIDL.loadModule("psutils_ridl");
# define a function that creates a spline
def CreateSpline(coords):
SX.delete_all_states(); # Clearing all the marks
SX.note_and_name_state(); # Marks the parasolid at a level
#
smooth = True;
body = SX.PS_MakeWireBody(coords, smooth);
#
SX.note_and_name_state(); # Marks the parasolid at a level
SX.delete_all_states(); # Clearing all the marks
SX.drawAllCanvases();
# define a function that prompts user for locations
178
Python Tutorials

# then calls the above CreateSpline function


def CreateSpline_CB():
print "-----------------------"
while True:
coords = SX.CoordList()
# opens the pick dialog to pick locations
# user can pick any number of nodes (or points,
# location on curve, etc.)
SX.pickLocations(coords, 0, "Pick locations of the spline");
if(coords.isEmpty()):
return;
len = coords.length();
# prints the coordinates of each node to the console window
for i in range(len):
print "-----------------------"
print "X: " + str(coords.at(i).x())
print "Y: " + str(coords.at(i).y())
print "Z: " + str(coords.at(i).z())
# creates a smooth spline using the picked locations
CreateSpline(coords);
# execute the function CreateSpline_CB()
CreateSpline_CB();
#
Step 3: Run the script by clicking the Run icon in the Script Editor window.
Step 4: 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 5: 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 6: The pick panel will remain open if you wish to create additional splines. Click Done, then Exit
when finished.

Python Tutorial 14 - Point on Curve


Point on Curve - This script creates a node on the selected curve that is at the mid-point. Object Helper
is used to pick the curve.
Step 1: In the Structures workspace, open a geometry file or SimXpert database that contains curves.
Step 2: In Script Editor, open the file: 14-PointOnCurve.py. Or Copy / Paste the text below into the
Script Editor window:
import RIDL
RIDL.loadModule("rgen_ridl");
RIDL.loadModule("input_helper_ridl");

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);

# curve is made up of edges


edges = curve.getEdgeList();
len = edges.length();
pos = SX.CLexWCoordinate();
tangent = SX.CLexWCoordinate();
graphicsContainer =
SX.CLexSofyEnv.getCurrentScene().getHighlightsGraphicsContainer();
for i in range(int(len)):
edge = edges.at(i);
ret, start, end = 0, 0.0, 0.0;
print str(start)+"\t"+str(end);
(ret, start, end, dummy) = edge.getRange(start, end);
param = (start + end) / 2.0;
edge.eval_tangent(param, pos, tangent);
SX.CLexNode(pos);
axisGraphics = SX.CLexArrowGraphicsObject(pos.x(), pos.y(),
pos.z(), tangent.x(), tangent.y(), tangent.z(), 0.010);
graphicsContainer.insert(axisGraphics);

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

Python Tutorial 15 - Complex Picking


Complex Picking- Demonstrates complex picking and adding options to Pick window.
Step 1: Open a finite element model in the Structures or Crash Workspace.
Step 2: In Script Editor, open the file: 15-complex-picking.py. Or Type or Copy / Paste the text below
into the Script Editor window:
import RIDL
RIDL.loadModule("rgen_ridl")
RIDL.loadModule("input_helper_ridl")
# RIDL.loadModule("pick_ridl")
#
# Demonstrates complex picking (pick dialog functionality)
# - Deletes elements connected to picked node
# - hence shows "how to automatically add elements to the pick" when
node was picked
#
# define a function that gets elements attached to the last picked
node and highlights them
def DelElemsProcessFunc(pp):
if(pp.isEmpty()):
return
node = pp.last()
SX.cast(node, "CLexNode")
# Get elements connected to the node
elems = SX.ElementList.new()
#mortal(elems);
SX.ShowMsg(node.getAppId())
node.getConnectedElements(elems)
if(elems.isEmpty()):
SX.ShowErrorMsg("No Elements Connected to Picked Node !!")
SX.CLexPickDialog.resetPickLists()
return
# Add these elements to pick
# Rejects the node that was picked.
SX.CLexPickDialog.rejectLast()
i=0
len = elems.length();
for i in range(len):
#Highlights the elements screen also.
SX.CLexPickDialog.insertPickedObject(elems[i])
SX.CLexPickDialog.getNumPickedList().insert(len)
#CLexPickDialog.resetPickLists()
#deleteObjects(elems)
def DelElemsDoneFunc(pp):
# Something has to be picked
if(pp.isEmpty()):
SX.ShowErrorMsg("No Elements to Delete !!");
SX.CLexPickDialog.resetPickLists();
return
# Get the elements
elems = SX.ElementList.new(pp.length());
#mortal(elems);
181
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();

# Delete the elements & nodes(if option is enabled)


nodes = SX.NodeList.new()
#mortal(nodes);
if(SX.CLexPickDialog.isChoiceEnabled()):
SX.getNodesFromElementList(elems, nodes);
SX.deleteObjects(elems);
SX.deleteObjects(nodes);
#CLexHistory.NoteAndNameState("Delete Elements");
SX.drawAllCanvases();
def AddElemsToPick_CB(pp):
if(pp.isEmpty()):
return

# 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);

# Remove already picked elements from the pick dialog


SX.CLexPickDialog.resetPickLists();
# Add these elements to pick
i=0
len = elems.length();
for i in range(len):
SX.CLexPickDialog.insertPickedObject(elems[i]);
SX.CLexPickDialog.getNumPickedList().insert(len);

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

SX.CLexPickDialog.manageChoice(False, "Delete Nodes Also", "Delete


Nodes Also");
#
SX.CLexPickDialog.setExtraRejectLastFunction("CLexPickDialog_GenericH
istoryRejectLast");
#
SX.CLexPickDialog.setExtraExitFunction("CLexPickDialog_GenericHistory
Exit");
# SX.CLexPickDialog.:setExtraExitFunction("");
SX.CLexPickDialog.setAnyFunction("AddElemsToPick_CB","+");
SX.CLexPickDialog.manageEvents();
SX.ShowMsg("Pick a Node whose connected elements will be deleted");
#
ComplexPicking_CB()

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.

Python Tutorial 16 - Writing efficient Python code


In this tutorial we will discuss several code samples that demonstrate how to make your programs run
faster. You can find these in the included sample file 16_Python_Faster_Code.py. This script cannot be
run as-is, but provides several examples you can use to write more efficient code.
• Checking code speed:

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)
#

• Looping through Lists:

Here are some suggestions on making loops more efficient.


#-----------------------------------------------------------
#SLOW:
for i in range(nodes.length()):
etc....
#
#FAST:
len = nodes.length();
for i in range(len):
etc...
#-----------------------------------------------------------
#
#-----------------------------------------------------------
#SLOW:
for... :
vec = SX.CLexWCoordinate();
#
#FAST:
# lot of performace gain with this
vec = SX.CLexWCoordinate();
for... :
vec.setValues(x, y, z);
#-----------------------------------------------------------
#
#-----------------------------------------------------------
#SLOW:
for... :
nodes = SX.NodeList();
#
#FAST:
# significant performace gain with this
#(creating a new node list every time you enter a for loop is avoided)
nodes = SX.NodeList();
for... :
nodes.clear();
SX.getNodesFrom...
#-----------------------------------------------------------
#
#-----------------------------------------------------------
#SLOW:
nodes = SX.NodeList();
for... :
nodes.insert(n);
#
184
Python Tutorials

#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);
#-----------------------------------------------------------

• Checking a list for contents


#-----------------------------------------------------------
#SLOW:
if(nodes.contains()):
...
#
#FAST:
Use nodes.at(i).getFlag1 & setFlag1 logic instead
#-----------------------------------------------------------
#

• 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 !
#---------------------------------------------------------

Python Tutorial 17 - Model name and node count template


In this tutorial you will create simple Action in Template Builder. The action includes a Python script
that gets the current model and node count, using function calls from the SimXpert API. The new script
action is saved as an Action file (*.act) which is then used in a SimXpert Template.
Step 1: Open Template Builder workspace and select New Template from entry screen.
Step 2: Double-click on the new template in Model Browser (It will be auto-assigned a name, such as
Template1.) In Properties panel, rename the template as Model_Nodes.
185
Python Tutorials

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

# CODE FENCE BEGIN: Outputs


186
Python Tutorials

outputs.setDouble("NodeCount", NodeCount);
# CODE FENCE END: Outputs

Step 9: Close Script Editor (if open).


Step 10: Return to Data page and click Save button to save the Action.
Step 11: In the Model Browser, return to the Model_Nodes template where you started. It is still empty.
Step 12: Click Actions toolbox and Browse to the location of the model_node_count.act file just
created. Select it and click anywhere in the window to create an instance of it.
Step 13: Click the Save icon.
Step 14: Switch to another workspace, e.g. Structures, and open any model that contains nodes.
Step 15: From the Templates tool ribbon, select Browse... and locate the saved template,
Model_Nodes.proc and select it to open Template Execution window.
Step 16: Click Run button to execute the template. You should see Messages stating the current model
name and the node count.
Step 17: The node count value should also be shown in an Execution Report window that opens upon
completion of the template.
187
RADE Scripting Language

RADE Scripting Language

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.

Overview of RADE Syntax


The syntax of RADE is similar to that of C++. Code statements to be executed may be 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:
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;
}

SimXpert's Object (Class) Hierarchy


SimXpert's core API deals with Objects (e.g. A node object). There are various Base Classes defined in
SimXpert. Each of these Base classes may have “child” members and functions which inherit the
characteristics of the base class. For example, CLexFemObject is a child of CLexObject. The Inheritance
Diagram of the CLexFemObject is shown for reference.

Some of the SimXpert base classes are mentioned below:


CLexGraphicsObject
CLexSolverCard
189
RADE Scripting Language

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

RADE Syntax Details


Pre Processor Controls
All preprocessor pragmas start with # symbol
#debug: turns debugging on
#nodebug: turns debugging off
#ifdef: condition starts a conditional ifdef pragma - if cond is false this part is skipped
#ifndef: condition starts a conditional ifdef pragma. If cond is true this part is skipped
#else: starts a conditional else pragma
#endif: ends a conditional else pragma
#endinput: ends the lexical parsing of the file
The condition may be:
0 - always false
1 - always true

Including (Processing) Files


Specifying including or processing (executing) a file is exactly the same:
include("path/filename")
process_file("path/filename")
Search path rules for the “include files”:
#path name: inserts a directory into path for file searched during execution of process file
commands.
clearpaths(): Clears the search path stack.
path("Path_Name"): Rade Function to add a path where "Path_Name" is a string variable
or a string constant.

Control Blocks
Syntax for the various RADE control blocks are as follows:
function func_name() { blocks }

if (condition expressions) { block }

if (condition expression)

{ block } else (or elseif) { block } end

while (condition) { block }


192
RADE Syntax Details

do { block } // can be used for local scoping

repeat
{ block } until (condition)

for(exp1; exp2; exp3)


{ block }

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

+ Addition or String Concatenation


- Subtraction
* Multiplication
/ Division
^ Power
= Assignment
++ Increment Operator (As Suffix Only)
-- Decrement Operator (As Suffix Only)
+= Adds the right hand side to the left hand side
-= Subtracts the right hand side from the left hand side
*= Multiplies the right hand side to the left hand side
/= Divides the left hand side by the right hand side

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

local a = {}; a[1] = "v1"; a[2] = "v2"; a[3] = 34

local a = {[f(k)]=g(y), x=1, y=3, [0] = b+c} is same as:

local a = {}; a[f(k)] = g(y); a["x"] = 1; a["y"] = 3; a[0] = b+c

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

%x - represents all hexa-decimal digits


%x - (where x is any non alphanumeric character) - represents the character x.
Escaping the magic characters ()%.[]*-?. - should be preceded by a %.
Example: read vertex 1 from an STL file
If line = "vertex 708.546021 -975.411987 720.219971"
b, e, v1, v2, v3 = strstr(line,"^%s*vertex%s+(%S+)%s+(%S+)%s+(%S+)");
will return b as non-null and vertices in v1, v2, v3

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

RADE Tutorial 1 - Hello World


Hello World - This script sends the message “Hello World” to the Message window in the SimXpert
session (at bottom of screen) in three different colors.
Step 1: In the Script Editor window, open the file:
<SimXpert Installation>/help/PartFiles/scripts/RADE/1-hello.rdl
OR Copy / Paste the text below into the Script Editor window:
#debug

/*
* 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.

RADE Tutorial 2 - Object Oriented Programming Concepts


OOP - Shows some features of object oriented programming.
Step 1: In the Script Editor window, open the file:
<SimXpert Installation>/help/PartFiles/scripts/RADE/2-oop.rdl
OR Copy / Paste the text below into the Script Editor window:
/*
* Object Oriented Programming concepts
* - Data storage in objects
* - Giving messages to objects to do something
* - Default parameters handled by messages
*/

#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:new(str, clr)


{
//ShowMsg("New Called ...");
local lm = {
msg_ = str,
color_ = clr,
}
instance(lm, CMessage);
return lm;
}
function CMessage:delete()
{
//ShowMsg("Delete Called");
//this.node_:delete();
}
function CMessage:setMsg(str)
{
// "this" gets the handle on the current class
// (in this case CMessage)
this.msg_ = str;
}

function CMessage:getMsg(str)
{
return this.msg_;
}

// handles default parameter


function CMessage:show(color)
{
ShowMsg(this.msg_, color);
}

function Demonstrate_OOP()
{
local my_msg = CMessage:new("Hello MSC");
my_msg:show();
my_msg.msg_ = "xxxxxxxxx";
my_msg:show("red");
my_msg:delete();

local obj2 = CMessage:new("Hello World !!!!!");


obj2:show();
obj2: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.

RADE Tutorial 3 - List Handling


List Handling - This tutorial shows how to use the various SimXpert XXXList classes, using IntList as
an example. It also shows the general RADE Table data type, which can contain mixed data types.
Step 1: In the Script Editor window, open the file:
<SimXpert Installation>/help/PartFiles/scripts/RADE/3-list.rdl
OR Copy / Paste the text below into the Script Editor window:
/*
* List handling in RADE. LIST is the ARRAY equivalent in most of the
* other programming languages
*/

function ListBasics_CB()
{
local i;

// instantiate a list. Below is a integer list (IntList)


// from SimX API.
// Similarly you can have ElementList, NodeList, etc.//
local list = IntList:new(); mortal(list);

// insert some items in the list


list:insert(0);
list:insert(3);
list:insert(5);
list:insert(10);
// now list(0)=0, list(1)=3, list(2)=5, list(3)=10
//
// loop through the list
for(i=0; i<list:length(); i++) {
// Print each member of the list
print(list[i]);
ShowMsg( "list [" + i + "] = " + list[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

local len = length(table);


for(i=0; i<=len; i++) {
print(table[i]);
ShowMsg( "table [" + i + "] = " + table[i] );
}
}
// now execute the function ListBasics_CB
ListBasics_CB();

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.

Tip: Copying of a list cannot be done by simply assigning variables, as in:


list_out = list_in;
It is necessary to loop through the list and copy each item in the list, as shown in the example below:
// Do not simply assign list variables...
// outstrlist = strlist;
// outobjlist = objlist;

// The correct way: do a copy


local len = strlist:length();
local i=0;
for (; i<len; i++) {
outstrlist:insert(strlist:at(i));
}

// For ObjectList, use the AddLists API


AddLists(objlist, outobjlist);

RADE Tutorial 4 - Menus


Creating menus- Create your own menu item in SimXpert and assign to your own function.
Step 1: In the Script Editor window, open the file:
<SimXpert Installation>/help/PartFiles/scripts/RADE/4-menu.rdl
OR Copy / Paste the text below into the Script Editor window:
/*
* Adding menus to SimXpert
*/
#debug

// define a simple function that uses the ShowMsg API call.


function ShowMessage_CB()
{
ShowMsg("My First Button", "Blue");
}
/* define a function that creates a menu and adds a push button
203
RADE Tutorials

* 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.

RADE Tutorial 5 - SimX Entity Creation


Entity - In this tutorial, create some nodes, and then some shell elements.
Step 1: You will need to switch to Structures workspace first and clear the database (File > New).
Step 2: In the Script Editor window, open the file:
<SimXpert Installation>/help/PartFiles/scripts/RADE/5-entity.rdl
OR Copy / Paste the text below into the Script Editor window:
/*
* Defines 3 functions
* 1. Creates a node grid
* 2. Asks the user to pick 4 nodes and creates an element.
* 3. Creates a menu with the 2 above functions
* Please note that CLexSofyEnv is the basic class in SimXpert from
* where you can start digging information about the model
*/

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

// If user unit is mm, nodes will be 10mm apart.


x = i * 10/1000;
y = j * 10/1000;
z = 0.0;
CLexNode:new(x, y, z);
}
}
}

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;
}

// Element has to go in some part. Try to get the current part.


// if there is no current part, create a part "MyPart"
local part = CLexSofyEnv:getCurrentPart();
if(not part) {
local model = CLexSofyEnv:getCurrentModel();
part = CreatePart(model, "MyPart");
CLexSofyEnv:setCurrentPart(part);
}

// Create an element from the picked nodes


// Need to Create a Shell element
// CLexElement - CLexShellElement - CLexQuad4Element -
// Member Function.
local elem = CreateQuad4ElementFromSofyName(nodes[0], nodes[1],
nodes[2], nodes[3], part);

UpdateCollectionList();
drawAllCanvases();
}

function AddEntitiesMenu()
{
local my_menu = gui:getTopMenu():findChild("My Menu");
if(not my_menu) {
my_menu = TopMenuItem:new("My Menu");
}

local pulldown = my_menu:findChild("Create Entities");


if(not pulldown) {
local pulldown = PullDownMenu:new(my_menu, "Create Entities");
PushButtonItem:new(pulldown, "Nodes", "CreateNodeGrid_CB");
PushButtonItem:new(pulldown, "Elements", "CreateElements_CB");
}
}
205
RADE Tutorials

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.

RADE Tutorial 6 - Picking


Picking - This script demonstrates entity picking.
Step 1: You will need to switch to Structures workspace first and open any file containing nodes and
elements.
Step 2: In the Script Editor window, open the file 6-picking.rdl.
OR Copy / Paste the text below into the Script Editor window:
/*
* Demonstrates simple entity picking
* Deletes elements connected to picked node and the node itself
*/

#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);
}

//local nodenn = CLexNodeNN:new(nodes);


//local nearest = nodesnn:nn(loc);

// following is a classic example of


// getting entities from entities
// with getXXXFromYYY functions
// you can almost achieve any entity enquiry
local elements = ElementList:new(); mortal(elements);
getElementsFromNodeList(nodes, elements);

// SimXpert's entity deletion


deleteObjects(elements);
206
RADE Tutorials

deleteObjects(nodes);

// update the canvas


drawAllCanvases();
}
// Add Picking to My Menu - assign to DeleteElements_CB function
function AddPickingMenu()
{
local my_menu = gui:getTopMenu():findChild("My Menu");
if(not my_menu) {
my_menu = TopMenuItem:new("My Menu");
}

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.

RADE Tutorial 7 - Mesh


Mesh - This script meshes all surfaces in a model.
For this tutorial you will also need the a geometry file containing surfaces, such as piston.x_t, located in
the <SimXpert Installation>/help/PartFiles folder.
Step 1: You will need to switch to Structures workspace first and clear the database (File > New).
Step 2: Use File, Import, Parasolid to open the geometry file piston.x_t in the Structures Workspace.
Or you can use any model containing Surfaces.
Step 3: In the Script Editor window, open the file:
<SimXpert Installation>/help/PartFiles/scripts/RADE/7-mesh.rdl
OR Copy / Paste the text below into the Script Editor window:
/*
* - Load Bracket.igs or any model with surfaces
* - Stitch all
* - Script gets the surfaces from the current scene & meshes them
*/

function MeshSurfaces_CB()
{
// get the current scene
207
RADE Tutorials

local scene = CLexSofyEnv:getCurrentScene();

// get the scene surfaces


local surfs = SurfaceList:new(); mortal(surfs);
scene:getSceneSurfaces(surfs);

// mesh the surfaces


local i, len = 0, surfs:length();
for(i=0; i<len; i++) {
surfs[i]:mesh();
}

// detach the mesh from the geometry to do anything on the mesh


for(i=0; i<len; i++) {
surfs[i]:detachFemEntities();
}

drawAllCanvases();
}
function AddMeshMenu()
{
// looks for top menu named My Menu
// and if not existing creates it

local my_menu = gui:getTopMenu():findChild("My Menu");


if(not my_menu) {
my_menu = TopMenuItem:new("My Menu");
}

// 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.

RADE Tutorial 8 - Enquiry


Enquiry - This script demonstrates how to get information from a model.
Step 1: In the Structures or Crash Workspace, open a model that contains some shell elements.
208
RADE Tutorials

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();

// get all shell elements in the model


local shells = ElementList:new(); mortal(shells);
model:getElements(shells, __CLEXELEMENT, SHELL, "", True, True);

// get warpage from the user


local str = CLexString:new(); mortal(str);
GetString("Enter Min. Warpage", str);
if (str:data() == "" || str:data() == "CANCEL") {
return;
}
local warpage = tonumber(str:data());

ShowMsg("Min. warpage --> " + warpage);

// now loop through the elements and check their warpages


local i, len = 0, shells:length();
for(i=0; i<len; i++) {
local elem = shells[i];
cast(elem, "CLexShellElement");
// Cast down to a child object to access it functions,
// in this case, cast from CLexElement to CLexShellElement
//
// If warpage is above the specified level, highlight element
print("Element Type is:", ttype(elem));
if(elem:warpage() > warpage) {
HighlightEntity(elem);
}
}
}

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.

RADE Tutorial 9 - Spreadsheet


Spreadsheet - This tutorial shows how to create a dialog box table (spreadsheet) and how to populate it
with model objects and push-buttons.
Step 1: In the Structures or Crash Workspace open a model that contains at least one Part and some shell
elements.
Step 2: In Script Editor, open the file: 9-spreadsheet.rdl. Or Copy / Paste the text below into the Script
Editor window:
//
#debug
// Part Info Viewer (& Editor)

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

// Get file to be read from user


local pattern = CLexString:new("{ *.nas *.bdf *.dat }");
mortal(pattern);
local workDir = CLexString:new(); mortal(workDir);
local fileString = CLexString:new(); mortal(fileString);
local selectedFileName = CLexString:new();
mortal(selectedFileName);
GetFile(pattern, "Get Some File ?",selectedFileName,
workDir,fileString,0);
if(selectedFileName:data() == "CANCEL" or
selectedFileName:data() == "") {
ShowMsg("Cancelled");
return;
}
local ss = pb.ss;
ss:setCell(3, 0, selectedFileName:data());
// store the selected file
ss.selectedFile = ss:getCell(3, 0);
}
function PartInfoSpreadSheet(part)
{
// Creates the spreadsheet with 4 rows and 2 cols.
local ss = CLexSpreadSheet:new("Part Info Viewer");
ss:setNumRows(4);
ss:setRowLabels(4, { "Name", "Thickness", "Demo Combo", "Push
Button" } );
ss:setNumColumns(2);
// Add Apply button which executes PartInfoApplyCB
ss:addActionButton("Apply", "PartInfoApplyCB");
// set the function to be executed upon pressing Exit button
ss:setExitCB("PartInfoExitCB");
ss:createGraphics();

//How to create a drop-down list


local cb = ComboBoxItem:new(ss, "PartInfoCombo",
"PartInfoComboCB");
cb:addItem("A");
cb:addItem("B");

// Create a push button which executes BrowseCB function


local pb = PushButtonItem:new(ss, "Browse...", "BrowseCB");
pb.ss = ss;
// attaching ss to pb so that it can be accessed from the
// BrowseCb callback

ss:setCell(0, 0, part:getName());
ss:setCell(1, 0, part:thickness());
ss:setCellWidget(2, 0, cb);
ss:setCellWidget(3, 1, pb);

ss.selectedFile = "Not Selected Anything";

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.

RADE Tutorial 10 - Read STL


212
RADE Tutorials

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

part = CreatePart(model, "STL_PART");


CLexSofyEnv:setCurrentPart(part);
}
// parse the stl file
SoBusyCursor();
readfrom(file); // Keywork - opens the file
local line, b, e, v1, v2, v3, n1, n2, n3;
// create three sets of coordinates
local p1 = CLexWCoordinate:new(); mortal(p1);
local p2 = CLexWCoordinate:new(); mortal(p2);
local p3 = CLexWCoordinate:new(); mortal(p3);
// count how many elements get created
local cnt = 0;
while(1) {
line = read("*l");
// Returns the whole line,& increment the
// file pointer to the next line
if(not line) { break; }
b, e = strstr(line, "^%s*outer%s+loop");
//b = found or not; e: column location
if(b != NULL) {
// read vertex 1
// looks for strings separated by spaces
line = read("*l");
b, e, v1, v2, v3 =
strstr(line,"^%s*vertex%s+(%S+)%s+(%S+)%s+(%S+)");
if(b != NULL) {
p1:setValues(v1, v2, v3);
p1 = p1 / 1000.0;
// mm -> m
// read vertex 2
line = read("*l");
b, e, v1, v2, v3 = strstr(line,
"^%s*vertex%s+(%S+)%s+(%S+)%s+(%S+)");
if(b != NULL) {
p2:setValues(v1, v2, v3);
p2 = p2 / 1000.0;// mm -> m
// read vertex 3
line = read("*l");
b, e, v1, v2, v3 = strstr(line,
"^%s*vertex%s+(%S+)%s+(%S+)%s+(%S+)");
if(b != NULL) {
p3:setValues(v1, v2, v3);
// mm -> m
p3 = p3 / 1000.0;
// create the three node objects
n1 = CLexNode:new(p1);
n2 = CLexNode:new(p2);
n3 = CLexNode:new(p3);
// create a triangular shell element
CreateTria3ElementFromSofyName(n1, n2, n3, part);
cnt++;
}
}
214
RADE Tutorials

}
}
}
ShowMsg("# Elements Created = " + cnt);
ShowMsg("Done Reading STL File. Cleaning up ...");

// Merge coincident nodes


local elems = part:getElementList();
local nodes = NodeList:new(); mortal(nodes);
getNodesFromElementList(elems, nodes);
MergeCoincidentNodes(nodes, False, 0.0000001, True, False);

// delete unreferenced nodes


deleteObjects(nodes);

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.

RADE Tutorial 11 - Graphics


Graphics - This script shows you how to create temporary graphics objects.
Step 1: Open the Structures or Crash Workspace and clear the database, as needed. (File > New)
Step 2: In Script Editor, open the file: 11-temp-graphics.rdl. Or Copy / Paste the text below into the
Script Editor window:
/*
* Temporary graphics object creation
215
RADE Tutorials

*/
#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);

// Create a text label


local textGraphics = CLexTextGraphicsObject:new(
"Look here", 0, 0, 0.001 );
//
// get the scene, then get the highlighted objects
local graphicsContainer =
CLexSofyEnv:getCurrentScene():getHighlightsGraphicsContainer();
// insert the three new objects into the
// list of hightlighted objects
graphicsContainer:insert(lineGraphics);
graphicsContainer:insert(axisGraphics);
graphicsContainer:insert(textGraphics);
FillScreen();
drawAllCanvases();
}

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.

RADE Tutorial 12 - Grapher


216
RADE Tutorials

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

local x_data = DoubleList:new(2); mortal(x_data);


local y_data = DoubleList:new(2); mortal(y_data);
x_data:insert(0.0); y_data:insert(0.0);
x_data:insert(1.0); y_data:insert(1.0);

local curve = canvas:addCurve("Curve 1");


curve:addPoints(x_data, y_data);

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.

RADE Tutorial 13 - Create Spline


Create Spline - This tutorial shows how to create geometry, in this case splines (smooth curves).
Step 1: Open any model containing locations, such as nodes or geometry points in the Stuctures
workspace.
Step 2: In Script Editor, open the file: 13-create-spline.rdl. Or Copy / Paste the text below into the
Script Editor window:
// use of Parasolid
function CreateSpline(coords)
{
delete_all_states(); // Clearing all the marks
note_and_name_state(); // Marks the parasolid at a level

local smooth = True;


local body = PS_MakeWireBody(coords, smooth);

note_and_name_state(); // Marks the parasolid at a level


delete_all_states(); // Clearing all the marks
drawAllCanvases();
}

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");
}

if(not my_menu:findChild("Create Spline")) {


local pb = PushButtonItem:new(my_menu, "Create Spline",
"CreateSplineCB");
}
}
AddSplineMenu();

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.

RADE Tutorial 14 - Point on Curve


Point on Curve - Creates a node on the selected curve that is at the mid-point.
Step 1: Open a geometry file or SimXpert database that contains curves in the Structures workspace.
Step 2: In Script Editor, open the file: 14-point-on-curve.rdl. Or Copy / Paste the text below into the
Script Editor window:
// define a function
function CurveExampleCB()
{
// create a CurveList object
local curves = CurveList:new(); mortal(curves);
// open pick dialog and prompt user to pick curves
pickCurves(curves, 1);
if(curves:isEmpty()) { return; }
local curve = curves[0];
// curve is made up of edges
local edges = curve:getEdgeList();
// initialize i and len, then get the length of EdgeList
local i, len = 0, edges:length();
// create two new CLexWCoordinate objects
local pos = CLexWCoordinate:new(); mortal(pos);
local tangent = CLexWCoordinate:new(); mortal(tangent);
// get the list of highlighted objects
local graphicsContainer =
CLexSofyEnv:getCurrentScene():getHighlightsGraphicsContainer();
// for each edge in EdgeList, get the start and end pts.
for(i=0; i<len; i++) {
local edge = edges[i];
local ret, start, end = 0, 0.0, 0.0;
ret, start, end = edge:getRange(start, end);
// find midpoint
local param = (start + end) / 2.0;
// Evaluate the edge at a parametric location,
// returning both the point and tangent on the edge
edge:eval_tangent(param, pos, tangent);
// create a node at the given location on curve
CLexNode:new(pos);
219
RADE Tutorials

// create a temporary arrow at the new node, in tangent dir.


local axisGraphics = CLexArrowGraphicsObject:new(pos:x(),
pos:y(), pos:z(), tangent:x(), tangent:y(), tangent:z(), 0.010);
graphicsContainer:insert(axisGraphics);
}
// redraw
drawAllCanvases();
}
// define function that creates a menu item
function PtOnCurveMenu()
{
local my_menu = gui:getTopMenu():findChild("My Menu");
if(not my_menu) {
my_menu = TopMenuItem:new("My Menu");
}

if(not my_menu:findChild("Pt. on Curve")) {


local pb = PushButtonItem:new(my_menu, "Pt. on Curve",
"CurveExampleCB");
}
}
// execute the function
PtOnCurveMenu();

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.

RADE Tutorial 15 - Complex Picking


Complex Picking- Demonstrates complex picking and adding options to Pick window.
Step 1: Open a finite element model in the Structures or Crash Workspace.
Step 2: In Script Editor, open the file: 15-complex-picking.rdl. Or Type or Copy / Paste the text below
into the Script Editor window:
/*
* Demonstrates complex picking (pick dialog functionality)
* - Deletes elements connected to picked node
* - hence shows "how to automatically
* - add elements to the pick" when node was picked
*/
#debug
220
RADE Tutorials

function DelElemsProcessFunc(pp)
{
if(pp:isEmpty()) { return; }
local node = pp:last();
cast(node, "CLexNode")

// Get elements connected to the node


local elems = ElementList:new(); mortal(elems);
ShowMsg(node:getAppId());
node:getConnectedElements(elems);
if(elems:isEmpty()) {
ShowErrorMsg("No Elements Connected to Picked Node !!");
CLexPickDialog:resetPickLists();
return;
}

// Add these elements to pick


CLexPickDialog:rejectLast();
local i, len = 0, elems:length();
for(i=0; i<len; i++) {
CLexPickDialog:insertPickedObject(elems[i]);
}
CLexPickDialog:getNumPickedList():insert(len);
//CLexPickDialog:resetPickLists();
//deleteObjects(elems);
}
function DelElemsDoneFunc(pp)
{
// Something has to be picked
if(pp:isEmpty()) {
ShowErrorMsg("No Elements to Delete !!");
CLexPickDialog:resetPickLists();
return;
}
// Get the elements
local elems = ElementList:new(pp:length()); mortal(elems);
local i, len = 0, pp:length();
for(i=0; i<len; i++) {
local elem = pp[i];
cast(elem, "CLexElement");
elems:insert(elem);
}
CLexPickDialog:resetPickLists();
// Delete the elements & nodes(if option is enabled)
local nodes = NodeList:new(); mortal(nodes);
if(CLexPickDialog:isChoiceEnabled()) {
getNodesFromElementList(elems, nodes);
}
deleteObjects(elems);
deleteObjects(nodes);
//CLexHistory:NoteAndNameState("Delete Elements");
drawAllCanvases();
}
function AddElemsToPick_CB(pp)
221
RADE Tutorials

{
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.

RADE Tutorial 16 - Writing efficient RADE code


In this tutorial we will discuss several code samples that demonstrate how to make your programs run
faster. You can find these in the included sample file 16_RADE_Faster_Code.rdl. This script cannot be
run as-is, but provides several examples you can use to write more efficient code.
• Checking code speed:

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));

• Looping through Lists:

Here are some suggestions on making loops more efficient.

//-------------------------------------------------------------
//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

// lot of performace gain with this


local vec = CLexWCoordinate:new(); mortal(vec);
for(...) {
vec:setValues(x, y, z);
}
//-----------------------------------------------------------
//
//-----------------------------------------------------------
//SLOW:
for(...) {
local nodes = NodeList:new(); mortal(nodes);
}
//FAST:
// significant performace gain with this
//(creating a new node list every time you enter
// a for loop is avoided)
local nodes = NodeList:new(); mortal(nodes);
for(...) {
nodes:clear();
getNodesFrom...
}
//-----------------------------------------------------------
//
//-----------------------------------------------------------
//SLOW:
local nodes = NodeList:new(); mortal(nodes);
for(...) {
nodes:insert(n);
}
//FAST:
/ if you are inserting something in the list,
// mentioning the size of the list
// in the constructor makes it faster
local nodes = NodeList:new(num_nodes); mortal(nodes);
for(...) {
nodes:insert(n);
}
//-----------------------------------------------------------

• Checking a list for contents


//-----------------------------------------------------------
//SLOW:
if(nodes:contains()) ...
FAST:
//Use nodes[i]:getFlag1 & setFlag1 logic instead
//-----------------------------------------------------------

• Deleting Objects
//-----------------------------------------------------------
//SLOW:
local nodes = NodeList:new(); mortal(nodes);
//FAST:
224
RADE Tutorials

local nodes = NodeList:new();


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 ******


local nodes = model:getNodeList();
nodes:delete();// <== VERY VERY DANGEROUS
// AS YOU ARE MESSING SIMXPERT's POINTERS!
//----------------------------------------------------------
225

Template Execution
226
Open Template Execution window

Open Template Execution window

Template Builder workspace


Right-click on a template in Model Browser and select Test.

The Template Execution window opens.

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.

Select No to execute without changing to the template’s unit system.


Select Cancel to abort execution.
Unit Validation is performed only on top-level templates. If a sub-template has a different unit attribute
than the parent template, then no additional validation or conversion will occur. In this case, the template
author may need to add an action to change the units for the sub-template.

Begin Execution
You may need to change some settings before running. For example:
• Set Options
• Pause at selected Actions
• Toggle automatic execution of Actions.

When ready, click the Run button.

Use the Template execution toolbar buttons to control the execution and/or the view during execution.
229
Running a Template

Providing template inputs


Typically an input parameter dialog box will appear at the start of template execution and possibly at
each action to gather undefined input parameters.

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.

Pick using recorded gestures


When a macro is recorded, or a template is executed and saved, the picking of objects 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 these saved inputs are later used to run the template, objects will be picked based on the recorded
gestures. The view, scene, and screen locations of the original picks are replayed. This allows the use of
a model that is similar to the original model, but perhaps with different object i.d.’s. Automatic picking
of objects can occur, even if i.d.’s do not match.

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.

Un-do and Re-do


While executing a template, it is possible to reverse the previous steps, using Un-do icon. The template
must be in a paused state to access this command.

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

Template execution toolbar


The Template Execution window has a toolbar with Options, File import and save, and Controls to run,
pause, stop, and run selective actions. Most of these are also available on a context menu by right-clicking
on an action in the tree or flowchart.

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.

Prompt for Inputs


If checked, user will be prompted to supply any inputs needed by the template during execution. If Use
Saved Inputs is also checked, input values from a prior run are populated in dialog boxes, but user will
confirm each. If un-checked, template runs automatically using saved input parameters from a previous
execution.

Use Saved Inputs


Inputs from a previous run can be used to help automate a Template. All or part of the template can be
run, using inputs from a previous run. The Process\Executed folder will be searched for a saved execution
file with the same name as the current template, and the template will be run using the inputs specified
in that file.

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.

Import Input Values


Input parameters can be imported from any saved template execution file (*.proc). Inputs are imported,
but template is not executed until Run button is selected.
Click the Import Input Values icon in the template execution toolbar.

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.

Run selected action

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.

Toggle automatic execution

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

Batch execution of templates

Opening Batch Execution window


Batch execution option can be selected from Options menu (on toolbar of Template Execution window),
or in the Templates tool ribbon.

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.

Editing the *.csv file


Prior to running the batch execution of a template, the *.csv file can be modified in the Batch Execution
window. Each row of the table represents one run of the template. Each column represents an input
parameter. Rows and columns may be added or deleted. Copy and Paste tools are available to assist with
the editing of input values, similar to spreadsheet editing.
Use Save or Save As... commands to save a copy of the modified file.

Running the batch execution


Click the Run button. The template will be run once for each row in the *.csv input file. Note that all
inputs must be included in the *.csv file (or valid defaults set). It is not possible to have a mixture of
supplied inputs from *.csv and input prompting dialogs.
If necessary, click Stop button to halt template execution.
Note: When running in batch mode, the Unit Validation dialog box will not appear. Units will be
changed to the user units stored in the template and template execution will proceed as normal.
Outputs will be written to the selected Output file (*.csv). Check Outputs tab to view the outputs.
Click the Close button to dismiss the Batch Execution window.
242
Batch execution of templates
243

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:

Template Builder workspace


There are several ways to interact with SimManager in the Template Builder workspace.
245
SimManager Introduction

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.

Actions can be published from the Action Editor.


See Publishing from SimXpert to SimManager for more details on publishing to SimManager.
246
SimManager Introduction

Other analysis workspaces


Toolbar
In any SimXpert analysis workspace (e.g. Structures, Crash, Thermal, etc.) simulation data may be
published to SimManager and subsequently retrieved using the SimManager toolbar. The entire
SimManager database can be navigated using Browse. See SimManager Toolbar for details.

Templates tool ribbon


To execute a published template, use the Retrieve or Run Published Template tool from the Templates
tool ribbon. You can navigate SimManager, select a template, and execute it in the appropriate SimXpert
analysis workspace.
247
SimManager Introduction

Enterprise Tab of Model Browser


The Enterprise tab also allows for creating SimManager objects, retrieving, and publishing data directly
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.

A confirmation message appears. Click Yes to logoff.


250
SimManager Toolbar

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.

See Retrieving from SimManager section for details.


251
SimManager Toolbar

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

Publishing from SimXpert to SimManager

Publish a Template from Template Builder


Once a template has been tested and saved in Template Builder, it can be shared by publishing to
SimManager. Open the Properties dialog box for the template by double-clicking on the template’s icon
in the model browser. Select Publish on the left side.

Select Workspace(s) for which the template is valid.


Then click Publish to begin. If not already logged in, you will be taken to the Logon screen, where you
must enter a valid User Name and Password.
Once logged in, the Publish Template dialog box is displayed.
255
Publishing from SimXpert to SimManager

A Publish Template dialog box appears.

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.

Procedure File information


The Procedure File field is automatically populated from the selected template. This file is the template
file with an xml wrapper and is created upon publication to SimManager.
The Procedure Name and Additional File fields are populated from the selected template file.
Select the Auto-Release check box if you wish the template to be promoted to Release Level 1 upon
publication. Otherwise it will be published at Release Level 0.

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.

Publish the Template and related files


Click Submit to proceed with the publishing process. If the Procedure Name is the same as one already
published in the same Project, you will be asked to confirm that you wish to create a Revision.

A message will be shown upon successful publication:


258
Publishing from SimXpert to SimManager

Publish Template as Resource


Templates can also be published “as a Resource.” For example, a template may be intended for use only
as a sub-template and not to be executed on its own. In that case, it would be appropriate to publish it as
a Resource.

See Publish an Action from Template Builder, below.

Publish an Action from Template Builder


An action may be published from the Action editor.
259
Publishing from SimXpert to SimManager

After modifying and saving the action, go to the Data sheet and click the Publish as Resource... button
to initiate a connection to SimManager.

Publish Resource dialog box


260
Publishing from SimXpert to SimManager

The Publish Resource dialog box is displayed.

Project selection
Click Select to choose a Project. In the Project selection dialog box. Scroll to locate the Project and select
it. Click Submit.

Resource file information


The Resource Name is populated from the action file name, but can be changed.
The Package Name is auto-populated and cannot be changed.
The Resource File is auto-populated from the selected action and can only be changed by selecting a
different action. Use the Browse button to do this, and you may also need to re-enter the above mentioned
inputs.
261
Publishing from SimXpert to SimManager

Click Submit to publish the action as a resource.

Publish Other Simulation Data


Other simulation data can be published to SimManager, using the Publish Data icon on the SimManager
toolbar. (All workspaces except Template Builder) This can be used to publish a SimXpert model, along
with input deck, results file, and key result images.

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.

• Advanced Item Inputs


The Advanced Item Inputs tab provides you the ability to add Text, Real, and/or Number
Attributes of the new Item These attributes will be applicable this Item and all Variants that are
created under the Item.
265
Publishing from SimXpert to SimManager

• Advanced Variant Inputs


The Advanced Variant Inputs tab provides you the ability to add Text, Real, and/or Number
Attributes of the new Variant. These attributes will be applicable to this Variant only.
266
Publishing from SimXpert to SimManager

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 Models and Results

• Add Design Model


268
Publishing from SimXpert to SimManager

• Add Input Deck

• Add Result
269
Publishing from SimXpert to SimManager

• Add Key Result

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

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

Select the Model using table or tree, and Submit.


Click Browse... to select the destination Directory to store the retrieved model and related files. Select
the check box to “Overwrite existing files,” if desired.
Any additional model files associated with the chosen Analysis Model will be listed in the Model Files
table. Select the Include column for any files you wish to retrieve.
Related objects, such as Input Decks, Results, and Key Results are listed in the Related Objects table.
Select the Include column for each object to be retrieved.
Select Open Model to open the selected analysis model in its default application.
Select Submit to retrieve and place a copy of the selected objects in the destination directory.

Retrieve and edit - actions or templates


Editing of an action or template is done in the Template Builder workspace.

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.

The retrieved action is opened for editing in the Action editor.

Retrieve and insert into template


While creating a template in Template Builder workspace, published Templates and Actions in
SimManager can be retrieved and inserted into the current template.
274
Retrieving from SimManager

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

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.

Or in other workspaces, select Run Published... in the Templates tool ribbon.

The Select Template dialog box is displayed.


276
Retrieve and Run a Template

Select a Template from the table, and Submit.

Project, Queue, and Launch Mode


A dialog box is displayed for you to select the Project, Queue, and Launch Mode.

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

Click Submit to begin execution.

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.

Retrieve (and run)


Select Templates on the Tool ribbon.
To retrieve a Template from SimManager and run it “unmanaged:” Select Retrieve...

A Select Template dialog box appears.


280
Retrieve and Run a Template

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

Enterprise SimManager options


If your SimManager connection was not set up during installation, you can configure it in User Options.
Select Tools from top menu bar, then Options. In the General options, select Enterprise SimManager.

Select the Protocol (for example, http://)


Enter the Host (server name), Port (for example 8989), and Web Context (usually SimManager).
If desired, Test the connection to check that the connection is set up correctly. A confirmation message
will indicate that the test was successful.

Click Ok to dismiss the information dialog.


Click Ok in User Options to when finished.
282
Enterprise SimManager options
283

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

discrete constraint 104


range constraint 104
input parameters
boolean parameter 120
CAD object 122
enterprise object 123
enumeration parameter 121
integer parameter 118
interface 111
managed object 122
object parameter 121
point parameter 122
real parameter 119
string parameter 113
inputs
prompting options 60
inserting objects in a template 26
integer parameter 118
L
layout 55
layout properties 128
lists
copying 157
loop
for-each loop 43
simple loop 41
while loop 45
M
macro recording 23
managed object parameter 122
message tool 50
N
new script action 85
O
object parameter 121
options 71
action 125
P
point parameter 122
286

prompt for confirmation 50


prompt for file 47
prompt for string 49
prompt tool 49
properties
action instances 57
actions 57
template 51
template general 51
template inputs 52
template outputs 53
template publish 53
publish a template 254
publish an action 258
publish simulation data 261
published actions
inserting in a template 30
published templates
inserting in a template 30
publishing to SimManager 254
python
running scripts 150
syntax details 155
syntax overview 152
tutorials 159
python scripting language 152
R
RADE
introduction 187
running scripts 150
syntax details 191
syntax overview 187
tutorials 198
range constraint 104
real parameter 119
recording a macro 23
retrieve and edit 272
retrieve and run a template 275
retrieve data from SimManager 270
287

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

running a template 228


saving execution file 237
template properties dialog box 51
templates
creating 21
editing 19
executing 226
testing a template 65
tool tips 17
tutorials
python 159
RADE 198
U
user interfaces 111
boolean parameter 120
CAD object 122
enumeration parameter 121
integer parameter 118
managed object 122
object parameter 121
point parameter 122
real parameter 119
string parameter 113
V
version
action 94
action, required 61

Das könnte Ihnen auch gefallen