ANSYS ACT Developers Guide
ANSYS ACT Developers Guide
ANSYS, Inc.
Southpointe
2600 ANSYS Drive
Canonsburg, PA 15317
[email protected]
http://www.ansys.com
(T) 724-746-3304
(F) 724-514-9494
Release 16.2
July 2015
ANSYS Customization Suite
ANSYS, Inc. is
certified to ISO
9001:2008.
Disclaimer Notice
THIS ANSYS SOFTWARE PRODUCT AND PROGRAM DOCUMENTATION INCLUDE TRADE SECRETS AND ARE CONFIDENTIAL AND PROPRIETARY PRODUCTS OF ANSYS, INC., ITS SUBSIDIARIES, OR LICENSORS. The software products
and documentation are furnished by ANSYS, Inc., its subsidiaries, or affiliates under a software license agreement
that contains provisions concerning non-disclosure, copying, length and nature of use, compliance with exporting
laws, warranties, disclaimers, limitations of liability, and remedies, and other provisions. The software products
and documentation may be used, disclosed, transferred, or copied only in accordance with the terms and conditions
of that software license agreement.
ANSYS, Inc. is certified to ISO 9001:2008.
Third-Party Software
See the legal information in the product help files for the complete Legal Notice for ANSYS proprietary software
and third-party software. If you are unable to access the Legal Notice, please contact ANSYS, Inc.
Published in the U.S.A.
Table of Contents
Introduction ............................................................................................................................................... 1
Add-Ins and Customization ..................................................................................................................... 1
Defining the Extension Concept .............................................................................................................. 1
Project and Extensions ............................................................................................................................ 2
Defining an Extension ................................................................................................................................ 3
Basic Extension Definition ....................................................................................................................... 3
XML Extension Definition ........................................................................................................................ 6
Python Callbacks for Extensions .............................................................................................................. 6
Customizing an Application .................................................................................................................... 7
Extensions and Libraries ......................................................................................................................... 8
Using Extensions ...................................................................................................................................... 11
Extension Types .................................................................................................................................... 11
Loading and Unloading Extensions ....................................................................................................... 11
Installing and Uninstalling an Extension ................................................................................................ 13
Compiling an Extension ........................................................................................................................ 15
Generation Options for Extensions Handling ......................................................................................... 17
Licensing ................................................................................................................................................... 21
Extension Capabilities .............................................................................................................................. 23
Common Capabilities ........................................................................................................................... 23
Defining Toolbars and Toolbar Buttons ............................................................................................ 23
Binding Toolbar Buttons with ACT Objects ...................................................................................... 26
Defining Pop-up Dialogs ................................................................................................................. 27
Storing Data in Your Extension ........................................................................................................ 28
ACT-Based Properties ........................................................................................................................... 29
Creating Property Groups ............................................................................................................... 29
Using PropertyGroup and PropertyTable ................................................................................... 29
Using Templates to Create Property Groups ............................................................................... 33
Parameterizing Properties ............................................................................................................... 34
Common Property Parameterization Processes .......................................................................... 34
Parameterization in ANSYS Mechanical ..................................................................................... 35
Defining Input Parameters in ANSYS Mechanical ................................................................. 35
Defining Output Parameters in ANSYS Mechanical .............................................................. 36
Parameterization in ANSYS DesignModeler ............................................................................... 37
Parameterization in a Third-Party Solver .................................................................................... 39
Defining Parameters under a Load in a Third-Party Solver .................................................... 39
Defining Parameters in Analysis Settings in a Third-Party Solver ........................................... 39
Defining Parameters under Results in a Third-Party Solver .................................................... 40
Defining DesignXplorer Properties .................................................................................................. 40
Properties in the DX Interface ................................................................................................... 40
Additional Attributes for DX Extensions ..................................................................................... 42
Advanced Usage Examples ....................................................................................................... 42
Managing Dependencies between Properties ..................................................................... 42
Controlling Property Visibility with a Callback ...................................................................... 42
DOE Example ................................................................................................................ 43
Optimization Example .................................................................................................. 43
Modifying an Attribute with a Callback ................................................................................ 43
DOE Example ................................................................................................................ 44
Optimization Example .................................................................................................. 44
Capabilities for ANSYS Mechanical ........................................................................................................ 44
Adding a Pre-Processing Feature in ANSYS Mechanical .................................................................... 44
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
iii
iv
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
vi
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
vii
viii
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Introduction
Add-Ins and Customization
ANSYS Workbench is built on a modular architecture that allows you to extend the functionality of the
framework using add-in development.
The ANSYS Workbench Framework Software Developer's Kit (SDK) is designed to manage data and
workflow, allowing you to integrate ANSYS tools with third-party applications at the framework level.
In contrast, the Application Customization Toolkit (ACT) is designed to allow customizations at the application level. These customizations are done with the goal of inserting specific needs within one
general process. Using ACT in the ANSYS Mechanical application, the customizations include specialized
loads and post processing. You can also use ACT to customize ANSYS DesignModeler, ANSYS
DesignXplorer, and ANSYS AIM. Both ACT and the SDK are part of the ANSYS Customization Suite.
ACT provides internal mechanisms that allow you to customize an ANSYS Workbench application without
needing to compile external code or link with existing ANSYS libraries.
ACT manages the interfaces between the standard application and the additional customization so that
they will interact accurately.
This document describes the steps for creating a custom application, or extension, with ACT. The examples
use ANSYS Mechanical, ANSYS DesignModeler, ANSYS DesignXplorer, and ANSYS AIM as the target applications.
The examples shown are basic ones and intended as a primer. Note that the development of extensions
requires some knowledge of IronPython and XML. For extensions that customize the ANSYS solver,
knowledge of APDL is also required.
The examples included were written and tested on all Windows platforms.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Introduction
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Defining an Extension
ACT has two basic components:
XML is used to define and configure the content of the extension.
Python script functions are used to respond to user/GUI interactions and implement the behavior of the
extensions. Typically, the Python functions are invoked through the different events or callbacks managed
by the extension.
An extension can potentially be created using additional components such as external Python libraries
or even C# code. However, the two components described above represent the basic definition for an
extension.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Defining an Extension
Figure 1: Extension Configuration File Hierarchy
The next figure shows the contents of the ExtSample1 folder. The file sample1.py contains the Python
script needed to fulfill the behavior of the example extension and the images folder holds the icon file
used by the GUI of the extension.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Figure 3: Images Folder Content (p. 5) shows the contents of the images folder. The icon file hand.bmp
is used by the example extension to expose the specific button from the toolbar. The BMP image format
is the only format supported by the ACT.
Figure 3: Images Folder Content
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Defining an Extension
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Customizing an Application
The function init() is called when the application (for example, Mechanical) is opened. The argument
context contains the name of the application (Mechanical).
The function HighFiveOut() is called when the user clicks the toolbar button HighFive. As with all
<onclick> callback functions, the application passes an instance of the active Analysis object as an
argument.
For any function, the global variable ExtAPI represents the main entry point for all the services provided
by ACT. As an example, the init() function uses the ILog interface of the ACT to write one message
in the log file. For more information on the available interfaces, see the Application Customization Toolkit
Reference Guide.
Customizing an Application
In the following figure, the ExtSample1 extension toolbar and HighFive button are now part of the
ANSYS Mechanical user interface. The context of this extension has been set to Mechanical. Consequently, this extension was loaded with the Mechanical application. You can refer to Using Extensions (p. 11) for more information about the load of extensions.
Figure 4: ExtSample1 Toolbar
The next figure shows an open extension log that demonstrates that ExtSample1 was initialized for
the Mechanical application context.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Defining an Extension
Figure 5: ExtSample1 Extension Log
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
10
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Using Extensions
From the main menu in Workbench, ACT provides a set of capabilities to handle the extensions. This
section describes these capabilities in detail. Using these capabilities, you have the ability to work with
the extensions as needed during the development and use phases.
Extension Types
ACT handles two different types of extensions. The following sections describe the scripted extensions
comprised of XML and IronPython functions. Another type is binary, resulting from the build of a
scripted extension. In essence, the development phase uses scripted extensions. Once those extensions
are complete, the binary extensions are shared by the developer with other users. The way these extensions can be used is explained more in detail in Licensing (p. 21).
The Extension Manager tool is available from the Manage Extensions menu, shown below.
Figure 7: Manage Extensions Menu
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
11
Using Extensions
Figure 8: Extension Manager (p. 12) shows the Extension Manager, which lists the available extensions.
Both binary and scripted extensions are listed in this menu. In addition to the name of the extension,
the type and version specified in the XML file are also displayed.
Figure 8: Extension Manager
To load an extension, check the Loaded check box for the extension. For binary extensions, it is also
possible to selected the Load option from the context menu by right-clicking a binary extension, shown
in Figure 9: Binary Extension Loading (p. 12).
Figure 9: Binary Extension Loading
To unload an extension, uncheck the Loaded check box or select the Unload option from the rightclick context menu.
You can select a set of extensions to be loaded by default in the Extension Manager. These extensions
are automatically loaded when ANSYS Workbench is launched. The selection of default extensions is
done by selecting Load as Default from the right-click context menu. Both scripted and binary extensions
are available for this selection. There is no limit to the number of extensions which can be loaded by
default. Figure 10: Default Extensions (p. 13) shows two extensions configured to be loaded by default.
For these two extensions, the (Default) label is added to the extension name and the Loaded check
box is automatically checked.
12
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
To remove an extension from the list of extensions to be automatically loaded, select the extension
and select Do Not Load as Default from the right-click context menu, as illustrated in Figure 11: Removing a Default Extension (p. 13).
Figure 11: Removing a Default Extension
The Extension Manager identifies the available extensions based on the directories defined in the ACT
options. For information on how to add directories to this list, see Generation Options for Extensions
Handling (p. 17).
The default directories used by the Extension Manager are:
%ANSYSversion_DIR%\..\Addins\AdvancedAddinPackage\extensions
%APPDATA%\Ansys\v162\AdvancedAddinPackage\extensions
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
13
Using Extensions
2. A file selection dialog opens and shows files that end in .wbex.
3. Select the WBEX file for the extension you want to install and select Open.
Extensions installed this way are located in the current users Application Data folder and are available
for loading through the Extension Manager.
Note
When a binary extension is installed, a new folder is created in addition to the WBEX file.
Both the folder and the WBEX file are necessary for compatibility with ACT. If you need to
move this new extension to a different folder, make sure that both the folder and the WBEX
file are copied at the same time to the same folder.
Figure 12: Install Extension menu
To uninstall an extension, select the extension in the Extension Manager and select the Uninstall option
in the right-click context menu, as shown in Figure 13: Uninstalling an Extension (p. 14).
Figure 13: Uninstalling an Extension
The process for uninstalling extensions is only available for binary extensions. To uninstall scripted extensions, delete the associated files and directories related to the extension. If you remove a scripted
extension while the Extension Manager is running, it will not appear the next time the Extension Manager
is launched.
14
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Compiling an Extension
Compiling an Extension
Compiling an extension means encapsulating a scripted extension into a binary format. This process
does not require you to use a specific compiler. ACT provides its own process for migrating the extension
to a binary format unreadable by any other user. The encapsulation of the scripted extension, also called
the build of the binary extension, generates a unique WBEX file. This file contains all the files or directories necessary for the extension. Once the extension is built, it must be installed before it can be used.
Installing and Uninstalling an Extension (p. 13) explains how to install a binary extension. The Binary
Extension Builder is available from Extensions > Build Binary Extension, as shown below.
Figure 14: Build Binary Extension Menu
The Binary Extension Builder allows you to define all the required input parameters for building an extension. Figure 15: Binary Extension Builder Interface (p. 15) illustrates the dedicated window that appears
when the user selects the Build Binary Extension option. When all expected input parameters are
defined, the Build button is activated.
Figure 15: Binary Extension Builder Interface
The Scripted Extension to Build option is populated with a list of scripted extensions from directories
defined in the ACT options. Both the name and the version are displayed in the list to avoid any confusion
when multiple versions of one extension are present. Generation Options for Extensions Handling (p. 17)
exposes this process in more detail.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
15
Using Extensions
Figure 16: Contextual List of Scripted Extensions
Once the scripted extension is defined, you must identify a directory where the binary extension will
be stored. The final required parameter defines a security level. This security level defines if the extension
can be saved within an ANSYS Workbench project, and thus, when that project is shared, if the extensions
can be loaded with the shared project. This security level enables the developer of the extension to
control how the extension can be shared along their use with various projects. With the option Can
copy extension to project, each time a user asks to save this extension with a project, the extension
itself is copied into the project and consequently is available each time this project is opened. This extension can also be used with other projects. However, if you select Can copy extension to project
but locked to this one, the extension can be saved within a project, as with the previous option, but
the use of the extension is limited to the current project. If a user opens a new project, this extension
is not available. If you select Can't copy extension to project, the extension is not saved with the
project and is not shared with other users with the project. Note that the extension can be sent in addition to the project. The process for saving extensions within a project is described in Generation Options
for Extensions Handling (p. 17). Note that these security options only apply if the user wants to save
the extension with the project, and are otherwise not applicable.
When all parameters are defined, the Build button is available, and you can launch the creation of the
binary extension. The bottom part of the window displays build information as illustrated below.
16
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
17
Using Extensions
Figure 19: Extensions Options
The first option, Additional Extension Folders, provides the ability to define additional folders in which
ACT will search for extensions in order to expose them in the Extension Manager. You can define several folder names, separated by a semi-colon (;). These folders are in addition to the two folders used
by default. These two default folders are the default installation folder for extensions:
%ANSYSversion_DIR%\..\Addins\AdvancedAddinPackage\extensions
and the user's Application Data folder:
%APPDATA%\Ansys\version\AdvancedAddinPackage\extensions
Because these folders are searched for extensions by default, the Extension Manager contains any extensions located in them.
During the scan of the available extensions, the folders are analyzed in following order:
1. The application data folder.
2. The installation folder.
3. Additional folders defined in the Additional Extension Folders option.
During this process, warning messages are returned for any conflicts; these messages are also logged
in the ACT log file.
The second property in the Extensions Options specifies if the extensions should be saved when the
project is saved. Figure 20: Save Extensions Option (p. 19) shows the available options for this property.
18
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
If you choose Never, the current loaded extensions are not saved within the project.
If you choose Copied but locked to the project, the extensions are saved within the project but are
limited to that project.
If you choose Always, the extensions are saved within the project and no restriction exists as to their
use in other projects. This option represents what most users expect when the project is saved. However,
note that this behavior is dependent on the security options of the extension defined by the developer,
as described in Compiling an Extension (p. 15). In particular, the following scenarios can occur:
The extension was built with the security option set to Cant copy extension to project and the user set
the save option to Always or Copied but locked to the project. In that case, the security option has the
priority and the user will not have the extension saved in the project.
The extension was built with the security option set to Can copy extension to project but locked to this
one and the user set the save option to Always. Although the save option does not impose any restriction
for the extension, the security level will limit the use of the extension for the current given project.
The third property allows you to activate Debug mode. When activated, this mode allows the developer
to debug the scripted extension. In addition, the Debug mode exposes one additional feature in the
toolbar of the main project page that enables to reload the extension once a modification has been
done in a script. This feature is similar to the feature 1 described below. When the ANSYS Mechanical
application is used, the Debug mode exposes two additional features in Mechanical that will help you
debug the extension under development. These two features are available from a new toolbar in
Mechanical.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
19
Using Extensions
For more information on debugging capabilities, see Debug Mode (p. 199).
20
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Licensing
ACT development is licensed, but binary extension usage is not. In other words, developers creating
new extensions must have a license. However, once the extension is built, a license is not required to
run it.
The ACT license enables two main capabilities, which are:
The ability to build an extension in the Binary Extension Builder. The ACT license is checked out when the
build is launched and is released once the build has been completed.
The ability to load a scripted extension. As a consequence, only the binary extensions can be loaded when
no ACT license is available. No matter the number of scripted extensions that are loaded, only one ACT license
is checked out. This license is released once all the scripted extensions have been unloaded from the Extension
Manager.
Note
If an ACT license is already checked out by a loaded scripted extension, the build operation
will not require a second ACT license to run.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
21
22
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Extension Capabilities
In the introductory chapter, the sample extension ExtSample1 was used to describe the fundamental
elements of an extension. The ExtSample1 extension demonstrated how to create a toolbar which
contains a button that responds by calling a Python scripted function. This chapter expands on this
description and introduces the main capabilities an extension can address.
This chapter divides extension capabilities in to the following categories:
Common Capabilities
ACT-Based Properties
Capabilities for ANSYS Mechanical
Capabilities for ANSYS DesignModeler
Capabilities for ANSYS DesignXplorer
Capabilities for Custom ACT Workflows in Workbench
Capabilities for ANSYS AIM
Common Capabilities
ACT provides customization capabilities that are common to all target applications: ANSYS Mechanical,
ANSYS DesignModeler, ANSYS DesignXplorer, and ANSYS AIM.
This section discusses the following common capabilities:
Defining Toolbars and Toolbar Buttons
Binding Toolbar Buttons with ACT Objects
Defining Pop-up Dialogs
Storing Data in Your Extension
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
23
Extension Capabilities
<callbacks>
<onclick>OnClickTB1Button1</onclick>
</callbacks>
</entry>
<entry name="TB1Button2" icon="button2Red">
<callbacks>
<onclick>OnClickTB1Button2</onclick>
</callbacks>
</entry>
<entry name="TB1Button3" icon="button3Red">
<callbacks>
<onclick>OnClickTB1Button3</onclick>
</callbacks>
</entry>
</toolbar>
<toolbar name="Toolbar2" caption="Toolbar2">
<entry name="TB2Button1" icon="button1Blue">
<callbacks>
<onclick>OnClickTB2Button1</onclick>
</callbacks>
</entry>
<entry name="TB2Button2" icon="button2Blue">
<callbacks>
<onclick>OnClickTB2Button2</onclick>
</callbacks>
</entry>
<entry name="TB2Button3" icon="button3Blue">
<callbacks>
<onclick>OnClickTB2Button3</onclick>
</callbacks>
</entry>
</toolbar>
</interface>
</extension>
The ExtToolbarSample extension adds two toolbars, Toolbar1 and Toolbar2. Each toolbar has
three buttons, as shown in Figure 21: User-Defined Toolbars in Mechanical (p. 24).
Figure 21: User-Defined Toolbars in Mechanical
24
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Common Capabilities
The XML example defines two toolbar elements. Each element starts with a begin tag <toolbar
name="..." caption="..."> and ends with a terminal tag </toolbar>. The toolbar element
has two attributes, name and caption. The name attribute is required and is used for internal references.
The caption attribute is the text displayed in the application.
The button entry elements define the buttons in the toolbar. Each button entry element starts with
a begin tag <entry name="..." icon="..."> and ends with a terminal tag </entry>. The
entry element has two attributes: name and icon. The name attribute is required and is used for
internal references. The name is also displayed as a tooltip. The icon attribute is the name of the icon
file mapped on to the button.
The entry element for each button is parent to a callbacks element. The <callbacks> element
encapsulates element(s), which are named on the basis of an event. For instance, the name specified
by the onclick element, <onclick>name</onclick>, provides the name of the Python function
to be called when the button is selected.
Referring again to the XML in the above code, the second line:
<script src="toolbarsample.py" />
defines the name of the Python script file for the ExtToolbarSample extension, toolbarsample.py,
the contents of which are shown below. By default, ACT will look for the Python script file in the directory
of the extension. If the Python script file is located in a different directory, an explicit path to the file
must be inserted into the extension XML file.
import os
import datetime
clr.AddReference("Ans.UI.Toolkit")
clr.AddReference("Ans.UI.Toolkit.Base")
from Ansys.UI.Toolkit import *
def init(context):
ExtAPI.Log.WriteMessage("Init ExtToolbarSample ...")
def OnClickTB1Button1(analysis):
LogButtonClicked(1, 1, analysis)
def OnClickTB1Button2(analysis):
LogButtonClicked(1, 2, analysis)
def OnClickTB1Button3(analysis):
LogButtonClicked(1, 3, analysis)
def OnClickTB2Button1(analysis):
LogButtonClicked(2, 1, analysis)
def OnClickTB2Button2(analysis):
LogButtonClicked(2, 2, analysis)
def OnClickTB2Button3(analysis):
LogButtonClicked(2, 3, analysis)
def LogButtonClicked(toolbarId, buttonId, analysis):
now = datetime.datetime.now()
outFile = SetUserOutput("ExtToolbarSample.log", analysis)
f = open(outFile,'a')
f.write("*.*.*.*.*.*.*.*\n")
f.write(str(now)+"\n")
f.write("Toolbar "+toolbarId.ToString()+" - Button "+buttonId.ToString()+" Clicked. \n")
f.write("*.*.*.*.*.*.*.*\n")
f.close()
MessageBox.Show("Toolbar "+toolbarId.ToString()+" - Button "+buttonId.ToString()+" Clicked.")
def SetUserOutput(filename, analysis):
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
25
Extension Capabilities
solverDir = analysis.WorkingDir
return os.path.join(solverDir,filename)
Each button in ExtToolbarSample has a unique callback function. Each callback function passes the
toolbar ID and the ID of the button pressed to the function LogButtonClicked, which stores them
in the variables toolbarId and buttonId. These variables are referenced within the function where
their string values are written. The functions LogButtonClicked and SetUserOutput demonstrate
how to reduce redundant code in callbacks using utility functions. The Analysis object is passed to
each <entry> callback and then used in the SetUserOutput function to query for the working
directory of the analysis. The script in toolbarsample.py makes use of the datetime namespace
from the .NET framework. The datetime namespace exposes a class also called datetime. LogButtonClicked invokes datetime to query the current date and time and stores the result in the variable
name now. The str() utility is used to extract the string definition of the variable now to write out
the date and time.
As an example, if the ACT button is bound with an ACT load in Mechanical, then this button is activated
only if the object is selected in the Mechanical environment; otherwise it is inactive.
In the same way, if the ACT button is bound with an ACT result in Mechnical, this button is active only
if the object is selected in the solution; otherwise it is inactive.
For any ACT object bound to a button, the <onclick> callback is not used.
Based on the above example, Figure 22: Selecting an Environment Object (p. 27) and Figure 23: Selecting
a Solution Object (p. 27) illustrate the GUI behavior based on selection of an object in the tree.
26
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Common Capabilities
Figure 22: Selecting an Environment Object
In addition to the control provided by the connection between the ACT button and the ACT object,
the <canadd> callback can be implemented to add new criteria to be considered for the activation
and deactivation of the button. If the <canadd> callback of the object returns false, the associated
button is deactivated. A typically example consists of filtering a particular analysis type to activate a
specific load.
27
Extension Capabilities
<entry name="DialogSample1" caption="GetFilename">
<callbacks>
<onclick>GUIToolbarOpenFile</onclick>
</callbacks>
</entry>
</toolbar>
</interface>
</extension>
The callback function specified in the XML for the GetFilename menu button is GUIToolbarOpenFile.
Here is the Python script from the file dialogsample.py.
clr.AddReference("Ans.UI.Toolkit")
clr.AddReference("Ans.UI.Toolkit.Base")
from Ansys.UI.Toolkit import *
def init(context):
ExtAPI.Log.WriteMessage("Init ExtDialogSample ...")
def GUIToolbarOpenFile(analysis):
filters = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
dir = "c:\\"
res = FileDialog.ShowOpenDialog(ExtAPI.UserInterface.MainWindow, dir, filters, 2,
"ExtDialogSample","")
if res[0]==DialogResult.OK:
message = str("OPEN selected -> Filename is "+res[1])
else:
message = "CANCEL selected -> No file"
MessageBox.Show(message)
28
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
ACT-Based Properties
Attributes are created or edited with the method:
Attributes["attribute_name"] = attribute_value
Note that an attribute associated with an extension can be shared between applications using the same
extension. For example, two Mechanical sessions can share data.
The command to store the attribute in a shared repository is as follows:
ExtAPI.ExtensionMgr.CurrentExtension.SetAttributeValueWithSync("MyData", 2.)
In the same way, the command to retrieve the content stored in a shared repository is:
ExtAPI.ExtensionMgr.CurrentExtension.UpdateAttributes()
v = ExtAPI.ExtensionMgr.CurrentExtension.Attributes["MyData"]
ACT-Based Properties
ACT has the ability to create customized objects that encapsulate ACT-based properties. This section
discusses how to use ACT to create properties.
The following topics are discussed:
Creating Property Groups
Parameterizing Properties
Defining DesignXplorer Properties
29
Extension Capabilities
properties and to create worksheet views from a property.The PropertyGroup type encapsulates a
list of child properties under one group.
The PropertyTable type encapsulates a list of child properties under one table. Each child property
creates a new column in the table and the user is able to control the line number of this table.
These functionalities are demonstrated into the AdvancedProperties extension.
The first example shows how to create a group of properties with a caption. The group can be collapsed
or expanded by the user. The Simple group with caption group is shown below.
Figure 24: Details Pane with Group Definition
caption" display="caption">
/>
/>
/>
The property group has a special attribute, display. In this case, this attribute is set to caption,
which means all the children properties are displayed under the caption. If the caption attribute is
omitted, then the display attribute is set to hidden and the property group is hidden.
The second example illustrates how to show or hide properties according to the value of another selected
property.
As shown in Figure 25: Contextual Content for Groups (p. 31), the visibility of the properties is dependent
on the value of the Group Select property as defined above.
30
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
ACT-Based Properties
Figure 25: Contextual Content for Groups
This group is created with the following XML code, which creates dependencies between properties:
<propertygroup name="Group2" caption="Another group" display="caption">
<propertygroup name="Group3" caption="Group Select" display="property" control="select"
default="Option 1">
<attributes options="Option 1,Option 2,Option 3" />
<property name="Prop1" caption="Prop For Option 1" visibleon="Option 1" control="text" />
<property name="Prop2" caption="Prop For Option 1 and Option 2"
visibleon="Option 1|Option 2" control="text" />
<property name="Prop3" caption="Prop For Option 3" visibleon="Option 3" control="text" />
</propertygroup>
</propertygroup>
In this case, the attribute display is set to property. The PropertyGroup Group3 defines a
standard ACT property which provides additional capabilities for all the children properties.
Each child property can specify an attribute visibleonwhich can take a value or a set of values. If
the current value of the parent property fits with the visibleon attribute, then the property is displayed; otherwise, the property is hidden.
The example below demonstrates how to create properties that open a worksheet each time the user
needs access to the content of the properties. The PropertyTable type is used for such an application.
This type of property is of particular interest as it allows you to create a worksheet that exposes a set
of properties for your customization.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
31
Extension Capabilities
In order to facilitate the development, ACT already provides some predefined worksheets. Two different
types of worksheets are currently available:
Time-dependent worksheet: The row number of this worksheet is initialized with the number of steps
defined in the AnalysisSettings object. If the user of the extension adds or removes time steps
in the AnalysisSettings object, the worksheet is automatically updated. Consequently, this type
of worksheet represents an efficient way to manage time-dependent data within an extension.
Figure 26: Time-Dependent Worksheet
In this example, the display attribute is set to worksheet. In addition, the class attribute is used
to specify the name of the IronPython class that is used to manage the worksheet. For this given application, the TFTabularData class is used. This class is defined in the file TimeFreqTabularData.py
located into the libraries/Mechanical/Worksheet folder, which is part of the standard ACT
installation.
The properties Step and Time integrate a specific treatment, as they are automatically populated with
the information specified in the AnalysisSettings object. These two properties are optional.
Non-fixed row dimension worksheet: For the second type of worksheet, the array is empty by default.
The user can add a new line by clicking on the top left button as illustrated below.
Figure 27: Non-Fixed Row Dimension Worksheet
32
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
ACT-Based Properties
<propertytable name="Worksheet" caption="Non-Fixed row count" display="worksheet" control="applycancel"
class="Worksheet.PropertyGroupEditor.PGEditor">
<propertygroup name="TempOrPres" caption="TempOrPres" display="property" control="select"
default="Temperature">
<attributes options="Temperature,Pressure" />
<property name="Temperature" caption="Temperature" unit="Temperature" control="float"
visibleon="Temperature"></property>
<property name="Pressure" caption="Pressure" unit="Pressure" control="float"
visibleon="Pressure"></property>
</propertygroup>
<property name="Scoping" caption="Scoping" control="scoping">
<attributes selection_filter="face|edge" />
</property>
<property name="FileName" caption="FileName" control="fileopen">
<attributes filters="Command files (*.bat)|*.bat|All files (*.*)|*.*" />
</property>
</propertytable>
In this example the PGEditor class is used. The PGEditor class is defined in the file PropertyGroupEditor.py, available in the /libraries/Mechanical/Worksheet folder.
You can access the content of the worksheet in the same manner as you do any other standard ACT
property.
First, a name is given to the template. The class SelectCoordinateSystem associated with this
template is defined in the file select.py, located in the /libraries/Mechanical/templates
folder. A template has to be made of one single property. If several properties need to be defined, then
they have to be integrated in a group. The template scoping illustrates a template definition with
different properties.
In order to link this template to a property, the user just needs to fill the control attribute of the
property with the name of the template.
Other examples are available in the file /templates/Mechanical/controltemplates.xml.
To be sure, the advanced user will find benefit in using the templates. The templates currently integrated
in ACT can be enriched so that the customized environment will enable always more complex customization in a very efficient way.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
33
Extension Capabilities
Parameterizing Properties
When defining ACT properties in ANSYS Mechanical and ANSYS DesignModeler, it is also possible to
define the property value as either an input or an output parameter (all ACT parameters are inputs,
unless you specify otherwise in the definition). Once parameterized, the property is sent to ANSYS
Workbench for inclusion in the Parameter Set, where it behaves and is treated as any other parameter.
You can incorporate parameters in a variety of places in your analysis.
In ANSYS Mechanical, parameters can be defined for any ACT object, regardless of its location in the tree.
In ANSYS DesignModeler, parameters can be incorporated into a number of custom ACT-based features,
such as renaming selected bodies, specifying geometry generation details like as material, dimensions, etc
.
In a third-party solver implemented by ACT, parameters can be incorporated into the load, analysis settings,
and result.
All combinations of ACT-based and standard parameters are supported:
ACT input(s) and standard output(s)
ACT input(s) and ACT output(s)
Standard input(s) and ACT output(s)
34
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
ACT-Based Properties
When the user has finished setting up the system and has finished working with parameters and design
point values (there should be at least one input and one output parameter), he can solve the problem
by updating the design points from the Parameter Set.
Note
Other tags such as default, isload, etc. could be added, as well.
The isparameter tag adds a check box to the user interface, making it possible for the user to select
the property for parameterization.
Once the property has been selected for parameterization, it will automatically be displayed in both
Outline of All Parameters and the Table of Design Points in the Parameter Set.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
35
Extension Capabilities
The code sample below is extracted from the XML file of the extension used in the previous example.
You can see how the property definition of our float_unit property is incorporated into the file.
<load name="CustomPressure" version="1" caption="CustomPressure" icon="tload" support="false"
isload="true" color="#0000FF">
<callbacks>
<getsolvecommands order="1">writeNodeId</getsolvecommands>
</callbacks>
<property name="Geometry" caption="Geometry" control="scoping">
<attributes selection_filter="face"/>
</property>
<property name="float_unit" caption="float_unit" control="float" unit="Pressure" isparameter="true"/>
</load>
Note
Other tags such as default, isload, etc. could be added, as well.
36
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
ACT-Based Properties
Again, the user must select the check box provided by the ACT tag to actually parameterize the property.
Once the property has been selected for parameterization, the corresponding output will automatically
be generated in the Outline of All Parameters table in the Parameter Set.
In addition, by default the minimum and maximum values of an ACT result object are available to become
output parameters. This capability is not managed by the ACT extension, but takes advantage of the
Mechanical environment.
The resulting check box next to the Length property allows the user to parameterize Length as an input
parameter.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
37
Extension Capabilities
You could add a static structural analysis based on the previous Geometry template by adding an
output parameter in the Static Structural analysis. This results in the schematic workflow shown below:
The input parameter defined in ANSYS DesignModeler will be managed in exactly the same way as
other any other input parameter. In the Outline of All Parameters table in Parameter Set, the geometry
input parameter will be placed under the Geometry system.
38
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
ACT-Based Properties
The following code segment, placed under the solver section of the XML definition file, defines the
Max. Iterations parameter.
<solver
<property name="MaxIter" caption="Max. Iterations" control="integer" isparameter="true" default="10"/>
</solver>
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
39
Extension Capabilities
Optionally, settings can be placed together in groups. Each group must be declared and defined in the
XML file as a <propertygroup> element under <sampling> or <optimizer> element.
For a description of common attributes and callbacks, see property under the XML Tags section of
the ACT Reference Guide for DesignXplorer. For more information on settings groups, see propertygroup
under the XML Tags section of the ACT Reference Guide for DesignXplorer.
40
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
ACT-Based Properties
Figure 29: DesignXplorer Properties View for External DOE
In Figure 30: DesignXplorer Properties View for External Optimizer (p. 41) below, we can see the Properties view when the external optimizer named Python Optimizer is selected.
Figure 30: DesignXplorer Properties View for External Optimizer
By default, properties are shown under the General category. If a propertygroup is specified, the
corresponding category is created in the property view. The properties under the General and the respective Status categories are specific to the external method and are defined in the XML file.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
41
Extension Capabilities
Note that if the sampling supports the LogFile capability, the Log File property is automatically
defined under the Status category of the Properties view. Once the sampling is generated optimization
has been run, the user can view the log file in a dialog box by clicking on the available link.
In the following optimization example, the minimum value is 2 and the maximum value is 200.
<property name="MyNumberOfSamples" caption="My Number of Samples" control="integer" default="50">
<attributes min="2" max="200"/>
</property>
The advanced attribute is used to classify the property as an advanced option. Advanced options are
visible for the user only if activated (in the Workbench user interface, open Tools > Options > Design
Exploration and select the Show Advanced Options check box). The following example is applicable
to either type of DX extension.
<property name="MyRandomNumber" caption="My Random Number provider" control="select"
default="Python">
<attributes options="Python,CLibrary" advanced="true"/>
</property>
42
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
ACT-Based Properties
DOE Example
The following example shows how to control the visibility of the PropForSingleInput property
with a callback coded in IronPython:
<property name="PropForSingleInput" caption="My Property for single input parameter"
control="text">
<callbacks>
<isvisible>isVisibleForSingInput</isvisible>
</callbacks>
</property>
Optimization Example
The following example shows how to control the visibility of the PropForSingleObjective property
with a callback coded in IronPython:
<property name="PropForSingleObjective" caption="My Property for single-objective optimization"
control="text">
<callbacks>
<isvisible>isVisibleForSOO</isvisible>
</callbacks>
</property>
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
43
Extension Capabilities
DOE Example
This example shows how you can modify the values of the max attribute of the property NumberOfLevels when input parameters are edited by the user.
Given the partial sampling definition:
<sampling >
<callbacks>
<InputParametersEdited>InputParametersEdited</InputParametersEdited>
</callbacks>
<property name="NumberOfLevels" caption="Number of Levels" control="integer" default="3"/>
<attributes min="1">
</property>
</sampling>
The InputParametersEdited function is called when input parameters are edited by the user. It
calculates the new minimum allowed value for the NumberOfLevels property from the current
number of input parameters and then sets this value to the max attribute.
Optimization Example
This example shows how you can modify the values of the min attribute of the property MyNumberOfSamples when input parameters are edited by the user.
Given the partial optimizer definition:
<optimizer >
<callbacks>
<InputParametersEdited>InputParametersEdited</InputParametersEdited>
</callbacks>
<property name="MyNumberOfSamples" caption="My Number of Samples" control="integer" default="50" />
</optimizer>
The InputParametersEdited function is called when input parameters are edited by the user. It
calculates the new minimum allowed value for the MyNumberOfSamples property from the current
number of input parameters and then sets this value to the min attribute.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
</load>
</simdata>
</extension>
The definition of the load is encapsulated by the <simdata> begin and end tags. The attributes in
the <load> begin tag provide the name, version, caption, icon, and color that apply to this load. The
color attribute is defined in a hexadecimal format. This color is used to contrast the load when it is
displayed on the model. The load <callbacks> tag encapsulates two callbacks <getsolvecommands> and <getnodalvaluesfordisplay>.
The tag <getnodalvaluesfordisplay> specifies the name of the Python function that is called
when the load is displayed in the application.
The tag <getsolvecommands> specifies the name of the Python function that is called when the
solver input file is generated by the application. Consequently, the related Python function is responsible
for generating the APDL commands that describe the load within the ANSYS input file. When get-
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
45
Extension Capabilities
solvecommands is used, the solver commands are inserted into the solver input file just before the
SOLVE command.
ACT provides two additional tags to better control where the specific solver commands are inserted in
the solver input file.
The tag <getprecommands> inserts the solver commands before the standard loads and boundary conditions defined in the application. For the ANSYS solver, the new commands are inserted in the context of
the /PREP7 preprocessor after the mesh has been written.
The tag <getpostcommands> inserts the solver commands so they are executed after the solution has
been resolved. For the ANSYS solver, the new commands will be inserted in the context of the /POST1
postprocessor after the /POST1 command.
Below the callbacks definition, you can define the properties that will be applied to the actual definition
of the load. These properties are displayed in the Details pane of ANSYS Mechanical, where the user
provides the necessary values to complete the load definition. In the Python script we will see how the
load's properties can be retrieved and / or modified.
The following figure shows that each property defined above appears in the Details pane with the
corresponding names and types of interface control.
Figure 31: Properties in the Details Pane
Note that the two properties, Select (static) and Select (dynamic), use a select control type. The
first property populates the list of options from the XML, while the second one defines an <onactivate> callback. This callback, which is called when the control is activated, populates the available options
for the property. This second approach allows a full control on the options to be exposed in the dropdown menu and makes the list of options dependent on the current status of the project. Many different
situations that can impact the content of the list of options can be addressed, as long as they are implemented in the <onactivate> callback.
46
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
47
Extension Capabilities
GetSolveCommands is intentionally simplified for this example. The prototype of this function is made
of two input arguments, the load object and the filename in which the new specific solver commands
are written. It is important to note that this output file is only a temporary file, as the content is rewritten
in the final solver input file to ensure that the specific commands related to the customized load are
merged with all the other commands already defined by the standard features of the application.
You can also create a specific set of context menu options. These options use the property Action.
Actions are defined inside the <callbacks> section of the load.
<callbacks>
<ongenerate>generate</ongenerate>
<oncleardata>clearData</oncleardata>
<action name="a1" caption="Action 1" icon="update">action1 </action>
<action name="a2" caption="Action 2" icon="update">action2 </action>
</callbacks>
48
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
As illustrated above, you can also add a Generate context menu option. This option derives from the
standard Generate action provided by Mechanical. For that reason, the declaration of this particular
option differs from the declaration of the options Action1 and Action2. This option is always associated
with the Clear Generated Data option.
These options allow you to create a load that can mimic a standard Imported Load. The callback associated with the Generate option replaces the standard function integrated in Mechanical.
The feature is activated when you define the callback <ongenerate> for the load.
The <ongenerate> callback will be called each time the user clicks on the Generate context menu
item, as well as when the user solves, if the state of the load is set to "not solved."
As for the standard Imported Load object, the <ongenerate> callback will be called only if the mesh
is already generated.
<callbacks>
<ongenerate>generate</ongenerate>
<oncleardata>clearData</oncleardata>
<action name="a1" caption="Action 1" icon="update">action1 </action>
<action name="a2" caption="Action 2" icon="update">action2 </action>
</callbacks>
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
49
Extension Capabilities
return False
try:
vexp = compile(exp,'','eval')
except:
return False
values = SerializableDictionary[int,float]()
nodeIds = []
propGeo = load.PropertyByName("Geometry")
refIds = propGeo.Value
mesh = ExtAPI.DataModel.MeshDataByName("Global")
for refId in refIds:
meshRegion = mesh.MeshRegionById(refId)
nodeIds += meshRegion.NodeIds
nodeIds = list(set(nodeIds))
for i in range(0,nodeIds.Count):
id = nodeIds[i]
node = mesh.NodeById(id)
x = node.X
y = node.Y
z = node.Z
v = 0.
try:
v = eval(vexp)
finally:
values.Add(id,v)
new_pct = (int)((i*100.)/nodeIds.Count)
if new_pct!=pct:
pct = new_pct
stopped = fct(pct,"Generating data...")
if stopped:
return False
propEx.SetAttributeValue("Values",values)
fct(100,"Generating data...")
return True
def clearData(load):
ExtAPI.Log.WriteMessage("ClearData: "+load.Caption)
propEx = load.PropertyByName("Expression")
propEx.SetAttributeValue("Values",None)
The <ongenerate> callback takes two arguments: the load object and a function to manage a progress
bar. This function takes also two arguments: the message to display and the value (between 0 and 100)
of the progress bar.
During the process, the generated data is stored using an attribute on the property Expression. More
details on how to store data are given in section 5.8.
The <oncleardata> callback takes one argument: the load object. This callback is called each time
the mesh is cleaned or when the user selects on the Clean Generated Data context menu option.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
The definition of the result is encapsulated by the <simdata> begin and end tags. The attributes in
the <result> begin tag provide the name, version, caption, icon, and unit that apply to this result.
The result <callbacks> tag encapsulates the single callback <evaluate> used for the evaluation.
The tag <evaluate> gives the name of the Python function that will be called to compute the result
when the application (i.e. presently ANSYS Mechanical) requests an evaluation. The output of this
function is sent directly to Mechanical to display the result.
Below the callbacks definition, you can define the properties that are applied to the actual result
definition. These properties are displayed in the Details pane of ANSYS Mechanical when the user has
selected the result in the Outline pane.
Figure 33: Properties in the Details Pane (p. 52) shows that each property appears in the Details pane
of ANSYS Mechanical with the corresponding names and result values.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
51
Extension Capabilities
Figure 33: Properties in the Details Pane
Below are the contents of the Python script file demoresult.py, the script file used for the DemoResult extension. The functions Create_WPS_Result and WPS_Eval are critical to the behavior and
application of the result.
The Create_WPS_Result function creates and adds the result to the simulation environment.
The WPS_Eval function is called during solution or when the results need to be re-evaluated.
The callback function Create_WPS_Result is used to create the result and add it to the simulation
environment. This function uses Python dot notation, which allows you to chain objects with methods
that return objects to each other. In the expression analysis.CreateResultObject("Absolute
Principal Stress"), the IAnalysis object analysis is given in argument of the callback. This IAnalysis
object calls the CreateResultObject method. From CreateResultObject, the XML is interpreted
and the internal mechanisms are set into motion to add the details and register the callbacks that define
the results framework. For more comprehensive descriptions of the API objects, methods and properties,
see the Application Customization Toolkit Reference Guide.
The WPS_Eval function is called when the result needs to be evaluated or re-evaluated, depending
on the state of the simulation environment. The function definition requires the input arguments result
and step and the output argument collector. Result is the result object for this result and stepInfo
is an IStepInfo object that gives information on the step currently prescribed in the details.
WPS_Eval queries for the component stresses at each node of elements. The stress tensor is used the
compute the three principal stresses (eigenvalues), and then the signed maximum value over these
three is stored as the final result for each node of element. WPS_Eval also deals with the conversion
of units. DemoResults uses a utility library called units, which is imported at the beginning of the
demoresults.py file. With this library, WPS_Eval can derive a conversion factor for the stress units
that is consistent with the units used during solution. Note that the result to be returned by the evalu-
52
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
53
Extension Capabilities
# Computation of the eigenvalues
eigenvalues = EigenValues(tensor)
# Extraction of the worst principal stress
wplocal_stress = eigenvalues[0]
if abs(eigenvalues[1])>abs(wplocal_stress):
wplocal_stress = eigenvalues[1]
if abs(eigenvalues[2])>abs(wplocal_stress):
wplocal_stress = eigenvalues[2]
# Return the worst value of the three principal stresses S1, S2, S3
return wplocal_stress
# This function computes the three eigenvalues of one [3*3] symetric tensor
EPSILON = 1e-4
def EigenValues(tensor):
global eigenvalues
eigenvalues = []
a
b
c
d
e
f
=
=
=
=
=
=
tensor[0]
tensor[1]
tensor[2]
tensor[3]
tensor[4]
tensor[5]
ACT introduces a new method to facilitate the development of Python functions to evaluate simulation
results. The third output argument collector is internally initialized based on the content of the scoping
property. When defined, this property contains the list of FE entities on which results are evaluated.
This information can be used directly in Python functions without looping over mesh regions. The following demonstrates the use of this method in the function WPS_Eval.
import units
wps_stress = {}
eigenvalues = {}
def init(context):
ExtAPI.Log.WriteMessage("Init Demoresult Extension...")
54
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
def Create_WPS_Result(analysis):
ExtAPI.Log.WriteMessage("Launch Create_WPS_Result...")
analysis.CreateResultObject("Worst Principal Stress")
# This function evaluates the specific result (i.e. the Absolute principal stress) on each element
required by the geometry selection
# The input data "step" represents the step on which we have to evaluate the result
def WPS_Eval(result,stepInfo,collector):
global wps_stress
analysis = result.Analysis
ExtAPI.Log.WriteMessage("Launch evaluation of the WPS result: ")
# Reader initialization
reader = analysis.GetResultsData()
reader.CurrentResultSet = stepInfo.Set
# Get the stress result from the reader
stress = reader.GetResult("S")
# Unit sytem management:
# First get the unit system that was used during the resolution
# Second compute the coefficient to be used so that the final result will be returned in the
SI unit system
unit_stress = stress.GetComponentInfo('X').Unit
conv_stress = units.ConvertUnit(1.,unit_stress,"Pa","Stress")
# Loop on the elements related to the collector.Ids list
for elementId in collector.Ids:
# Get the stress tensor related to the current element
tensor = stress.ElementValue(elementId,"X;Y;Z;XY;XZ;YZ")
# Get element information
element = mesh.ElementById(elementId)
nodeIds = element.CornerNodeIds
values = []
# Loop on the nodes of the current element to compute the Von-Mises stress on the element nodes
for i in range(0,nodeIds.Count):
local_wps = WPS(tensor[6*i:6*(i+1)])
# Final stress result has to be returned in theSI unit system
local_wps = local_wps * conv_stress
values.Add(local_wps)
collector.SetValues(elementId, values)
# This function computes the absolute principal stress from the stress tensor
# The Von-Mises stess is computed based on the three eigenvalues of the stress tensor
def WPS(tensor):
# Computation of the eigenvalues
eigenvalues = EigenValues(tensor)
# Extraction of the worst principal stress
wplocal_stress = eigenvalues[0]
if abs(eigenvalues[1])>abs(wplocal_stress):
wplocal_stress = eigenvalues[1]
if abs(eigenvalues[2])>abs(wplocal_stress):
wplocal_stress = eigenvalues[2]
# Return the worst value of the three principal stresses S1, S2, S3
return wplocal_stress
# This function computes the three eigenvalues of one [3*3] symetric tensor
EPSILON = 1e-4
def EigenValues(tensor):
global eigenvalues
eigenvalues = []
a
b
c
d
=
=
=
=
tensor[0]
tensor[1]
tensor[2]
tensor[3]
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
55
Extension Capabilities
e = tensor[4]
f = tensor[5]
if ((abs(d)>EPSILON) or (abs(e)>EPSILON) or (abs(f)>EPSILON)):
# Polynomial reduction
A = -(a+b+c)
B = a*b+a*c+b*c-d*d-e*e-f*f
C = d*d*c+f*f*a+e*e*b-2*d*e*f-a*b*c
p = B-A*A/3
q = C-A*B/3+2*A*A*A/27
if (q<0):
R = -sqrt(fabs(p)/3)
else:
R = sqrt(fabs(p)/3)
phi = acos(q/(2*R*R*R))
S1=-2*R*cos(phi/3)-A/3
S2=-2*R*cos(phi/3+2*3.1415927/3)-A/3
S3=-2*R*cos(phi/3+4*3.1415927/3)-A/3
else:
S1 = a
S2 = b
S3 = c
eigenvalues.Add(S1)
eigenvalues.Add(S2)
eigenvalues.Add(S3)
return eigenvalues
This extension takes advantage of the fact that the collector.Ids property is initialized with the element
numbers related to the selected geometrical entities. This list can be used to evaluate results for each
element. The collector.Ids property contains nodes or element numbers depending on the type
of result defined in the XML file of the extension. For results with the location set to node, collector.Ids
contains a list of node numbers. For results with the location set to elem or elemnode, collector.Ids
contains a list of element numbers.
56
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
As with the loads and results features, the solver definition must be encapsulated within a <simdata>
tag. In this example the context attribute is "Project|Mechanical." When "Project" is specified as a
context attribute, the solver appears as a component in the Workbench Project Schematic (see Figure 34: Project Schematic with External Solver System (p. 58)).
The solver definition begins with the tag <solver>. This tag takes some mandatory attributes:
name: internal name of the solver
version: version of the solver
caption: display name of the solver
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
57
Extension Capabilities
analysis: analysis type addressed by the third-party solver. For compatibility reasons, this attribute must
be set to Static, but this does not prevent you from integrating any type of third-party solver.
physics: physics type addressed by the third-party solver. Today, this attribute must be set to Structural.
This tag as no real impact on what the solver computes.
You must define the callback <onsolve>. This callback is called when the application launches the
solver and thus takes in argument the sol ver object.
You can define a set of properties, which appear in the details view of the analysis. In the example, a
simple property is created to define the maximum number of iterations to be performed by the solver.
By default the value is set to 10.
Figure 34: Project Schematic with External Solver System (p. 58) shows the new system in the toolbox.
Each third-party solver is added into a new category, identified by the caption of the extension; the
system is named by the caption of the solver.
The system related to the third-party solver is equivalent to one standard system that can be created
with the ANSYS solver. The components that build this new system remain the same. Then the user
can add in the schematic a new system related to the solver just as he does for any other systems.
Figure 34: Project Schematic with External Solver System
Following is the code for the extension (file main.py). The solver code is located in a separate file,
solver.py, which is placed in the same folder as main.py. The third line of the main.py script is
"import solver." This Python technique is using separate code for reuse and maintainability. The script
in solver.py defines the SolverEngine class.
import os
import solver
def CreateValuesLoad(analysis):
analysis.CreateLoadObject("Values")
58
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
59
Extension Capabilities
maxIter = int(s.Properties["MaxIter"].Value)
f.write("Max. iteration : %d\n" % (maxIter))
mesh = s.Analysis.MeshData
numEdges = 0
geo = ExtAPI.DataModel.GeoData
nodeIds = []
for asm in geo.Assemblies:
for part in asm.Parts:
for body in part.Bodies:
for edge in body.Edges:
numEdges = numEdges + 1
ids = mesh.MeshRegionById(edge.Id).NodeIds
nodeIds.extend(ids)
steps = []
stepsTmp = []
f.write("Num. edges : %d\n" % (numEdges))
sol = solver.SolverEngine(mesh,initValues,nodeIds)
initValues = sol.Run(maxIter,f,stepsTmp,solbystepTmp)
nodeIds = mesh.NodeIds
sol = solver.SolverEngine(mesh,initValues,nodeIds)
values = sol.Run(maxIter,f,steps,solbystep)
initValues = {}
except StandardError, e:
f.write("Error:\n");
f.write(e.message+"\n");
f.close()
return False
f.close()
return True
def GetSteps(solver):
global steps
return steps
def Save(folder):
global solbystep
fm = System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
try:
stream = System.IO.StreamWriter(os.path.join(folder,"sol.res"),False)
except:
return
try:
fm.Serialize(stream.BaseStream,solbystep)
finally:
stream.Close()
def Load(folder):
global solbystep
if folder==None:
return
fm = System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
try:
stream = System.IO.StreamReader(os.path.join(folder,"sol.res"))
except:
return
try:
solbystep = fm.Deserialize(stream.BaseStream)
finally:
stream.Close()
class ExtSolver1Reader(ICustomResultHeader):
def __init__(self,infos):
self.infos = infos
self.step = 1
60
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
def GetCurrentStep(self):
return self.step
def SetCurrentStep(self,stepInfo):
self.step = stepInfo
def GetStepValues(self):
global steps
return steps
def GetResultNames(self):
return ["VALUES"]
def GetResultLocation(self,resultName):
return ResultLocationEnum.Node
def GetResultType(self,resultName):
return ResultTypeEnum.Scalar
def GetComponentNames(self,resultName):
return [""]
def GetComponentUnit(self,resultName,componentName):
return "Temperature"
def GetValues(self,resultName,collector):
global solbystep
if self.step.Set in solbystep:
values = solbystep[self.step.Set]
for id in collector.Ids:
if id in values:
collector.SetValues(id, [values[id]])
def GetReader(solver):
return ["ExtSolver1Reader"]
The function associated to the <onsolve> callback is Solve. This function creates a file solve.out,
which is read interactively by the application and stored in the solution information.
By default, the application launches the resolution directly into the working directory, so it is not necessary to set the folder in which the solve.out file must be created.
The callback function must return True or False to specify if the solve has succeeded or failed.
Note that it is not possible to return progress information with the current version.
Post Processing
You can create a result reader to expose results.
To do that, you create a class that implements the ICustomResultReader interface. The following
methods need to be implemented. For each method, the expected results that must be returned are
described.
GetCurrentStep(self)
This method must return the current step number.
SetCurrentStep(self,stepInfo)
This method is called each time the current step number is changed.
GetStepValues(self)
This method must return a lost of double values that represents the time steps or frequencies.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
61
Extension Capabilities
GetResultNames(self)
This method must return a list of strings that represents the result names available for the reader.
GetResultLocation(self,resultName)
This method must return the location type of the result identified by the name resultName. The possible
values are node, element, and elemnode.
GetResultType(self,resultName)
This method must return the type of the result identified by the name resultName. The possible values
are scalar, vector, and tensor.
GetComponentNames(self,resultName)
This method must return a list of strings that represents the list of available components available for the
result identified by the name resultName.
GetComponentUnit(self,resultName,componentName)
This method must return the unit name related to the results component identified by the result name
resultName and the component name componentName.
GetValues(self,resultName,collector)
This method must return a list of double values for each component associated to the result identified by
the name resultName.
To specify a dedicated reader, add a <getreader> callback in the solver definition. This callback returns
a list of string, where the first is the name of the reader class and the remainder represents parameters
given to the constructor of the class when the reader is instanced by ACT. Any result exposed in the
method ResultNames() will be available in Mechanical's Results worksheet.
If the name of the result matches a standard result name (like "U"), Workbench applies the same treatment
for this result than for a standard one. So, if the result is named "U", Workbench uses this result to draw
the deformed model.
In the Extsolver1 example, the reader declares one single scalar nodal result VALUES. No deformation is considered.
62
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
63
Extension Capabilities
Figure 37: Solution Information Associated to External Solver (p. 64)a nd Figure 38: Post-processing Associated to External Solver (p. 65) show the two types of output derived from the resolution. Note that
the solution information is interactively displayed during the resolution.
Figure 37: Solution Information Associated to External Solver
64
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
65
Extension Capabilities
</callbacks>
</entry>
</toolbar>
</interface>
<simdata context="DesignModeler">
<geometry name="MyFeature" caption="MyFeature" icon="construction" version="1">
<callbacks>
<ongenerate>generateMyFeature</ongenerate>
<onaftergenerate>afterGenerateMyFeature</onaftergenerate>
</callbacks>
<property name="Face" caption="Face" control="scoping">
<attibutes selection_filter="face"/>
</property>
<property name="Length" caption="Length" control="float" unit="Length" default="1.2 [m]"></property>
<property name="Minimum Volume" caption="Minimum Volume" control="float" unit="Volume" >
<attributes readonlyaftergenerate="true" />
</property>
</geometry>
</simdata>
</extension>
As in previous examples, the XML first defines the extension using a version and name attribute. The
path to the Python script file main.py is specified by the <script> tag. The ACT toolbar is defined
in the <interface> tag, which has a context of DesignModeler. The callback function named createMyFeature is used to create and add the geometry to the DesignModeler environment.
The definition of the geometry is encapsulated by the <simdata> begin and end tags. The attributes
in the <geometry> begin tag provide the name, caption, icon, and version that apply to this geometry.
The geometry <callbacks> tag encapsulates two callbacks <ongenerate> and <onaftergenerate>.
The tag <ongenerate> specifies the name of the Python function that is called when the geometry is
generated by the application. The application provides the geometry type (type IDesignModelerGeoFeature) as the callback argument.
This callback must return a Boolean value to indicate whether the generation has been successful; it
returns true if the generation has succeeded and false if it has failed.
The tag <onaftergenerate> specifies the name of the Python function that is called after the geometry
is generated by the application. The application provides the geometry type (type IDesignModelerGeoFeature) as the callback argument.
To specify additional details about the geometry, you can include additional tags, such as <canadd>,
<onadd>, <oninit>, or <onmigragte> between the <callbacks> begin and end tags.
Below the callbacks definition, you can define the properties that will be applied to the actual definition
of the geometry (in this example, Face and Length). These properties are displayed in the Details View
pane of ANSYS DesignModeler, where the user provides the necessary values to complete the geometry
definition. When we review the Python script in a subsequent section, we will see how the geometry
properties can be retrieved and/or modified.
The following figure shows that each property defined above appears in the Details View pane with
the corresponding names and types of interface control.
66
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Note that the two geometry properties, Face and Length, use different control types.
The Face property uses a scoping control type with the attribute of selection_filter set to face.
This specifies that the value for this property will be one or more faces. The faces will be defined in the
main.py file and then used to generate our geometry.
The Length property uses a float control type, and does not require the definition of one specific callback.
Instead, the XML definition introduces a physical quantity dependency with the unit attribute, which
specifies that this property is consistent with a length. The default attribute specifies a default value
of 1.2[m]; this default value is exposed in the Details View pane each time a new load is created.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
67
Extension Capabilities
for face in faces:
centroid = face.Centroid
uv = face.ParamAtPoint(centroid)
normal = face.NormalAtParam(uv[0], uv[1])
radius = math.sqrt(face.Area/(math.pi*2))
xdir = [1., 0., 0.]
vector = vectorProduct(xdir, normal)
if norm(vector)<1.e-12:
xdir = [0., 1., 1.]
s = scalarProduct(xdir, normal)
xdir = [xdir[0]-s*normal[0],xdir[1]-s*normal[1],xdir[2]-s*normal[2]]
n = norm(xdir)
xdir[0] /= n
xdir[1] /= n
xdir[2] /= n
arc_generator = builder.Primitives.Wire.CreateArc(radius, centroid, xdir, normal)
arc_generated = arc_generator.Generate()
disc_generator = builder.Operations.Tools.WireToSheetBody(arc_generated)
normal[0] *= -1
normal[1] *= -1
normal[2] *= -1
extrude = builder.Operations.CreateExtrudeOperation(normal,length)
cylinder_generator = extrude.ApplyTo(disc_generator)[0]
bodies.Add(cylinder_generator)
feature.Bodies = bodies
feature.MaterialType = MaterialTypeEnum.Add
return True
def afterGenerateMyFeature(feature):
edges = []
minimum_volume = System.Double.MaxValue
for body in feature.Bodies:
body_volume = 0
if str(body.BodyType) == "GeoBodySolid":
body_volume = body.Volume
if body_volume <= minimum_volume:
minimum_volume = body_volume
for edge in body.Edges:
edges.Add(edge)
else:
ExtAPI.Log.WriteMessage("Part: "+body.Name)
feature.Properties["Minimum Volume"].Value = minimum_volume
ExtAPI.SelectionManager.NewSelection(edges)
named_selection = ExtAPI.DataModel.FeatureManager.CreateNamedSelection()
ExtAPI.SelectionManager.ClearSelection()
68
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
69
Extension Capabilities
The material.Type allows us to enter different properties such as Freeze, Cut, and Add. The image
below illustrates the resulting geometry given selection of the different properties.
Figure 40: Effect of different material type properties on the geometry
70
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
71
Extension Capabilities
DX takes advantage of the ANSYS Workbench platform to allow parametric studies in a generic way for
any simulation project. Regardless of the number of solvers and physics or the complexity of the
workflow involved to execute the simulation, DX sees the same simplified representation of the project
and interacts with it only in terms of parameters, design points, and the associated services.
Figure 42: DesignXplorer DOEs in an ANSYS Workbench Project
This generic architecture makes it possible to implement a variety of algorithms without needing to
worry about the communication with solvers. Since the external methods are hosted by DX, they also
take advantage of the ANSYS Workbench platform architecture to work with any kind of simulation
project defined in ANSYS Workbench, with no additional implementation effort.
Optimization Study
Variables
Variables
DOE domain
Optimization domain
Parameter relationships
Objectives
Constraints
72
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
The DX Component
DX exposes several types of systems in Workbench, with each system type corresponding to one of its
parametric features such as Parameters Correlation, Response Surface, Six Sigma Analysis, etc. DX
components can be found in the Design Exploration toolbox.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
73
Extension Capabilities
74
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
The DX Extension
External DOEs and optimizers can be packaged and installed as Workbench extensions. When the extension is installed and loaded, DX detects the external DOEs or optimizers and exposes them as additional options in the DesignXplorer component. If the user selects one of these custom methods, DX
delegates to the selected external option; it delegates sampling resolution to the external sampling
and optimization resolution to the external optimizer. Note that when an external option is used, the
Workbench session is journaled and can be replayed as usual.
The extension is a container for one or more DOEs or optimizers. The DOEs and optimizers themselves
are generally provided as compiled libraries included in the .wbex extension file.
Implementing a DX Extension
A DX extension is comprised of three main parts:
XML file that declares, defines and configures the extension
Python scripts that implement callbacks
ISamplingMethod or IOptimizationMethod implementation, which is the adapter to your existing
implementation. This is typically achieved in C# or IronPython.
This section describes each of these pieces and includes references to several examples of functional
DX extensions.
Implementation Requirements
The implementation of a DX extension requires:
ANSYS Workbench installation
ANSYS Customization Suite license
IronPython, which is provided as part of ANSYS Workbench in the directory <installdir>\commonfiles\IronPython
Microsoft Visual Studio 2010 SP1 for C# implementation
Microsoft Visual Studio 2010 SP1 or equivalent for C/C++ implementation
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
75
Extension Capabilities
Filename of the main Python script (as specified by the <script> element)
Name of the Python function to invoke when initializing the extension (as specified by the OnInit callback)
In a DX extension, the OnInit callback is the correct place to load the DLL containing the external
sampling. Another callback named OnTerminate is invoked when the extension is unloaded and is
the correct place to perform cleanup operations and unload the DLL.
The specificity of a DX extension is to define external sampling or optimization methods to be used by
DX. The definitions are encapsulated in a <simdata> element, where the context attribute is set to
DesignXplorer. The main elements used to declare and define the DOEs are shown in Figure 45: Declaration and Definition of an External DOE (p. 76). The main elements used to declare and define the
optimizers are shown in Figure 46: Declaration and Definition of an External Optimizer (p. 77).
Figure 45: Declaration and Definition of an External DOE
In Figure 45: Declaration and Definition of an External DOE (p. 76), the DOE defined is called FullFactorial.
The two attributes framed in red are examples of capabilities being defined for this DOE. Here we can
see that for FullFactorial:
The LogFile attribute is set to true, so the sampling has the capability to use the DX API to generate a
log file in the Workbench project.
The CustomTable attribute is set to false, so the DOE does not have the capability to handle the custom
table available in DX.
All other capabilities are configured per the default values. For a listing of capabilities, see DX Extension
Capabilities (p. 78).
The callbacks to hook up with DX are framed in blue. Note that the OnCreate callback, which is invoked
to obtain an ISamplingMethod instance, is mandatory. All other callbacks are optional.
Finally, all of the properties declared for the DOE in Figure 45: Declaration and Definition of an External
DOE (p. 76) are framed in orange. These properties allow the user to control specific settings of the
76
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
In Figure 46: Declaration and Definition of an External Optimizer (p. 77), the extension is named MyOptimizer and defines two different external optimizers. The declaration for each optimizer is marked with
a green bracket. Each optimizer will be managed by DX as an independent optimization method.
In Figure 46: Declaration and Definition of an External Optimizer (p. 77), the first optimizer defined is
called MyOptimizer. The two attributes framed in red are examples of capabilities being defined for
this optimizer. Here we can see that for MyOptimizer:
The SeekObjective attribute is set to false, so the optimizer does not have the capability to handle
the Seek Target objective available in DX.
The LogFile attribute is set to true, so the optimizer has the capability to use the DX API to generate a
log file in the Workbench project.
All other capabilities are configured per the default values. For a listing of capabilities, see Optimization
Example (p. 78).
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
77
Extension Capabilities
The callbacks to hook up with DX are framed in blue. Note that the OnCreate callback, which is invoked
to obtain an IOptimizationMethod instance, is mandatory. All other callbacks are optional.
Finally, all of the properties declared for the optimizer in Figure 46: Declaration and Definition of an
External Optimizer (p. 77) are framed in orange. These properties allow the user to control specific
settings of the algorithm, access relevant output information (e.g. number of iterations, final convergence
metrics, status), or whatever else the optimizer needs to expose as a result of the optimization run.
DX Extension Capabilities
A DX extension is designed to solve a specific range of problems, and its implementation is characterized
by complementary features and limitations. To allow DX to determine when a given sampling or optimization method is applicable, depending on the current DOE or optimizer definition, it is necessary to
declare the main capabilities of each external method. There are also optional capabilities used by DX
to adjust the user interface according to what complementary features are supported by the external
method.
For external DOEs, the capabilities are specified in the XML file as attributes of the <sampling> element.
For external optimizers, the capabilities are specified in the XML file as attributes of the <optimizer>
element.
Main Capabilities
The main capabilities are used to determine if the external sampling or optimization method can be
applied to the problem as it is currently defined. If the external method has the required capabilities,
it is available as a menu option in the DX Properties view (applicable external samplings are available
in the Design of Experiments Type menu, and applicable optimizers are available in the Method Name
menu). If an external method is not applicable, it is not listed as a menu option. Each modification to
the DOE or optimization study (e.g. modifying an existing input parameter, enabling or disabling an
input parameter, etc.) triggers an evaluation of the relevant capabilities to reassess whether the external
method is applicable and will be made available to the user.
DOE Example
The external sampling FullFactorial, defined previously in Figure 45: Declaration and Definition of an External DOE (p. 76), has MaximumNumberOfInputParameters capability equal to 10. As a consequence,
as soon as the user defines more than 10 input parameters, FullFactorial is removed from the list of
available sampling methods. If the user then changes the DOE study so that the number of input parameters
is less than or equal to 10, FullFactorial is immediately restored as an available option.
Note that if the user selects FullFactorial first and defines more than 10 input parameters afterward,
the sampling method is retained. Given the incompatibility of the sampling method and the number
of input parameters, however, the state of the DOE will turn to Edit Required and a Quick Help
message will be provided to explain why the sampling cannot be launched as currently configured.
Optimization Example
The external optimizer MyFirstOptimizer, defined previously in Figure 46: Declaration and Definition of
an External Optimizer (p. 77), does not have the SeekObjective capability. As a consequence, as soon
as the user defines a Seek Target objective, MyFirstOptimizer is removed from the list of available optimization methods. If the user then changes the optimization study so that the Seek Target objective is no
longer defined, MyFirstOptimizer is immediately restored as an available option.
Note that if the user selects MyFirstOptimizer first and defines the unsupported Seek Target objective afterward, the optimization method is retained. Given the incompatibility of the optimization
method and the objective, however, the state of the Optimization will turn to Edit Required and
78
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Optimizer
MaximumNumberOfInputParameters
MaximumNumberOfInputParameters
MaximumNumberOfDoubleParameters
MaximumNumberOfDoubleParameters
MaximumNumberOfDoubleListParameters
MaximumNumberOfDoubleListParameters
MaximumNumberOfIntegerListParameters
MaximumNumberOfIntegerListParameters
ParameterRelationship
ObjectiveOnInputParameter
ConstraintOnInputParameter
MinimizeObjective
MaximizeObjective
SeekObjective
LessThanConstraint
GreaterThanConstraint
EqualToConstraint
InsideBoundsConstraint
MinimumNumberOfObjectives
MaximumNumberOfObjectives
MinimumNumberOfConstraints
MaximumNumberOfConstraints
BasedOnResponseSurfaceOnly
BasedOnDirectOptimizationOnly
For a comprehensive list of capabilities, see the "Sampling" and Optimizer sections in the ACT Reference
Guide for DesignXplorer.
Optional Capabilities
The optional capabilities are used to enable or disable specific options or features of DX according to
the level of support provided by the selected external method. After the main capabilities have estabRelease 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
79
Extension Capabilities
lished that a method is applicable to a given DOE or optimization study, the optional capabilities determine which features will be exposed for that method in the DX user interface.
For example, the LogFile capability is declared for the sampling defined in Figure 45: Declaration and
Definition of an External DOE (p. 76), FullFactorial, and also for the optimizer defined in Figure 46: Declaration and Definition of an External Optimizer (p. 77), MyFirstOptimizer. As a result, the corresponding
features to manage and expose the log file are enabled in DX and exposed in the user interface. If this
capability was not declared or was set to false, DX would adjust its user interface to hide the access
to the log file because it is not supported by this external method.
As additional examples:
If the selected sampling does not support the Custom Table capability, the Custom Table is not available
in the user interface.
If the selected optimizer does not support the Maximize objective type, then the objective types available
in the user interface are limited to Minimize and Seek Target.
If the optimizer does not support importance levels on objectives, the Objective Importance property is
not available in the Property view of the optimization criterion.
For a comprehensive list of capabilities, see the "Sampling" and Optimizer sections in the ACT Reference
Guide for DesignXplorer.
Notes on Monitoring
Notes on Sampling Monitoring
DX provides user interface elements that allow the user to monitor the progress of a sampling, in addition
to the progress and log messages.
80
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Notes on Results
Notes on Sampling Results
The DOE post-processing is similar for all DOE methods. It is based on results data rendered graphically
and/or as tables in the user interface.
Once the DOE is generated, DX extracts all results provided by the sampling in order to generate postprocessing tables and charts:
Sample points from the ISamplingMethod.Samples property
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
81
Extension Capabilities
In some cases, DX builds missing results if one of these result types is not supported. For example, if
the optimization method provides the sample points without the candidate points, DX applies its own
sorting logic to generate the candidate points based on objectives and constraints definitions. If the
optimizer provides the sample points without the Pareto fronts indices, DX builds missing data based
on objectives and constraints definitions.
Note
At present, the mixing of ACT-defined and installed tasks and taskgroups is not supported;
ACT-defined tasks cannot be added to installed taskgroups, and installed tasks cannot be
added to ACT-defined taskgroups.
The figure that follows shows a Workbench Mesh Transfer taskgroup that takes an upstream mesh and
passes it to a downstream Fluent taskgroup. For details, see the Mesh Transfer (p. 234) example.
82
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
This section discusses how to create the various files required to define custom ACT workflows in
Workbench, exposing custom taskgroups and tasks as systems and components on the Project
Schematic.
The following topics are addressed:
The Custom Workflow Creation Process
Creating the Extension Definition XML File
Creating the IronPython Script
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
83
Extension Capabilities
Once youve installed your extension, you can load it into Workbench via the Extensions Manager.
Upon loading your extensions, the custom taskgroup(s) will be exposed as systems in a new Workbench
Toolbar group, as shown below:
Figure 48: Custom Taskgroups in the Workbench Toolbox
These custom taskgroups can be added to the Project Schematic. When you invoke an Update on a
custom task within the taskgroup, the add-in may:
1. Obtain the inputs.
2. Prepare the inputs.
3. Write input file(s).
4. Run the external solver or performs calculations.
5. Read output file(s).
6. Set the parameters or properties to the calculated values.
84
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
85
Extension Capabilities
visible=""
persistent="" parameterizable="" keytype="" valuetype="" elementtype=""/>
</propertygroup>
<property name="" caption="" control="" default="" readonly="" needupdate= visible=""
persistent="" parameterizable="" keytype="" valuetype="" elementtype=""/>
<parameters>
<parameter name= caption= usage= control= version=1/>
</parameters>
<inputs>
<input/>
<input type="" format=""/>
</inputs>
<outputs>
<output type="" format=""/>
</outputs>
</task>
</tasks>
<taskgroups>
<taskgroup name="" caption="" icon="" category="" abbreviation="" version="1"
isparametricgroup=False>
<includetask name=/>
<includeGroup name=/>
</taskgroup>
</taskgroups>
</workflow>
</extension>
Defining a Task
One or more tasks can be defined in the <tasks> node. Individual tasks are defined in a <task> child
node.
In each task definition, you must include the name and version attributes. Child nodes are can be
used to specify callbacks, inputs and outputs, properties, parameters, and context menus.
The basic structure of a task definition is shown below:
<tasks>
<task name="" caption="" icon="" version="1">
<callbacks>
<onupdate></onupdate>
<onrefresh></onrefresh>
<oninitialize></oninitialize>
<onedit></onedit>
<onreset></onreset>
<onstatus></onstatus>
<onreport></onreport>
</callbacks>
<contextmenus>
<entry name= caption= icon= version=1 priority= type=>
<callbacks>
<onclick></onclick>
</callbacks>
</entry>
</contextmenus>
<propertygroup name= caption=>
<property name="" caption="" control="" default="" readonly="" needupdate= visible=""
persistent="" parameterizable="" keytype="" valuetype="" elementtype=""/>
</propertygroup>
<property name="" caption="" control="" default="" readonly="" needupdate= visible=""
persistent="" parameterizable="" keytype="" valuetype="" elementtype=""/>
<parameters>
<parameter name= caption= usage= control= version=1/>
</parameters>
<inputs>
<input/>
<input type="" format=""/>
</inputs>
<outputs>
86
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Callbacks
Callbacks to IronPython functions are specified in the <callbacks> node. The following callbacks are
available: <onrefresh>, <oninitialize>, <onupdate>, <onedit>, <onreset>, <onstatus>,
and <onreport>.
Definition of the <onedit> callback automatically creates a default Edit context menu for the task.
Context Menus
If you specify the <onedit> callback in your extension definition file, a default Edit context menu option
is automatically created for the task. However, it is possible to define additional GUI operations for each
task.
Custom GUI operations are specified in the optional <contextmenus> node. At minimum, the
context menu entry definition must include the name and version attributes. When the optional
type attribute is defined, it must be set to ContextMenuEntry.
Each entry in the <contextmenus> node must have an <onclick> callback.
The basic structure of the <contextmenus> node is shown below:
<contextmenus>
<entry name= caption= icon= version=1 priority= type=>
<callbacks>
<onclick></onclick>
</callbacks>
</entry>
</contextmenus>
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
87
Extension Capabilities
<input/>
</inputs>
<outputs>
<output format="FluentMesh" type="SimulationGeneratedMesh"/>
</outputs>
</task>
For a list of supported transfer types and their corresponding transfer properties, see Appendix B (p. 317).
Property Groups and Properties
Instead of using parameters to drive your simulation, you can work through the data model, simplifying
data access by defining custom properties.
Properties can be defined in the optional <propertygroup> node. At minimum, each property
group definition must include the name attribute. The caption attribute will be used as the group
category name in the Workbench Property view if the child properties are visible.
Individual properties can be defined in the <property> node, which can be either a child to
<propertygroup> or a stand-alone definition at the same level. At minimum, each property
definition must include the name and control attributes.
The basic structure of a property definition is shown below:
<propertygroup name= caption=>
<property name="" caption="" control="" default="" readonly="" needupdate=
visible=""
persistent="" parameterizable="" keytype="" valuetype="" elementtype=""/>
</propertygroup>
<property name="" caption="" control="" default="" readonly="" needupdate=
visible=""
persistent="" parameterizable="" keytype="" valuetype="" elementtype=""/>
Properties are linked to entity definitions in the referenced IronPython script, which makes use of
the following commands:
GetCustomEntity: Gets the property-containing entity.
GetCustomEntityPropertyValue: Gets the property. This query obtains the entity property value
for a custom property defined on the task.
SetCustomPropertyValue: Sets the property. This command sets the entity property value for a
custom property defined on the task.
Parameters
You can integrate an external application with the Project Schematic by defining parameters that are
created dynamically at initialization.
Parameters are defined in the optional <parameters> node. At minimum, each parameter definition must include the following attributes: name, usage, control, and version.
The basic structure of a parameter definition is shown below:
<parameters>
<parameter name= caption= usage= control= version=1/>
</parameters>
88
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Defining a Taskgroup
The sole purpose of a taskgroup is to collect tasks. One or more taskgroups can be defined in the
<taskgroups> node. Individual taskgroups are defined in a <taskgroup> child node.
At minimum, each taskgroup definition must include the taskgroup name and version attributes. The
<includetask> and <includeGroup> child nodes are to specify one or more tasks or nested
taskgroups to be included.
If you define a caption, it overrides the task-level caption. Otherwise, the taskgroup-level caption is
used.
The basic structure of a taskgroup definition is shown below:
<taskgroups>
<taskgroup name="" caption="" icon="" category="" abbreviation="" version="1" isparametricgroup=False>
<includetask name=/>
<includeGroup name=/>
</taskgroup>
</taskgroups>
Note
At present, the mixing of ACT-defined and installed tasks and taskgroups is not supported;
ACT-defined tasks cannot be added to installed taskgroups, and installed tasks cannot be
added to ACT-defined taskgroups. Also, nested taskgroups within a taskgroup are not recognized by Workbench at 16.2.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
89
Extension Capabilities
For example, a material transfer to a downstream Engineering Data task must set the DataReference
TransferFile property on a MatML31 data object to the file reference of a registered matmlformatted XML file, all completed during the Update routine.
Convenience APIs
Convenience APIs are IronPython queries that provide simple access to task-stored input and output
data. The available convenience APIs are:
GetInputDataByType
Returns a List<object> containing upstream data for a given type. For example:
upstreamData =
container.GetInputDataByType(InputType="MeshingMesh")
meshFileRef = None
upstreamDataCount = upstreamData.Count
if upstreamDataCount > 0:
meshFileRef = upstreamData[0]
GetOutputData
Returns a Dictionary<string, List<DataReference>> holding the task's output types. For
example:
outputRefs = container.GetOutputData()
meshOutputSet = outputRefs["SimulationGeneratedMesh"]
meshOutput = meshOutputSet[0]
meshOutput.TransferFile = meshFileRef
GetCustomEntity
Obtains the custom data entity from a container based on the entity's name and type. If the name and
type are not specified, the default ACT object is returned. This object contains the properties defined by
the workflow task from the <propertygroup> and <property> blocks.
entity = ACT.GetCustomEntity(container)
GetCustomEntityPropertyValue
This query returns the value of a property defined on a custom data entity.
inputValue = ACT.GetCustomEntityPropertyValue(entity, "Input")
SetCustomEntityPropertyValue
This command handles the setting of a custom entity's property value.
ACT.SetCustomEntityPropertyValue(entity, "Output", outputValue)
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
As in previous examples, the XML file first defines the extension using a version and name attribute.
The path to the Python script file main.py is specified by the <script> tag.
The definition of the load is encapsulated by the <simdata> begin and end tags. The context attribute
for <simdata> has been set to Study , which makes the extension compatible with AIM. The attributes
in the <load> begin tag provide the name, version, caption, icon, support status, and color that apply
to this load. The color attribute is defined in a hexadecimal format. This color is used to contrast the
load when it is displayed on the model. The <callbacks> tag encapsulates the callback <getsolvecommands>. This tag specifies the name of the Python function that is called when the solver input
file is generated by the application. Consequently, the related Python function is responsible for generating the commands that describe the load within the ANSYS input file.
Below the callbacks definition, you can define the properties that will be applied to the actual definition
of the load. These properties are displayed in the specific ACT object created by the extension, where
the user provides the necessary values to complete the load definition.
Note that neither property requires the definition of a callback.
The first property, Geometry, uses a scoping control type, and has the selection_filter attribute
set to face. This property allows you to select the face of the geometry to which the custom pressure will
be applied.
The second property, Expression, uses a float control type, which provides the property with access
to AIM expressions functionality. Consequently, you can enter an expression into the Expression property
field and expect a float. Setting datatype to double introduces a physical quantity dependency with the
unit option, which is set to Pressure; this combination specifies that this property is consistent with a
pressure. Finally, setting isparameter to true specifies that this expression can be parameterized.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
91
Extension Capabilities
def writeNodeId(load, stream):
ExtAPI.Log.WriteMessage("writeNodeId...")
stream.WriteLine("/com, GetSolveCommands")
property_expression = load.PropertyByName("Expression")
expression = property_expression.Value
ExtAPI.Log.WriteMessage(expression.ToString())
if expression=="":
return None
property_geometry = load.PropertyByName("Geometry")
refIds = property_geometry.Value.Ids
ExtAPI.Log.WriteMessage(refIds.ToString())
mesh = ExtAPI.DataModel.MeshDataByName("Mesh 1")
for refId in refIds:
meshRegion = mesh.MeshRegionById(refId)
ExtAPI.Log.WriteMessage(meshRegion.ToString())
nodeIds = meshRegion.NodeIds
for nodeId in nodeIds:
node = mesh.NodeById(nodeId)
stream.WriteLine("F,"+nodeId.ToString()+", FX,"+expression.ToString()+"\n")
The main.py Python file defines the writeNodeId function, which writes the value of the Expression
property on the geometry nodes scoped for the load.
The following figure shows that the CustomPressure ACT load weve created is now made available
to be added as a boundary condition in AIM.
92
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
The following figure shows the status of the load once all the properties are defined.
Figure 50: CustomPressure Load with Properties Defined
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
93
Extension Capabilities
94
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Note
In future releases, the IronPython commands used to define fluid dynamics features
may be modified to ensure consistency with AIM Journaling and Scripting functionality.
For the information on whether a given command has been modified or deprecated,
refer to the ACT Reference Guide.
import clr
clr.AddReference("Ansys.Study.Proxies.Customization")
from Ansys.Study.Proxies.Customization.Analysis import AFDObject
def getcmds(load,stream):
velocity = load.Properties["InletVelocity"]
pressure = load.Properties["OutletPressure"]
faces = []
faces += load.Properties["Inlet"].Value.Ids
faces += load.Properties["Outlet"].Value.Ids
geo = load.Analysis.GeoData
wallFaces = []
for part in geo.Assemblies[0].Parts:
for body in part.Bodies:
for face in body.Faces:
if not faces.Contains(face.Id) and not wallFaces.Contains(face.Id):
wallFaces.Add(face.Id)
boundary = AFDObject.CreateBoundary()
boundary.SetProperty("BoundaryType","Inlet")
boundary.SetProperty("Location",load.Properties["Inlet"].Value.Ids)
boundary.SetProperty("Flow.Option","Velocity")
boundary.SetProperty("Flow.Velocity.Magnitude",velocity.Value.ToString()+' ['+velocity.UnitString+']')
boundary.Send(stream)
boundary = AFDObject.CreateBoundary()
boundary.SetProperty("BoundaryType","Outlet")
boundary.SetProperty("Location",load.Properties["Outlet"].Value.Ids)
boundary.SetProperty("Flow.Option","Pressure")
boundary.SetProperty("Flow.Pressure.GaugeStaticPressure",pressure.Value.ToString()+'
['+pressure.UnitString+']')
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
95
Extension Capabilities
boundary.Send(stream)
boundary = AFDObject.CreateBoundary()
boundary.SetProperty("BoundaryType","Wall")
boundary.SetProperty("Location",wallFaces)
boundary.Send(stream)
The function getcmds is defined in the main.py Python file for the AFDLoad extension. This function
writes commands to the solver input file. The required input arguments are load and stream, where
load is the load object and stream refers to the solver input file. In our example, the function
getcmds is referenced in the AFDLoad.xml file by the <getsolvecommands> callback. When
called, it creates the boundaries for the AFD object, defines boundary properties, and specifies the
face(s) to which the boundary will be applied. Within this function:
The CreateBoundary() method is applied to AFDObject to create a boundary. (This AFD object was
imported by the import command at the top of the Python file.)
boundary = AFDObject.CreateBoundary()
With boundary.SetProperty, we can also specify the location (faces, bodies, etc.) to which the
boundary will be applied. To do so, we can use the scoping properties previously defined in the extension.
The location property expects a list of identifiers.
boundary.SetProperty("Location",load.Properties["Inlet"].Value.Ids)
To the property that just created, we can add an option representing a velocity (for an inlet) or a pressure
(for an outlet).
boundary.SetProperty("Flow.Option","Velocity")
To the option just added, we add a float value. (This float value could come from a property defined in the
XML file.) We also have the ability to specify a unit.
boundary.SetProperty("Flow.Velocity.Magnitude",velocity.Value.ToString()+' ['+velocity.UnitString+']')
The following figure shows that the InOut ACT load weve created is now made available to be added
as a fluids boundary condition in AIM. This load includes all the properties defined in the extension.
96
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
The following figure shows the status of the load once all the properties are defined.
Figure 52: InOut Load with Properties Defined
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
97
98
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Workbench Wizards
A Workbench wizard can be created to be executed on the Workbench Project tab or across a combination of the Project tab and target applications such as Mechanical or DesignModeler.
Project Wizard
A Workbench Project wizard is executed in the ANSYS Workbench Project tab. It can incorporate any dataintegrated application with Workbench journaling and scripting capabilities, such as ANSYS DesignXplorer
or ANSYS Fluent, into the simulation workflow.
Mixed Wizard
A mixed wizard is executed across the ANSYS Workbench Project tab and one or more supported target
applications with Workbench journaling and scripting capabilities. A mixed process provides native
workflow guidance in both the Project tab and the target application.
99
Note
For examples of all the different types of guided processes, see Custom Guided Process Examples (p. 240).
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Note
Syntax differences for other kinds guided processes (other wizard types or custom templates)
will be noted.
Below is our XML extension file, WizardDemos.xml.
<extension version="2" minorversion="1" name="WizardDemos">
<guid>6D33EFFC-C521-4859-8273-BA320044B6B8</guid>
<author>ANSYS Inc.</author>
<description>Simple extension to test wizards in different contexts.</description>
<script src="main.py" />
<interface context="Project">
<images>images</images>
</interface>
<wizard name="ProjectWizard" version="1" context="Project" icon="wizard_icon">
<description>Simple wizard for demonstration in the Workbench Project page.</description>
<step name="Geometry" caption="Geometry" version="1" context="Project"
CustomContentFile="help/geometry.html">
<description>Create a geometry component.</description>
<callbacks>
<onupdate>CreateGeometry</update>
<onreset>DeleteGeometry</reset>
</callbacks>
<propertygroup display="caption" name="definition" caption="Basic properties" >
<property name="filename" caption="Geometry file name" control="fileopen" />
<property name="myint" caption="Integer value" control="integer" />
<property name="mytext" caption="Text value" control="text" />
<property name="myquantity" caption="Quantity value" control="float" unit="Pressure" />
<property name="myreadonly" caption="Readonly value" control="text" readonly="true"
default="My value" />
<propertygroup display="property" name="myselect" caption="List of choice" control="select"
default="Option1">
<attributes options="Option1,Option2" />
<property name="option1" caption="Option1 value" control="text" visibleon="Option1" />
<property name="option2first" caption="Option2 first value" control="float" unit="Pressure"
visibleon="Option2" />
<property name="option2seond" caption="Option2 second value" control="float" unit="Length"
visibleon="Option2" />
</propertygroup>
</propertygroup>
</step>
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
101
Extension definition:
The standard extension definition is the same. The name, version, and IronPython script reference are
unchanged. In our wizard example, the interface context is set to Project because the extension will
be run on the Workbench Project tab.
102
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Note
For a mixed wizard, the <wizard> context would still be set to Project because the
guided process will be launched from the Project tab. Each step in a mixed guided process
would have its context set to the application in which the step will be executedeither
DesignModeler or Mechanical.
For an AIM custom template, the <wizard> context is always set to Study. The name
value is the name of the newly created system that appears under Simulation Process
Templates.
Step definitions:
For each step, the required name, caption, and version attributes are defined. In our wizard example,
note that the optional context is set to Project for all the steps; the steps involve creation of a geometry
and two systems in the Project Schematic, so the steps are executed on the Workbench Project tab.
Note
For each step in a mixed guided process, the context would be set to the application
in which the step will be executedeither DesignModeler or Mechanical.
Optional attributes are defined for various steps. For example, the HelpFile attribute indicates
the file containing custom help content to be shown in the UI.
Child nodes define callbacks and properties.
Callback definitions:
Callbacks execute an action that has been defined in the IronPython script for the guided process. Each
callback receives the current step as a method argument.
The required <onupdate> callback is invoked when you click the Next button for a Workbench wizard.
In our wizard example, it executes the actions CreateGeometry, CreateMechanical, and CreateFluent.
The <onrefresh> callback is invoked when the next step is initialized. It initiates changes to the interface, so you can use this callback to change the appearance of the guided process, initialize a value to
be used in the current step, instantiate variables, access data of an existing project, etc. In our wizard
example, the <onrefresh> callback executes the RefreshReport and RefreshMechanical
actions.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
103
Note
For an AIM custom template, only the <onupdate>, <onrefresh>, and <onreset>
callbacks are supported.
The <onupdate> callback is invoked when you click the Create Simulation Process
button. Typically, it is used to insert the content of an existing journal into the guided
process to create a workflow and establish boundary conditions, mesh, and solver
options.
The <onreset> callback is used to reset situations where the guided process has not
been completed correctly; it allows you to go back to the process properties and
modify them.
Property definitions:
Properties, property groups, and property visibility controls are defined with the same syntax as for a
standard extension property.
The required name , caption , and control attributes are defined for all the properties. The
control attribute specifies the control type for the property. The standard select, float, integer, scoping, text, and fileopen property types are supported. Advanced types such as
applycancel and custom are also supported.
Optional attributes are also defined for various properties.
The unit attribute specifies the units for the property value.
The readonly attribute specifies whether the property value is editable.
The default attribute specifies the default property value.
The visibleon attribute controls the visibility of the property. In our example, it is used to
control the display of conditional options in a property group.
The <propertygroup> node is used to create groupings of properties. In our example:
For the first property group, no control is defined, so the group is a list of individual properties
inside the <propertygroup> tags.
The second property group is embedded within the first.
In our example, the control attribute set to select , which provides a drop-down list.
The attributes options tag defines the available options.
The visibleon attribute defines the properties in the group are defined as conditional based
on selection from the drop-down.
The <onvalidate> property callback is used to validate the value entered for a property.
104
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Note
Syntax differences for other kinds guided processes (other wizard types or custom templates)
will be noted.
Below is the main.py script referenced by our XML extension file.
geoSystem = None
dsSystem = None
fluentSystem = None
def CreateGeometry(step):
global geoSystem
template1 = GetTemplate(TemplateName="Geometry")
geoSystem = template1.CreateSystem()
geometry1 = geoSystem.GetContainer(ComponentName="Geometry")
geometry1.SetFile(FilePath=step.Properties["definition/filename"].Value)
def DeleteGeometry(step):
global geoSystem
geoSystem.Delete()
def RefreshMechanical(step):
tree = step.UserInterface.GetPanel("Tree")
root = tree.CreateTreeNode("Root")
node1 = tree.CreateTreeNode("Node1")
node2 = tree.CreateTreeNode("Node2")
node3 = tree.CreateTreeNode("Node3")
root.Values.Add(node1)
root.Values.Add(node2)
node2.Values.Add(node1)
node2.Values.Add(node3)
root.Values.Add(node3)
tree.SetTreeRoot(root)
def CreateMechanical(step):
global dsSystem, geoSystem
template2 = GetTemplate(
TemplateName="Static Structural",
Solver="ANSYS")
geometryComponent1 = geoSystem.GetComponent(Name="Geometry")
dsSystem = template2.CreateSystem(
ComponentsToShare=[geometryComponent1],
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
105
This script defines all the actions executed by the callbacks in the XML file. Each step defined in the
XML file may include multiple actions. In our example XML extension file:
106
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Note
For a mixed wizard, the definition of the first step executed in the Project tab also specifies
the applications and component names from which subsequent steps will be executed. For
instance, in the excerpted code sample below, we can see that multiple actions are defined;
these will be called by the steps in the process definition file.
def action1(step):
template1 = GetTemplate( TemplateName="Static Structural", Solver="ANSYS")
system1 = template1.CreateSystem()
geometry1 = system1.GetContainer(ComponentName="Geometry")
geometry1.SetFile(FilePath=step.Properties["filename"].Value)
nextStep = step.NextStep
if nextStep!=None:
nextStep.SystemName = system1.Name
nextStep.ComponentName = "Geometry"
thirdStep = step.Wizard.Steps["Step3"]
if thirdStep!=None:
thirdStep.SystemName = system1.Name
thirdStep.ComponentName = "Model"
Wizard Help
You can implement one HTML file for the wizard and one additional HTML file for each defined step.
To implement help files in your wizard, specify the HTML file for a step by using the HelpFile attribute
in the XML step definition.
In Step 1 (the geometry step) of our Project wizard example, the HelpFile attribute is set to
help/geometry.html.
<step name="Geometry" caption="Geometry" version="1" context="Project" HelpFile="help/geometry.html">
<description>Create a geometry component.</description>
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
107
<callbacks>
<update>CreateGeometry</update>
<reset>DeleteGeometry</reset>
</callbacks>
...
The geometry.html file contains both text and a reference to the image geometry.png, along
with the necessary display information to display the file contents in the Help panel at the bottom of
the guided process UI.
Note
In order to use custom help in an AIM custom template, the user of the extension must have
write access to the following directory:
%AWP_ROOT162%\commonfiles\help\ACSHelpServer\docu_aim_html\custom
To implement help files in your custom template:
1. Create a help folder in your extension directory.
2. Create one HTML help file for your template and one for each of its defined properties, naming the files as
follows:
Template: <templatename>.html
Property: <templatename_propertyname>.html
When the extension is loaded to AIM, the folder will be copied into the %AWP_ROOT162%\commonfiles\help\ACSHelpServer\docu_aim_html\custom directory for display in the help panel.
108
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Loading
Your guided processes will not be visible until you have loaded them to your project or Study. To load
a guided process:
1. In the main menu, select Extensions > Manage Extensions.
2. In the Extensions Manager, select the guided processes you want to load.
3. Click OK.
In Workbench or a target application, an Open Wizard button will be added to the toolbar.
In AIM, an icon for each loaded custom template will be added under Simulation Process Templates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
109
110
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Top: Shows general information about the wizard and a logo of your choice.
Left: Shows a list of the steps in the wizard, with the current step highlighted.
Right: Shows the data-entry and data-display fields for the selected step.
Bottom: Shows the custom help for the selected step.
Note
The overall content and function of the wizard interface within the Mechanical or DesignModeler application will be the same as in Workbench. However, the display of the interface
may vary slightly according to the application.
111
112
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
113
3. Now, with your custom workflow in place, you can work through the simulation as usual.
114
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Note
When moving to a different property, you must click the data panel Help icon in order refresh
the Help panel content.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
115
116
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
APIs Description
ACT supports application customization with a set of interfaces for each supported application. This
chapter details aspects of the APIs delivered by ACT. The high-level member interfaces of the APIs expose
the properties and methods that allow access to the applications underlying data.
The extensions that are loaded by the Workbench Extension Manager are each configured and initialized
to support Python scripting. For each extension, a global variable ExtAPI gives access to the
DataModel property. This property returns an IDataModel object, which has properties that return
all of the high-level interfaces available for customizations. The complete list of member interfaces is
given in the Application Customization Toolkit Reference Guide.
Using the APIs, you can both create new objects and modify existing ones.
Note
When you create a new object, Mechanical initializes the object's property values in the
Details window to the same default values used when you add an object via standard mouseclick operations. Some properties, such as scoping or the mass of a point mass, may be invalid
until you enter a value.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
117
APIs Description
For more information on ANSYS Mechanical APIs and their properties, refer to the Application Customization Toolkit Reference Guide.
Numerical Value (float and integer): A property, such as Relevance or Rate, expecting a numerical
value (a number for which a unit is not specified).
Example:
my_object.TetraGrowthRate = 2
Geometry Scoping: A property whose value is one or more geometric entities. In these cases, you must:
1. Create selection information and specify the Ids of the entities you want to manipulate.
2. Assign this list of Ids to the Location / SourceGeometry properties.
Example:
my_selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
my_selection.Ids= [28,25]
My_object.Location = my_selection
118
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
It results in the creation of the point mass and activation of the pinball region in ANSYS Mechanical, as
shown below:
119
APIs Description
my_selection.Ids = [16]
mesh_method.Location = my_selection
mesh_method.Method = MethodType.AllTriAllTet
mesh_method.Algorithm = MeshMethodAlgorithm.PatchIndependent
mesh_method.MaximumElementSize = Quantity("0.05 [m]")
mesh_method.FeatureAngle = Quantity("12.000000000000002 [degree]")
mesh_method.MeshBasedDefeaturing = True
mesh_method.DefeaturingTolerance = Quantity("0.0001 [m]")
mesh_method.MinimumSizeLimit = Quantity("0.001 [m]")
mesh_method.NumberOfCellsAcrossGap = 1
mesh_method.CurvatureNormalAngle = Quantity("36 [degree]")
mesh_method.SmoothTransition = True
mesh_method.TetraGrowthRate = 1
It results in the creation of a Patch Independent meshing control in ANSYS Mechanical, as shown below:
It results in the creation of a frictionless contact and beam connection in ANSYS Mechanical, as shown
below:
120
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
In our example, we apply the internal and external pressures to the pipe:
pressure.Magnitude.Output.Formula = '10*time'
pressure.Magnitude.Output.DiscreteValues=[Quantity('6 [Pa]')]
Note
If you use a constant ramped from t=0s to define the force, the first value cannot be
"0" .
force.Magnitude.Output.DiscreteValues=[Quantity('11.3 [N]'), Quantity('12.85 [N]')]
Script execution results in the creation of a Magnitude property for the applied Force, with time as an
input variable and a single output variable:
Although initially we used tabular data to define the Magnitude property, we can also use a constant
value or a time- or space-dependent formula. Below is an example of how to use a constant value to
define the property:
force.Magnitude.Output.DiscreteValues=[Quantity('10 [N]')]
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
121
APIs Description
We can also opt to define the Magnitude property with global coordinates, instead of a vector, by using
the following commands:
force.DefineBy = LoadDefineBy.Components
force.ZComponent.Output.DiscreteValues = [Quantity('0 [N]'),Quantity('-9 [N]')]
It results in a solved analysis indicating the values for the Minimum and Maximum properties for the
Total Deformation result, as shown below:
122
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
The Python script function traversegeometry() demonstrates how an extension could traverse
the geometry data. In this example, an object of type IGeoData is obtained from the Analysis object
using the GeoData property. This GeoData object is then used to query for a list of IGeoAssembly
objects by calling the Assembly property. For each of the IGeoAssembly objects in the returned
list, the Parts property is called and a list of IGeoPart objects is returned. This pattern is repeated
through the hierarchy of the geometry down to the vertices of each edge.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
123
APIs Description
Below is the content of the traversegeometry() function.
def traversegeometry(analysis):
now = datetime.datetime.now()
outFile = analysis.WorkingDir + "SolutionDetails.log"
f = open(outFile,'a')
f.write("*.*.*.*.*.*.*.*\n")
f.write(str(now)+"\n")
# --- IGeometry Interface
# +++ Properties and Methods
# +++
Assemblies
# +++
CellFromRefId
# +++
SelectedRefIds
geometry = analysis.GeoData
assemblies = geometry.Assemblies
assemblies_count = assemblies.Count
# --- IGeoAssembly Interface
# +++ Properties and Methods
# +++
Name
# +++
Parts
for assembly in assemblies:
assembly_name = assembly.Name
parts = assembly.Parts
parts_count = parts.Count
# --- IGeoPart Interface
# +++ Properties and Methods
# +++
Name
# +++
Bodies
for part in parts:
part_name = part.Name
bodies = part.Bodies
bodies_count = bodies.Count
# --- IGeoBody Interface
# +++ Properties and Methods
# +++
Name
# +++
Vertices
# +++
Edges
# +++
Faces
# +++
Shells
# +++
Material
for body in bodies:
faces = body.Faces
faces_count = faces.Count
# --- IGeoFace Interface
# +++ Properties and Methods
# +++
Body
# +++
Shell
# +++
Vertices
# +++
Edges
# +++
Loops
# +++
Area
# +++
SurfaceType
# +++
PointAtParam
# +++
PointsAtParams
for face in faces:
edges = face.Edges
edges_count = edges.Count
# --- IGeoEdge Interface
# +++ Properties and Methods
# +++
Faces
# +++
Vertices
# +++
StartVertex
# +++
EndVertex
# +++
Length
# +++
CurveType
# +++
Extents
# +++
IsParamReversed
# +++
ParamAtPoint
# +++
PointAtParam
# +++
PointsAtParams
for edge in edges:
vertices = edge.Vertices
124
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
125
APIs Description
# +++ Z
# +++ Elements
for nodeid in nodeids:
node = mesh.NodeById(nodeid)
nodex = node.X
nodey = node.Y
nodez = node.Z
try:
f.write("
Element: "+elementid.ToString()+" Node: "+nodeid.ToString()+",
X = "+nodex.ToString()+", Y = "+nodey.ToString()+",
Z = "+nodez.ToString()+"\n")
except:
continue
f.close()
return
The Python script function elementcounter() demonstrates another example of how an extension
could access the mesh data. In this example, only the elements of user-selected geometry entities are
considered. First, the script obtains the IGeoData and IMeshData objects. Then the CurrentSelection.Ids property queries the IDs of the selected geometry entities using the ISelectionMgr
object. If no IDs are returned, a MessageBox displays the message "Nothing Selected." Otherwise, the
GeoEntityById and MeshRegionById methods obtain the IGeoEntity and IMeshRegion
objects corresponding to each selected entity. These two objects are used inside the try-except block
to query for the type of entity selected and the number of elements in each entity's mesh. The Type
property of the IGeoEntity interface and the NumElements property of the IMeshRegion interface
are used here and the results are displayed in a MessageBox.
def elementcounter(analysis):
geometry = analysis.GeoData
mesh = analysis.MeshData
selectedids = ExtAPI.SelectionMgr.CurrentSelection.Ids
if selectedids.Count == 0:
MessageBox.Show("Nothing Selected!")
else:
for selectedid in selectedids:
entity = geometry.GeoEntityById(selectedid)
meshregion = mesh.MeshRegionById(selectedid)
try:
numelem = meshregion.ElementCount
MessageBox.Show("Entity of type: "+entity.Type.ToString()+
" contains "+numelem.ToString()+
" elements.")
except:
MessageBox.Show("The mesh is empty!")
return
return
Traversing Results
The Python function minmaxresults() computes the minimum and maximum component values
of the nodal displacement and the SXX stress component. It begins by instantiating a result reader using
the analysis.ResultsData method. Results are retrieved relative to the finite element model and
queried using either the elementID (elemental result) or the nodeID (nodal result). The displacement
result "U" is a nodal result, whereas the stress result "S" is a result on nodes of the elements. The displacement result stores a set of component values for each node, where the component names are X,
Y and Z.
The script minmaxresults first iterates over the nodeIDs to compute the minimum and maximum
values. Then, the script iterates over the elementIDs and the nodes of each element to compute the
minimum and maximum values. Note that the second loop over the nodes is filtered to the primary
nodes of the elements, since stress results are available only on these primary nodes. Finally, the results
are written to the output file.
126
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
> maxdispx:
dispvals[0]
> maxdispy:
dispvals[1]
> maxdispz:
dispvals[2]
< mindispx:
dispvals[0]
< mindispy:
dispvals[1]
< mindispz:
dispvals[2]
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
127
APIs Description
#
# Get the SXX stress component at node "nodeid"
#
SXX = stressval[i]
#
# Determine if the SXX stress component is min or max
#
if num == 0:
maxsxx = SXX
minsxx = SXX
if SXX > maxsxx:
maxsxx = SXX
if SXX < minsxx:
minsxx = SXX
num += 1
#
# Write the results to the output
#
f.write("Max U,X:Y:Z = "+maxdispx.ToString()+" : "+maxdispy.ToString()+" : "+maxdispz.ToString()+"\n")
f.write("Min U,X:Y:Z = "+mindispx.ToString()+" : "+mindispy.ToString()+" : "+mindispz.ToString()+"\n")
f.write("Max SXX = "+maxsxx.ToString()+"\n")
f.write("Min SXX = "+minsxx.ToString()+"\n")
f.close()
This API allows access to toolbars and provides the ability to hide or gray-out ACT-based features. Note
that it cannot be used to create new items (e.g., toolbars); it only provides access to existing UI elements.
ExtAPI.UserInterface.Toolbars is a collection of toolbar objects. Each object has fields to access
Name/Caption/Visibility/Child Entries. Each child has the following properties: Caption,
Enabled, Entries, EntryType, Name, and Visible.
The boolean fields Visible and Enabled can be set to "show" or "hide" so that the user can control
the availability of the buttons depending on the current context.
128
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
This command returns an ISelectionInfo object that describes the selected entities.
To retrieve entities:
selection.Entities
Creating Primitives
The DesignModeler Primitives API provides you with the ability to create different types of primitive
bodies: sheet bodies, wire bodies, and solid bodies. For each primitive body type, multiple shape options
are available.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
129
APIs Description
Figure 53: Primitive body type and shape options
In this example:
The width and height variables are used to define the width and the height of the cylinder.
The sheetBodies variable specifies the type of primitive to be created.
The primitive variable uses the global variable ExtAPI to access the data model and define the geometry
builder, which serves as entry point for ACT into DesignModeler.
130
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
131
APIs Description
In this example:
The points_list () method is defined for later use in the creation of the polyline body. For arguments,
it expects as a list of coordinate points (defined by three float values per point).
The primitive variable uses the global variable ExtAPI to access the data model and define the geometry
builder, which serves as entry point for ACT into DesignModeler.
The CreatePolyline () method is applied to the object Wire to generate the new body. As arguments,
this method is expecting the coordinate points defined by the points_list method above.
With the polyline_generated object, we use the Generate () method to generate the polyline, as
shown below.
Figure 55: Generation of wire body polyline primitive
The new body is added to the feature.bodies list, as described in Creating a Sheet Body (p. 130).
With the MaterialType line, we specify a material property of Add.
In this example:
The point1 () and point2 () methods are defined for later use in the creation of the solid body. For
arguments, they each expect as a list of coordinate points (defined by three float values per point).
132
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
The new body is added to the feature.bodies list, as described in Creating a Sheet Body (p. 130).
With the MaterialType line, we specify a material property of Freeze.
Applying Operations
The DesignModeler Operations API enables you to perform different operations on a geometric body.
Available operations can be divided into two different categories: Primary and Boolean Operations
and Tools Operations.
Figure 57: Operation types and options
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
133
APIs Description
The operation variable ExtAPI.DataModel.GeometryBuilder.Operations is the gateway
for performing operations. The code must be integrated into the <ongenerate> callback.
The Python script function ongenerate() can be used to perform various types of operations on a
geometry feature. The API provides primary and Boolean operations that allow you to specify properties
such as body type, dimensions, shape, point coordinates, and material. It also offers a number of tools
that can be used to manipulate your geometry, including actions such as copying or deleting a body
or using transform operations to create a body based on another body or topological components.
In this example:
The first part of the function creates a polygon sheet body, using a process similar to the one used to create
a cylinder in Creating a Sheet Body (p. 130).
With the Extrude operation, we use the operations generator builder.Operations.CreateExtrudeOperation. The CreateExtrudeOperation method specifies that the operation is defined by
the following arguments:
Vector coordinates (which will define the direction of the extrusion)
Length of the extrusion
Note
In our example, the same Length variable is used for both the sheet body and the
extrusion definition. We also could have used a different variable for each.
The ApplyTo method specifies the geometry to which the extrude operation will be applied. The ApplyTo() method returns a list of bodies to which the operation will be applied.
134
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
In this example:
The first part of the function creates a polygon sheet body, using a process similar to the one used to create
a cylinder in Creating a Sheet Body (p. 130).
With the body function, we use the operations generator builder.Operations.Tools.EdgesToWireBody. The EdgesToWireBody method specifies that the operation tool will transform the edges of the
sheet body polygon into a wire body.
Note
In our example, the same Length variable is used for multiple faces of the sheet body.
We also could have used a different variable for each face.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
135
APIs Description
The new wire body is added to the feature.bodies list, as described in Applying the Extrude Operation (p. 134).
Figure 59: Application of the Edges to Wire Body tool to a sheet body polygon
DOE APIs
This section discusses the APIs provided by ACT to customize DesignXplorer DOE functionality.
DOE Architecture
The object PSMtrxGenerator is responsible for the execution of the DOE. Regardless of whether the
sampling is built-in or external, it executes the same process via the sampling API.
The main elements of the API, shown below in Figure 60: DesignXplorer's Sampling Architecture (p. 137),
are as follows:
ISamplingMethod : the main interface between DX and the external sampling, which is required to implement it
IServices: the interface for the external sampling to access DX services, such as the calculation of one
or more points
DXPoint: the class that describes and stores the point data, such as variable values, calculation state, etc.
136
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
For more details about the API, see the "API Description" section in the ACT Reference Guide for
DesignXplorer.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
137
APIs Description
Figure 61: DesignXplorer's Sampling Process
Optimization APIs
This section discusses the APIs provided by ACT to customize DesignXplorer optimization functionality.
Optimization Architecture
The object OptimizationEngineMgr is responsible for the execution of the optimization. Regardless
of whether the optimizer is built-in or external, it executes the same process via the optimization API.
The main elements of the API, shown below in Figure 62: DesignXplorer's Optimization Architecture (p. 139), are as follows:
IOptimizationMethod: the main interface between DX and the external optimizer, which is required
to implement it
IOptimizationServices: the interface for the external optimizer to access DX services, such as the
calculation of one or more points
DXOptimizationPoint: the class that describes and stores the points data, such as variable values, calculation state, etc.
138
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
For more details about the API, see the "API Description" section in the ACT Reference Guide for
DesignXplorer.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
139
APIs Description
Figure 63: DesignXplorer's Optimization Process
140
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Associated Libraries
This chapter describes the libraries installed with the ACT. These libraries include a set of Python functions
that can be used to develop extensions more efficiently.
The commands related to the examples provided below can be interactively tested using the ACTConsole
extension from the application. The ACTConsole extension is installed with ACT and you can refer to
ACT Console Extension (p. 202) for more detailed information.
The following sections describe a subset of the available libraries. You can access other libraries from
the ANSYS installation directory and consult the source code for a reference on their use. Libraries can
be found in the following directories:
%ANSYSversion_DIR%\..\Addins\AdvancedAddinPackage\libraries\Mechanical
%ANSYSversion_DIR%\..\Addins\AdvancedAddinPackage\libraries\Project
Location
libraries/Mechanical/materials.py
libraries/Project/materials.py
Usage
import materials
Functions
GetListMaterialProperties(mat)
This function returns a list of property names for the material mat given in argument.
GetMaterialPropertyByName(mat, name)
This function returns the material property name for the material mat.
InterpolateData(vx, vy, vin)
This function computes a linear interpolation vout = f(vin) with f defined by vy = f(vx).
vx represents a list of values for the input variable.
vy represents a list of values for the property that depends on the input variable defined by vx.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
141
Associated Libraries
vin is the value on which the function has to evaluate the property.
Example
This command:
import materials
mat = ExtAPI.DataModel.GeoData.Assemblies[0].Parts[0].Bodies[0].Material
materials.GetListMaterialProperties(mat)
This command:
prop = materials.GetMaterialPropertyByName(mat,"Elasticity")
prop
This command:
val = materials.InterpolateData(prop["Temperature"][1:],prop["Young's Modulus"][1:],10.)
val
val = materials.InterpolateData(prop["Temperature"][1:],prop["Young's Modulus"][1:],20.)
val
Units Conversion
Description
This library implements a set of functions to manipulate the unit dependent quantities within an extension. This library is of particular interest each time quantities have to remain consistent with the current
unit system activated in the application.
Location
libraries/Mechanical/units.py
libraries/Project/units.py
Usage
import units
142
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Units Conversion
Function
ConvertUnit(value,fromUnit,toUnit[,quantityName])
This function converts the value from the unit fromUnit to the unit toUnit. The user can specify
the quantity name to avoid conflict during conversion. This quantity name is not mandatory.
Example
This command:
import units
units.ConvertUnit(1,"m","mm")
Function
ConvertUserAngleUnitToDegrees(api, value)
This function converts the angle value to the unit degrees. If the current activated unit is already degrees, then the value remains unchanged.
Example
This command:
import units
units.ConvertUserAngleUnitToDegrees(api,3.14)
returns
180. if the angle unit is set to radius when the command is called
3.14 if the angle unit is set to degrees when the command is called
Function
ConvertToSolverConsistentUnit(api, value, quantityName, analysis)
This function converts the valueof the quantity quantityName from the currently activated unit in
the application to the corresponding consistent unit used by the solver for the resolution of the analysis
analysis.
Example
This command:
import units
units.ConvertToSolverConsistentUnit(api,1.,pressure,Static Structural)
returns
10. if the unit system is set to Metric(mm,dat,N,s,mV,mA) when the command is called
Function
ConvertToUserUnit(api, value, fromUnit, quantityName)
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
143
Associated Libraries
This function converts the value of the quantity quantityName from the unit fromUnit to the
currently activated unit system in the application.
Example
This command:
import units
units.ConvertToUserUnit(api,1.,m,length)
returns
1000. if the current activated unit is millimeter when the command is called
Function
ConvertUnitToSolverConsistentUnit(api, value, fromUnit, quantityName, analysis)
This function converts the valueof the quantity quantityName from the unit fromUnit to the
consistent unit that is used by the solver for the resolution of the analysis analysis.
Example
This command:
import units
units.ConvertUnitToSolverConsistentUnit(api,1.,m,length,Static Structural)
returns
1000. if the consistent unit is millimeter when the command is called
Function
GetMeshToUserConversionFactor(api)
This function returns the scale factor to be applied to convert a length from the unit associated to the
mesh and the currently activated unit in the application.
Example
This command:
import units
units.GetMeshToUserConversionFactor(api)
returns
1000. if the unit associated to the mesh is meter and if the current activated unit in the application
is millimeter.
MAPDL Helpers
Description
This library implements some helpers to write APDL command blocks or to execute ANSYS Mechanical
APDL programs.
144
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Journaling Helper
Location
libraries/Mechanical/ansys.py
libraries/Project/ansys.py
Usage
import ansys
Functions
createNodeComponent(refIds,groupName,mesh,stream,fromGeoIds=True)
This function writes the APDL command block (CMBLOCK) for the creation of a node component related
to the geometry entities identified by refIds into the stream stream. refIds refer to geometric IDs
if fromGeoIds is true and the node IDs are retrieved from geometric entities using the associativity
between the geometry and mesh. If fromGeoIds is false, then refIds refer directly to the node IDs to
be written in the component.
createElementComponent(refIds,groupName,mesh,stream,fromGeoIds=True)
This function writes the APDL command block (CMBLOCK) for the creation of an element component
related to the geometry entities identified by refIds into the stream stream. refIds refer to geometric
IDs if fromGeoIds is true and the element IDs are retrieved from geometric entities using the associativity between the geometry and the mesh. If fromGeoIds is false, the refIds refer directly to the
element IDs to be written in the component.
RunANSYS(api,args,[runDir[,exelocation]])
This function calls the ANSYS Mechanical APDL program with the command line initialized by args.
The user can specify the folder from which he wants to execute the program with runDir. The location
of the executable is also managed with exelocation.
api parameter must be ExtAPI.
Example
import ansys
ansys.createNodeComponent([refId],"myGroup",mesh,stream)
ansys.RunANSYS(ExtAPI,"")
Journaling Helper
Description
This library implements a helper that can be used to transfer data between Mechanical and the Project
page.
Location
libaries/Mechanical/wbjn.py
libraries/Project/wbjn.py
Usage
import wbjn
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
145
Associated Libraries
Functions
ExecuteCommand(api,cmd,**args)
This function executes a journal command specified by cmd You can get a result object by using the
function returnValue(obj) in your journal command. All arguments must implement the serialization
interface provided by .Net. The object sent to the function returnValue(obj) must also implement
the serialization interface. This interface is already implemented for many standard types of data (integer,
double, list). Please note that the standard Python dictionary does not implement this interface by
default. If a dictionary is required, use the SerializableDictionary class provided by ACT.
api parameter must be ExtAPI.
ExecuteFile(api,file,**args)
Examples
This command:
import wbjn
wbjn.ExecuteCommand(ExtAPI,"returnValue(a+b)",a=2,b=3)
This command:
import wbjn
wbjn.ExecuteCommand(ExtAPI,"returnValue(a+GetAllSystems()[0].DisplayText+b)",
a="My first system is: ",b=" !")
This command:
import wbjn
dict = SerializableDictionary[str,int]()
dict.Add("e1",1)
dict.Add("e2",2)
wbjn.ExecuteCommand(ExtAPI,'returnValue(d["e1"]+d["e2"])', d=dict)
146
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Note
The content of the XML file is case-sensitive.
<extension> Element
This represents the "root" element, or base tag, that all other tags/elements fall under.
The <extension> element contains the <guid>, <script>, <interface>, <workflow>, and
<simdata> elements.
<extension version="[version number]" minorversion="[minor version number]"
name="[extension name]">
<author>author name</author>
<description>description of the extension</description>
<assembly src="[source file name (string)]"
namespace="[namespace (string)]"/>
</extension>
Mandatory attributes
version="[version number (integer)]"
name="[extension name (string)]"
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
147
Optional attributes
minorversion="[minor version number (integer)]"
<GUID> Element
The GUID element allows a unique identification for the extension.
<extension version="[version id (integer)]"
name="[extension name (string)]"
<guid shortid="[name (string)]">GUID</guid>
</extension>
Mandatory attributes
GUID
Optional attribute
shortid="[name]"
The GUID must remain the same along the evolutions of the extension, independently of the extension
version or name. It is used to uniquely identify an extension. The shortId attribute is needed for
compatibility with old projects. The shortId attribute provides backwards compatibility for extensions
which were developed before the GUID element was available.
<script> Element
<extension version="[version id (integer)]"
name="[extension name (string)]"
<script src="[python file name (string)]"></script></extension>
You can either insert the IronPython script directly into the XML file, or use the src attribute to specify
the path to the script.
Additional paths can be specified by adding new <script> elements.
<script src="[Path]\filename.py" />
Optional attribute
src="[file name.py]"
By default, ACT looks for IronPython scripts in the same directory as the extension. If the scripts are not
located in that directory, you can specify the path the scripts in addition to the file name.
For example:
<script src="my_path\main.py" />
<interface> Element
The <interface> element and its child elements define GUI elements, including custom toolbars.
148
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
<extension version="[version id (integer)]"
name="[extension name (string)]"
<interface context="[Project | Mechanical]">
...
</interface>
The interface element information pertains specifically to the GUI. The available elements under
the <interface> tag are presented in the next sections.
Optional attribute
context="[context name]
The context specifies the application for which the interface element applies. At the moment, the
supported contexts are Project, Mechanical, DesignModeler and DesignXplorer.
If no context is specified, then the interface element applies to all the available applications for ACT.
<images> Element
<interface context="[Project | Mechanical]">
<images>[folder]</images>
...
</interface>
The appropriate folder in which the images to be integrated by the extension have been stored.
By default, ACT looks for images in the same directory as the extension. If images for the extension
have been stored in a subdirectory of the main extension directory called images, the following definition is appropriate. This is the most common situation:
<images>images</images>
<callbacks> Element
This section applies to the ANSYS Mechanical application only.
<interface context="[Project | Mechanical | ASim]">
<!-- Interface level callbacks -->
<callbacks>
<oninit>[function(context)]</oninit>
<onterminate>[function(context)]</onterminate>
<onload>[function(currentFolder)]</onload>
<onsave>[function(currentFolder)]</onsave>
<resume>[function(binary reader)]</resume>
<save>[function(binary writer)]</save>
<onbeforesolve>[function(analysis)]</onbeforesolve>
<onaftersolve>[function(analysis)]</onaftersolve>
<isanalysisvalid>[function(analysis,firstCheck)] </isanalysisvalid>
<ondraw2d>[function()]</ondraw2d>
<getprecommands> [function(analysis,stream)]</getprecommands>
<getsolvecommands timedependent="[true | false(default)]">
[function(analysis,stream)]</getsolvecommands>
<getpostcommands>[function(analysis,stream)] </getpostcommands>
<onactiveobjectchange>[function(analysis)]</onactiveobjectchange>
<onpoststarted>[function(analysis)]</onpoststarted>
<onpostfinished>[function(analysis)]</onpostfinished>
</callbacks>
...
</interface>
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
149
The oninit element specifies the name of the IronPython function called when the GUI is initialized.
The declaration of the called function must be:
def function_name(context):
The context argument contains the name of the application as defined by the context attribute of
the <interface> element.
<onterminate>[function name(application context)]</onterminate>
The onterminate element specifies the name of the IronPython function called when the application
context is stopped. The declaration of the called function must be:
def function_name(context):
The context argument contains the name of the application as defined by the context attribute of
the <interface> element.
<onload>[function name(Folder)]</onload>
The onload element specifies the name of the IronPython function called when the project is opened
by the application. The declaration of the called function must be:
def function_name(folder):
The input argument folder defines the folder path of the project.
<onsave>[function name(Folder)]</onsave>
The onsave element specifies the name of the IronPython function called when the project is saved
by the application. The declaration of the called function must be:
def function_name(folder):
The input argument folder defines the folder path of the project.
<resume>[function(binary reader)]</resume>
The resume element specifies the name of the IronPython function called when the project is opened
by the application. The declaration of the called function must be:
def function_name(binary_reader):
The input argument binary_reader defines the reader to be used to get data previously stored by
the resume element. in this case, data are retrieved directly from the standard database of the application
(see the save element description below).
<save>[function(binary writer)]</save>
The save element specifies the name of the IronPython function called when the project is saved by
the application. The declaration of the called function must be:
def function_name(binary_writer):
The input argument binary_writer defines the writer to be used to store data. In this case, data
are stored in the standard database of the current application. No new external files are created to store
the specific data related to the extension.
150
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
<onbeforesolve>[function name(analysis)] </onbeforesolve>
The onbeforesolve element specifies the name of the IronPython function called when the solve of an
analysis starts. The declaration of the called function must be:
def function_name(analysis):
The input argument analysis defines the current analysis. If the solve request invokes the resolution
of multiple analysis then this callback will be called for each analysis.
<onaftersolve>[function name(analysis)]</onaftersolve>
The onaftersolve element specifies the name of the IronPython function called when the solve of
an analysis is complete. The declaration of the called function must be:
def function_name(analysis):
The isanalysisvalid element specifies the name of the IronPython function called when Mechanical retrieves the status of the analysis. The declaration of the called function must be:
def function_name(analysis,firstCheck):
The ondraw2d element specifies the name of the IronPython function called each time the graphics
view of Mechanical is refreshed. This function can be used to draw 2D objects such as labels associated
with a node. The declaration of the called function must be:
def function_name():
<getprecommands> [function(analysis,stream)]</getprecommands>
The getprecommands element specifies the name of the IronPython function called when Mechanical
writes the solver input file. This function allows you to add input solver commands in the stream. The
commands added to this stream are located just after the mesh definition.
<getsolvecommands>[function(analysis,stream)]</getsolvecommands>
The getsolvecommands element specifies the name of the IronPython function called when Mechanical writes the first load step in the solver input file. Like the getprecommands element, this function
allows you to add input solver commands in the stream. The commands added to the stream are located
just after the definition of the first load step.
<getpostcommands> [function(analysis,stream)]</getpostcommands>
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
151
The onactiveobjectchange element specifies the name of the IronPython function called when
the active object has been changed.
<onpoststarted>[function name(analysis)]</onpoststarted>
The onpoststarted element specifies the name of the IronPython function called when the postprocessing of an analysis starts. The declaration of the called function must be:
def function_name(analysis):
The onpostfinished element specifies the name of the IronPython function called when the postprocessing of an analysis is complete. The declaration of the called function must be:
def function_name(analysis):
<toolbar> Element
<extension version="[version id (integer)]"
name="[extension name (string)]"
<!-- Toolbar definition -->
<toolbar name="[toolbar internal name (string)]"
caption="[toolbar display name (string)]">
<!--Toolbar button definition -->
<entry name="[toolbar button internal name (string)]"
caption="[caption name (string)]"
icon="[name of an image located in images folders (string)]"
userobject="[object name (string)]">
<callbacks>
<!-- Declaration of callback for toolbar button activation -->
<onclick>[function()]</onclick>
</callbacks>
</entry>
...
</toolbar>
</extension>
The toolbar element supports two attribute nodes: name and caption. They are described below in
the following sections.
152
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
Mandatory attributes
name
The value of the name attribute specifies the name used by the application
to reference this toolbar.
caption
The value of the caption attribute specifies the name displayed in the
GUI for toolbar.
Child Elements
The toolbar element supports one or more entry child elements. Each entry element spawns the
creation of a toolbar button. An entry element supports an onclick callback, which specifies the
name of the IronPython function called when the user clicks on the button. The entry element for a
toolbar button is defined as follows:
<toolbar name="[toolbar internal name (string)]"
caption="[toolbar display name (string)]">
<!--Toolbar button definition -->
<entry name="[toolbar button internal name (string)]"
caption="[caption name (string)]"
icon="[name of an image located in images folders (string)]"
userobject="[object name (string)]">
<callbacks>
<!-- Declaration of callback for toolbar button activation -->
<onclick>[function()]</onclick>
</callbacks>
</entry>
...
</toolbar>
Mandatory attribute
name
The name attribute specifies the name used by the context application to
reference this toolbar button.
Optional attributes
caption
The value of the caption attribute specifies the caption to be displayed when the
mouse is hovered over this toolbar button.
icon
The value of the icon attribute specifies the file name of the icon displayed in
the GUI for this toolbar button, without the file extension. (An icon is a 16x16 pixel
image in BMP, JPG, or GIF format.) This file has to be stored in one of the folders
previously defined in the <images> elements.
userobject
When the userobject attribute is used, the onclick callback is ignored. Depending on the nature
of the object (load, result, general), the button associated with the entry will be activated or deactivated
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
153
<workflow> Element
The workflow element defines a custom ACT workflow.
<workflow context="Project">
<tasks>
<task>
</task>
</tasks>
<taskgroups>
<taskgroup>
</taskgroup>
</taskgroups>
</workflow>
Mandatory attributes
context
Specifies the context to which the custom workflow applies. Acceptable values: Project.
<tasks> Element
The tasks element is the top-level entry containing all task definitions.
<tasks>
<task name="" caption="" icon="" version="1">
...
</task>
</tasks>
<task> Element
The task element defines a single task within a workflow. A task captures one application, process, or
logic step.
<task name="" caption="" icon="" version="1">
<callbacks>
</callbacks>
<contextmenus>
</contextmenus>
<propertygroup name="" caption="">
</propertygroup>
<property/>
<parameters>
</parameters>
<inputs>
</inputs>
<outputs>
</outputs>
</task>
Mandatory attributes
name
154
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
version
Optional attributes
caption
Specifies the task display text. If not supplied, name will be used. Acceptable values: any valid string.
icon
Specifies the image displayed with the task. In the Workbench Project Schematic, this is the icon displayed on the left of a cell block. Acceptable values: a filename of a 16x16 pixel image of the .png
format.
<callbacks> Element
The callbacks element specifies the functions defined by the user's Python code. The callbacks are
described below:
<callbacks>
<onupdate></onupdate>
<onrefresh></onrefresh>
<oninitialize></oninitialize>
<onedit></onedit>
<onreset></onreset>
<onstatus></onstatus>
<onreport></onreport>
</callbacks>
onupdate
Called when the user edits the task. By declaring this callback, ACT will automatically expose a default
Edit context menu for this task.
onreset
Called when the application (e.g. Workbench) asks the task for its current state.
onreport
Called when the user generates a project report. This allows the task to access the report object and
add its own task-specific reporting content.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
155
<contextsmenus> Element
The contextmenus element specifies the user-defined context menus to expose on this task. Note
that you can receive an Edit context menu for free by supplying a Python method for the <onedit>
callback.
<contextmenus>
<entry name="" caption="" icon="" version="1" priority="" type="">
<callbacks>
<onclick></onclick>
</callbacks>
</entry>
</contextmenus>
<entry> Element
The entry element specifies the context menu entry.
Mandatory attributes
name
Specifies the context menu version number. Acceptable values: an integer string.
Optional attributes
caption
Specifies the entry display name. If not supplied, name will be used. Acceptable values: any valid string.
icon
Specifies the icon associated with the context menu entry. Acceptable values: a filename of a 16x16
pixel image of the .png format.
priority
Specifies the context menu priority. Indicates where the entry should be placed when other entries are
specified for the same menu. Lower numbers appear at the top of the menu. You can specify groups
by using decimals to indicate {group}.{order}. Acceptable values: a float string.
type
<propertygroup> Element
The propertygroup element specifies a group of properties. In the Workbench Project Schematic,
this exposes a new group in the property view to better organize multiple properties.
156
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
<propertygroup name="" caption="">
<property name="" caption="" control="" default="" readonly="" needupdate="" visible=""
persistent="" parameterizable="" keytype="" valuetype="" elementtype=""/>
</propertygroup>
Mandatory attributes
name
Specifies the property group name. Acceptable values: any valid string.
Optional attributes
caption
Specifies the property group display name. If not supplied, name will be used. Acceptable values: any
valid string.
<property> Element
The property element defines a piece of data to be stored within a task.
<property name="" caption="" control="" default="" readonly="" needupdate="" visible=""
persistent="" parameterizable="" keytype="" valuetype="" elementtype=""/>
Mandatory attributes
name
Specifies the property control type. Acceptable values: string, double, integer, datareference,
boolean, object, quantity, option, list, dictionary, datacontainerreference.
version
Specifies the property version number. Acceptable values: any valid string.
Optional attributes
caption
Specifies the property display text. If not supplied, name will be used. Acceptable values: any valid
string.
default
Specifies the property default value (the initial value). Acceptable values: any valid type-based string.
readonly
Indicates whether the property is an outuput (not editable by the user). Acceptable values: true or
false.
needupdate
Indicates if the property is an input and forcing a state change if the property value is modified. Acceptable values: true or false.
visible
Indicates if the property should be user-visible in the application. Acceptable values: true or false.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
157
Indicates whether the property value should be saved with the project. Use this attribute if you want
to keep data on your task (e.g. display to the user) but not store it in the project file. Acceptable values:
true or false.
parameterizable
Indicates whether the property should be a candidate for parameterization. In Workbench, a true value
will result in a check box displayed to the right of the property to allow users to promote the property
as a Workbench parameter. Acceptable values: true or false.
keytype
The key type of a key-value pair for a property whose control attribute is set to dictionary. Acceptable
values: see control. (Nested collections are not supported at 16.2)
valuetype
The value type of a key-value pair for a property whose control attribute is set to dictionary. Acceptable
values: see control. (Nested collections are not supported at 16.2)
elementtype
The element type of a key-value pair for a property whose control attribute is set to dictionary. Acceptable values: see control. (Nested collections are not supported at 16.2)
<parameters> Element
The parameters element defines the parameters to be exposed by this task.
<parameters>
<parameter name="" caption="" usage="" control="" version="1"/>
</parameters>
<parameter> Element
The parameter element specifies the parameter value for this task. In Workbench, a parameter will be
automatically created for this entry. This will not be associated with a displayed data property.
Mandatory attributes
name
Specifies whether the parameter is an input or output. Acceptable values: input or output.
control
Specifies the parameter data type.Acceptable values: Acceptable values: Double, Float, Long,
Quantity.
Optional attributes
caption
Specifies the parameter display text. If not supplied, name will be used. Acceptable values: any valid
string.
158
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
version
Specifies the parameter version number. Acceptable values: any valid integer string.
<inputs> Element
The inputs element defines the task inputs for consuming upstream connections.
<inputs>
<input/>
<input type="" format=""/>
</inputs>
<input> Element
The input element defines an input for this task.
Optional attributes
type
Specifies the data type string representing the data desired for input to this task. Acceptable values:
any valid string.
format
Specifies the format of data desired for input to this task. More specific than type (and always specified
with a corresponding type), this value provides an additional specification for formatting the requested
input data type. In Workbench, for example, you could specify a type as MeshingMesh and the format
as FluentMesh. The former indicates you want to consume a mesh. The latter provides the additional
detail that the mesh should be in the .msh fluent format. Acceptable values: any valid string.
<outputs> Element
The outputs element defines the task outputs for providing downstream connections.
<outputs>
<output type="" format=""/>
</outputs>
<output> Element
Optional attributes
type
Specifies the data type string representing the data exposed and generated by this task. Acceptable
values: any valid string.
format
Specifies the format of data generated by this task. More commonly used on an input specification than
an output. Acceptable values: Any valid string.
<taskgroups> Element
The taskgroups element is the top-level entry containing the groups of tasks defined in this workflow.
<taskgroups>
<taskgroup name="" caption="" icon="" category="" abbreviation="" version="1"
isparametricgroup="False">
<includetask name=""/>
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
159
<taskgroup> Element
The taskgroup element defines a collection of tasks and taskgroups into one single unit.
Mandatory attributes
name
Optional attributes
caption
Specifies the taskgroup display text. If not supplied, name will be used. Acceptable values: any valid
string.
icon
Specifies the icon associated with the taskgroup. Acceptable values: a filename of a 16x16 pixel image
of the .png format.
category
Specifies the taskgroup category. Use this value to group taskgroups into a general division. In Workbench, this defines the toolbox group into which your taskgroup will appear. Acceptable values: any
valid string.
abbreviation
Specifies the taskgroup abbreviation. In Workbench, this value determines the unique taskgroup directory
into which taskgroup information can be stored. Acceptable values: any valid string.
isparametricgroup
Indicates whether the taskgroup works only on parameters. In Workbench, this value determines
whether or not the group will appear below the Parameter Set bar. Acceptable values: true or false.
<includetask>
The includetask element specifies the task to include in the taskgroup.
Mandatory attributes
name
<includegroup>
The includegroup element specifies the group to include in the taskgroup.
Mandatory attributes
160
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
name
<simdata> Element
The <simdata> element information pertains specifically to the simulation environment. Three child
elements are used for integrating custom loads, custom results and third party solvers into the application.
These three main features are nested as child elements within the <simdata> element.
<extension version="[version id (integer)]"
name="[extension name (string)]"
<simdata context="[Project | Mechanical | DesignXplorer]">
<load> ... </load>
<object> ... </object>
<result> ... </result>
<solver> ... </solver>
</simdata>
</extension>
Optional attribute
context="[context name]
The context specifies the application to which the interface element applies.
If no context is specified, then the interface element applies to all the available applications for
the ACT.
<load> Element
The <load> element and its children allow you to configure the properties of a custom load and specify
the IronPython functions that are invoked based on system and user-generated events. The <load>
element supports eight attribute nodes. These are name, version, caption, icon, issupport,
isload, color and solveorder. These are defined inside the load element as described below:
<simdata context="[Project | Mechanical]">
<load name="[load internal name]"
version="[version identifier of the load]"
caption="[load display name]"
icon="[name of an icon file]"
issupport="[true | false]"
isload="[true | false]"
color="[#xxxxxx]"
contextual="[true(default) | false]"
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
161
The element has two child elements: the callbacks element and the property element. These two
elements and their children are presented in the next two sections.
Mandatory attributes
name
The value of the name attribute specifies the name used by the application
to reference this load.
version
The value of the version attribute allows the load author to attach a
version number to this load.
caption
The value of the caption attribute specifies the name displayed in the
GUI for this load.
icon
The value of the icon attribute specifies the file name of the icon
displayed in the GUI for this toolbar button, without the file extension.
(An icon is a 16x16 pixel image in BMP, JPG, or GIF format.) This file has
to be stored in one of the folders previously defined in the <images>
elements.
Optional attributes
issupport
The value of the issupport attribute specifies that this load has to be
interpreted as a boundary condition.
isload
The value of the isload attribute specifies that this load has to be
interpreted as a load.
color
The value of the color attribute specifies the color to be used when
scoped geometry is displayed. Color is defined by a six-digit hexadecimal
number. This number consists of three two-digit numbers corresponding
to red, green and blue (RGB) values.
#XXxxxx = red
#xxXXxx = green
#xxxxXX = blue
contextual
If true, the load can be added directly from the Insert context menu on
the load object.
class
unit
<callbacks> Element
<load name="[load internal name (string)]"
162
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
version="[version identifier of the load (integer)]"
caption="[load display name (string)]"
icon="[name of an image located in images folders (string)]"
issupport="[true | false]"
isload="[true | false]"
color="[#xxxxxx]" >
<callbacks>
<onmigrate>[function(newLoad,oldLoad)]</onmigrate>
<onshow>[function(load)]</onshow>
<onhide>[function(load)]</onhide>
<oninit>[function(load)]</oninit>
<onadd>[function(load)]</onadd>
<onremove>[function(load)]</onremove>
<onsuppress>[function(load)]</onsuppress>
<onunsuppress>[function(load)]</onunsuppress>
<getcommands>[function(load,solverdata,stream)]</getcommands>
<getprecommands order="[(integer)]">[function(load,stream)]</getprecommands>
<getsolvecommands order="[(integer)]" timedependent="[true | false(default)]>
[function(load [,step],stream)]</getsolvecommands>
<getpostcommands order="[(integer)]">[function(load,stream)] </getpostcommands>
<getnodalvaluesfordisplay>[values=function(load,nodeIds)]</getnodalvaluesfordisplay>
<canadd>[function(analysis,loadName)]</canadd>
<onduplicate>[function(load)]</onduplicate>
<canduplicate>[function(load,parent object)]</canduplicate>
<canremove>[function(load)]</canremove>
<action name="[(string)]" caption="[(string)]" icon="[(string)]">
[function(load)]</action>
<ongenerate>[function(load,fct)]</ongenerate>
<onaftergenerate>[function(load)]</onaftergenerate>
<oncleardata>[function(load)]</oncleardata>
<isvalid>[function(load)]</isvalid>
</callbacks>
</load>
The <callbacks> element and its children enable you to specify the Python functions that are invoked
based on system and user-generated events related to the load behavior. The callbacks children are
described below:
<onmigrate>[function(new_load,old_load)] </onmigrate>
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
163
The onshow element specifies the name of the IronPython function called when the load is selected
in the tree. This function is used to display customized graphical information associated with this load.
<onhide>[function(load)]</onhide>
The onhide element specifies the name of the IronPython function called when the load switches
from a visible status to a hidden status. This event is called when the ACT object is unselected.
<oninit>[function(load)]</oninit>
The oninit element specifies the name of the IronPython function called when the load is created.
<onadd>[function(load)]</onadd>
The onadd element specifies the name of the IronPython function called when the load is added. This
event is called when the ACT object is added to the project.
<onremove>[function(load)]</onremove>
The onremove element specifies the name of the IronPython function called when the load is deleted.
This event is called when the ACT object is deleted from the project.
<onsuppress>[function(load)]</onsuppress>
The onsuppress element specifies the name of the IronPython function called when the load switches
from an active state to a suppressed state. This event is called when the ACT object is suppressed.
<onunsuppress>[function(load)]</onunsuppress>
The onunsuppress element specifies the name of the IronPython function called when the load
switches from a suppressed state to an active state. This event is called when the ACT object is unsuppressed.
<getcommands location = [string] order = [integer]>
[function(load,solverdata,stream)]</getcommands>
The getcommands element specifies the name of the IronPython function called when Mechanical
writes the solver input file.
The callback named getcommands replaces the three callbacks getprecommands, getsolvecommands, and getpostcommands when the ANSYS solver is used.
When another solver other than the ANSYS solver is used, the getcommands callback is unavailable.
In such a case, the getprecommands, getsolvecommands, and getpostcommands callbacks
must be used.
The solverdata structure is associated to the getcommands callback. The solverdata structure
provides access to a set of data from the current model at the IronPython level. The solverdata
structure is useful when the solver commands to be generated by the extension need to add entities
in the model such as nodes or elements. Through the solverdata structure, ACT provides an efficient
method to manage the newly created IDs of these entities with the existing IDs previously generated
by the solver. Without the solverdata structure, the APDL command *GET must be used extensively
to determine the maximum ID before creating new entities.
164
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
<getprecommands order = [integer]> [function(load,stream)]</getprecommands>
The getprecommands element specifies the name of the IronPython function called when Mechanical
writes the solver input file. This function allows you to add input solver commands in the stream. The
commands added to the stream are located just after the definition of the mesh. The order attribute
indicates the priority given to the generation of the solver commands in comparison to the other ACT
loads. Low order gives a high priority to the commands to be written. For command blocks with a same
order, the priority is given to the first object as defined in the tree of the application. By default, an
order equal to one is used.
The commands added to the stream are located at the location specified in the location attribute.
Possible values for the location attribute are:
pre
Commands are written at the end of the pre-treatment section (before entering into the /SOLU module).
preload
Commands are written before the first standard load definition.
solve
Commands are before the solve command and after all the standard loads have been defined.
post
Commands are written after the solve command.
The attribute order is used to define the priority of the command generation when the function is
called several times for one given location.
The second argument solverdata refers to the object that contains the model for the current analysis.
The solverdata type is ISolverData and contains the following fields:
MaxElementId
Current maximum element ID on the model.
MaxNodeId
Current maximum node ID on the model.
MaxElementType
Current maximum element type ID on the model.
CurrentStep
Current step number.
The methods available with the properties of solverdata are:
GetNewElementId
Generate a new element ID and increment the MaxElementId property by one.
GetNewNodeId
Generate a new node ID and increment the MaxNodeId property by one.
GetNewElementType
Generate a new element type ID and increment the MaxElementType property by one.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
165
or
<getsolvecommands order = [integer] timedependent = false>[function(load,stream)] </getsolvecommands>
The getsolvecommands element specifies the name of the IronPython function called when Mechanical writes the solver input file. The commands added to the stream are located just after the definition
of the standard loads for the step number step if the attribute timedependent is set to True or just
after the first step if timedependent is set to False. Please refer to the getprecommands callback
for information on the order attribute.
Note
The argument step is expected only when the attribute timedependent is set to true.
<getpostcommands order = [integer]> [function(load,stream)]</getpostcommands>
The getpostcommands element specifies the name of the IronPython function called when Mechanical writes the solver input file. Commands added to the stream are located just after the solve command.
Please refer to the getprecommands callback for information on the order attribute.
<getnodalvaluesfordisplay> [values=function(load,nodeIds)] </getnodalvaluesfordisplay>
The getnodalvaluesfordisplay element specifies the name of the IronPython function called
prior to the display of the load. The user specifies the active load and an array of node ids. The function
must return an array containing one value per node. This output array needs to be consistent in terms
166
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
of sequential storage with the input nodeIds. The ith value of the output will refer to the ith node
number from nodeIds. These values are displayed in Mechanical on the model (for example, a spatial
dependent thermal load).
<canadd>[function(analysis,loadName)]</canadd>
The canadd element specifies the name of the IronPython function called when Mechanical checks
the availability of the load for the current analysis. The function takes two arguments: the current analysis and the name of the load to be checked. This function must return True or False.
<onduplicate>[function(load)]</onduplicate>
The onduplicate element specifies the name of the IronPython function called when Mechanical
duplicates the load object.
<canduplicate>[function(load,parent_object)]</canduplicate>
The canduplicate element specifies the name of the IronPython function called when Mechanical
checks if the load object can be duplicated depending on the current selected parent object in the
tree.
<canremove>[function(load)]</canremove>
The canremove element specifies the name of the IronPython function called when Mechanical checks
if the load object can be removed.
<action name="[(string)]" caption="[(string)]" icon="[(string)]"
function(load)
/action>
The action element specifies a new context menu option that will be available on the load object. The
name attribute defines the name of the action, the caption attribute defines the text displayed on the
context menu, and the icon attribute defines the name of the image to display on the context menu.
<ongenerate>state=[function(load,fct)]</ongenerate>
The ongenerate element specifies the name of the IronPython function called when the load must
be evaluated. The function takes two arguments: the load object and a function to manage the progress
bar. This function must return True or False: True if the evaluation ended correctly, False otherwise.
<onaftergenerate>[function(load)]</onaftergenerate>
The onaftergenerate element specifies the name of the IronPython function called when the
generate callback is complete.
<oncleardata>[function(load)]</oncleardata>
The oncleardata element specifies the name of the IronPython function called when the load need
to be cleared. The function takes one argument: the load object. This function is called each time the
mesh is cleaned and when the user clicks on the Clear Generated Data context menu option.
<isvalid>[function(load)]</isvalid>
The isvalid element specifies the name of the IronPython function called when Mechanical checks
the validity of the load object.
<property> Element
The property element and its children define the properties required for this load. Through this
definition, these properties appear in the details view of the application's Details pane.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
167
Mandatory attributes
name
caption
Optional attributes
unit
The value of the unit attribute specifies the physical quantity to which
the result refers (for example, Length or Mass. See the ANSYS Workbench
User's Guide for details).
readonly
default
The value of the default attribute specifies the default value to use for
this property on initialization.
visible
This option indicates whether the property is visible in the detail view
window. The visible option can be used to show or hide a property
depending on another property value.
control
168
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
The text control activates a text area in which the user defines input data.
The select control activates a drop-down menu that contains a list of
available definitions.
The applycancelcontrol activates an Apply/Cancel button based on one
user-defined selection. This control is the most generic control type that can
be used with callbacks to integrate a variety of scenarios.
The template name: All pre-defined templates can be used as control type.
The following templates are available: scoping, component_selection,
geometry_selection, fileopen, entity_selection and
coordinatesystem_selection. Look at the file controltemplates.xml
in folder templates for more details on each template.
visibleon
class
To define all the callbacks related to a property, you can create a class in
Python where each defined function matches the name of a callback. In
this case the class attribute must contain the name of this class.
needupdate
If this attribute is equal to true, each time the user change the value of
the property, solution will be invalidated. If this attribute is equal to false,
any change will not impact the status of the solution.
<callbacks> Element
<property name="[property internal name (string)]"
caption="[property display name (string)]"
datatype="[string | int | double | string[] | int[] | double[] | undef]"
unit="[string]"
readonly="[true | false(default)]"
default="[default value]"
control="[scoping | text(default) | select | tabular | custom |
applycancel | file]">
<callbacks class="[class name that implement a sub set of callbacks]">
<onmigrate>[function(new property,old property)]</onmigrate>
<onactivate>[function(load,property)]</onactivate>
<onvalidate>[function(load,property)]</onvalidate>
<isvalid>[isvalid=function(load,property)]</isvalid>
<isvisible>[isvalid=function(load,property)] </isvisible>
<onapply>[function(load,property)]</onapply>
<oncancel>[function(load,property)]</oncancel>
<string2value>[value=function(load,property,string)] </string2value>
<value2string>[string=function(load,property,value)] </value2string>
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
169
The <callbacks> element and its children provide the means to specify the Python functions that
are invoked based on system and user-generated events related to load properties behavior. The callbacks
children are described below:
<onmigrate>[function(new_prop,old_prop)] </onactivate>
The onmigrate element specifies the name of the IronPython function called when Mechanical loads
the ACT customized load. This function allows you to maintain the properties related to the load from
one version number to another one. The function is called if the current version of the load is greater
than the last saved version. The new_prop argument contains the definition of the property as defined
in the XML file and old_prop contains the definition of the load previously saved in the project. With
this function, you can convert legacy data read from the project file to the new property initialized by
the updated XML file.
<onactivate>[function(load,property)]</onactivate>
The onactivate element specifies the name of the IronPython function called when the user selects
a load property in the details view. This callback is typically used to fill the options of a property when
the type select (ie. combo box) is used. The load and property are given as arguments.
<onvalidate>[function(load,property)]</onvalidate>
The onvalidate element specifies the name of the IronPython function called when you change the
value of a load property in the Details view. This callback is typically used to validate the new value.
The load and property are given as arguments.
<isvalid>[isvalid=function(load,property)] </isvalid>
The isvalid element specifies the name of the IronPython function called when Mechanical queries
the validity of the property.
<isvisible>[isvisible=function(load,property)] </isvisible>
The isvisible element specifies the name of the IronPython function called when Mechanical checks
if the property is visible or not. This function must return True or False.
<onapply>[function(load,property)]</onapply>
The onapply element specifies the name of the IronPython function called when the user selects the
Apply button in the load property control from the details view. The load and property are given
as arguments.
170
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
<oncancel>[function(load,property)]</oncancel>
The oncancel element specifies the name of the IronPython function called when the user selects
the Cancel button in the load property control from the Details view. The load and property are
given as arguments.
<string2value> [value=function(load,property,string)] </string2value>
The string2value element specifies the name of the IronPython function called when Mechanical
converts the string representation of a numeric value to a double. This function returns a double.
<value2string> [string=function(load,property,value)] </value2string>
The value2string element specifies the name of the IronPython function called when Mechanical
converts the numeric value to a string representation. This function returns a string.
<getvalue>[function(load,property,value)] </getvalue>
The getvalue element specifies the name of the IronPython function called each time the value of
the property is accessed. The load and property and the internal value of the property are given as
arguments.
<oninit>[function(load,property)]</oninit>
The oninit element specifies the name of the IronPython function called when the property is initialized.
<onshow>[function(load,property)]</onshow>
The onshow element specifies the name of the IronPython function called when the property is shown
in the targeted application.
<onhide>[function(load,property)]</onhide>
The onhide element specifies the name of the IronPython function called when the property is hidden
in the targeted application.
<onadd>[function(load,property)]</onadd>
The onadd element specifies the name of the IronPython function called when the property is added
in the targeted application.
<onduplicate>[function(load,property)]</onduplicate>
The onduplicate element specifies the name of the IronPython function called when the property
is duplicated.
<onremove>[function(load,property)]</onremove>
The onremove element specifies the name of the IronPython function called when the property is removed.
<setvalue>[function(load,property,value)]</setvalue>
The setvalue element specifies the name of the IronPython function called when the property is set
to the given value defined by the value argument.
<propertygroup> Element
A propertygroup has one more attribute than a standard property. This optional attribute is described
below.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
171
Optional attribute
display
The callbacks associated to a propertygroup are the same as those associated to a standard property.
<propertytable> Element
A propertytable has one more attribute than a propertygroup. This optional attribute is described
below.
Optional attribute
allowempty
The callbacks associated to a propertytable are the same as those associated to a standard property.
<result Element>
The <result> element and its children allows the user to configure the properties of a custom result
and to specify the IronPython functions that are invoked based on system and user-generated events.
<simdata context="[Project | Mechanical | ASim]">
172
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
averaging="[Average | ElementalDifference | ElementalFraction |
ElementalMean | NodalDifference | NodalFraction |
Unaverage]"
class="[class_name]"
hasimaginary="[True | False]">
</result>
...
</simdata>
The <result> element supports a set of attributes, as described below, and two child elements: the
callbacks element and the property element. These two elements and their children are presented
in the next two sections.
Mandatory attributes
name
version
caption
icon
location
type
timehistory
Optional attributes
unit
The value of the unit attribute specifies the physical quantity to which
the result refers (for example, Length or Mass. See the ANSYS Workbench
Documentation for details). If no unit is specified, then the result will be
considered as unitless.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
173
If true, the result can be added directly from the Insert context menu
available on the load object.
averaging
class
hasimaginary
<callbacks> Element
<result name="[result internal name (string)]"
version="[version identifier of the result (integer)]"
caption="[load display name (string)]"
icon="[name of an image located in images folders (string)]"
location="[node | elemnode | element]"
type="[scalar | vector | tensor]"
timehistory="[True| False]"
unit="">
<callbacks>
<onmigrate>[function(newResult,oldResult)]</onmigrate>
<onshow>[function(result)]</onshow>
<onhide>[function(result)]</onhide>
<oninit>[function(result)]</oninit>
<onadd>[function(result)]</onadd>
<onsuppress>[function(result)]</onsuppress>
<onunsuppress>[function(result)]</onunsuppresss>
<oncleardata>[function(result)]</oncleardata>
<onstarteval>[function(result,step)]</onstarteval>
<onendeval>[function(result,step)]</onendeval>
<getvalue>[values=function(result,entityId)]</getvalue>
<canadd>[function(analysis,loadName)]</canadd>
<onduplicate>[function(result)]</onduplicate>
<canduplicate>[function(result,parent_object)]</canduplicate>
<onremove>[function(result)]</onremove>
<canremove>[function(result)]</canremove>
<evaluate>[function(result,stepinfo,collector)]</evaluate>
<getfieldcount>[cuntion(result,entityId)]</getfieldcount>
<isvalid>[function(result)]</isvald>
</callbacks>
...
174
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
</result>
The <callbacks> element and its children specify the Python functions that are invoked based on
system and user-generated events related to the result behavior. The children of the callbacks element
are described below:
<onmigrate> [function(new_result,old_result)] </onmigrate>
The onmigrate element specifies the name of the IronPython function called when Mechanical loads
the ACT customized result. This function allows you to maintain the extension from one version number
to another. The function is called if the current version of the result is greater than the last saved version.
<onshow>[function(result)]</onshow>
The onshow element specifies the name of the IronPython function called when the result is "visible"
(ie. the result in the tree is selected). This function is used to display customized graphical information
associated with this result.
<onhide>[function(result)]</onhide>
The onhide element specifies the name of the IronPython function called when the result switches
from a visible status to a hidden status. This event is called when the ACT object is unselected.
<oninit>[function(result)]</oninit>
The oninit element specifies the name of the IronPython function called when the result is created.
<onadd>[function(result)]</onadd>
The onadd element specifies the name of the IronPython function called when the result is added. This
event is called when the ACT object is added to the project.
<onremove>[function(result)]</onremove>
The onremove element specifies the name of the IronPython function called when the result is deleted.
This event is called when the ACT object is deleted from the project.
<onsuppress>[function(result)]</onsuppress>
The onsuppress element specifies the name of the IronPython function called when the result switches
from an active state to a suppressed state. This event is called when the ACT object is suppressed.
<onunsuppress>[function(result)]</onunsuppress>
The onunsuppress element specifies the name of the IronPython function called when the result switches
from a suppressed state to an active state. This event is called when the ACT object is unsuppressed.
<oncleardata>[function(result)]</oncleardata>
The oncleardata element specifies the name of the IronPython function called when the hosting
application requests that the data stored in relation to this result is cleared. This event may be fired by
direct user action or implicitly as the result of upstream data changes in the application which invalidate
the result.
<onstarteval>[function(result,step)]</onstarteval>
The onstarteval element specifies the name of the IronPython function called when the evaluation
of the result is required. Operations such as memory allocations or file access can be done at this stage.
The argument step defines the step on which the evaluation has to be done.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
175
The onendeval element specifies the name of the IronPython function called when the evaluation of
the result is completed. Operations related to clean-up, such as releasing memory allocations or closing
external files, should be done at this stage.
<getvalue>[values=function(result,entityId)] </getvalue>
The getvalue element specifies the name of the IronPython function called when Mechanical retrieves
the results values. EntityId refers to a node ID or an element ID, depending on the type of the result.
For scalar results on nodes, the size of values is 1
For vector results on nodes, the size of values is 3
For scalar results on elements, the size of values is 1
For vector results on elements, the size of values is 3
For scalar results on nodes of elements, the size of values is equal to the number of nodes related to the
element.
For vector results on nodes of elements, the size of values is equal to 3 multiplied by the number of nodes
related to the element.
<canadd>[function(analysis,resultName)]</canadd>
The canadd element specifies the name of the IronPython function called when Mechanical evaluates
if a result can be created for the current analysis. canadd takes two arguments: the current analysis
and the name of the result to be validated. This function must return True or False.
<onduplicate>[function(result)]</onduplicate>
The onduplicate element specifies the name of the IronPython function called when Mechanical
duplicates the result object.
<canduplicate>[function(result,loadName)]</canduplicate>
The canduplicate element specifies the name of the IronPython function called when Mechanical
checks if the result object can be duplicated, depending on the selected parent object in the tree.
<onremove>[function(result)]</onremove>
The onremove element specifies the name of the IronPython function called when Mechanical removes
the result object.
<canremove>[function(result)]</canremove>
The canremove element specifies the name of the IronPython function called when Mechanical checks
if the result object can be removed.
<evaluate>[function(result,stepinfo,collector)]</evaluate>
The evaluate element specifies the name of the IronPython function called when Mechanical evaluates
the result.
The callback named evaluate replaces the two callbacks onstarteval and getvalue. This simplifies
the implementation of ACT results by combining the evaluation of the result with the passing of the
result to the application.
176
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
The stepinfo argument is an object with properties that provides information on the current result
set number or the current time step.
The collector argument is used by the application for displaying the result. When the function is
called, collector is already initialized with expected information such as IDs of the FE entities on
which a result is expected.
For example, for a scalar result to be computed on nodes or elements, the following implementation
sends the constant value value to the set of appropriate FE entities:
def evaluate(result, stepinfo, collector):
value = 1
for Id in collector.Ids:
collector.SetValues(Id,value)
<getfieldcount>[function(result,entityId)]</getfieldcount>
The getfieldcount element specifies the name of the IronPython function called to get the number
of fields for the current result related to one given element or node ID.
<isvalid>[function(result)]</isvalid>
The isvalid element specifies the name of the IronPython function called when Mechanical evaluates
if the result is valid.
<property> Element
The description of the property element for a result is the same as that of the property element
for the load. Please refer to the section 8.1.3.1.2 for that purpose.
<propertygroup> Element
The description of the propertygroup element for a result is the same as that of the propertygroup
element for the load. Please refer to the section 8.1.3.1.3 for that purpose.
<propertytable> Element
The description of the propertytable element for a result is the same as that of the propertytable
element for the load. Please refer to the section 8.1.3.1.4 for that purpose.
<solver> Element
The <solver> element and its children provide the means to configure a third party solver connection
and specify the IronPython functions that are invoked based on system and user-generated events.
<simdata context="[Project | Mechanical | DesignXplorer]">
...
<solver name="[solver internal name]"
version="[version identifier of the solver]"
caption="[solver display name]"
icon="[name of an icon file]"
analysis="[string (analysis type (Static))]"
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
177
The <solver> element has two child elements. These are the callbacks element and the property
element. These two elements and their children are presented in the next two sections.
The <solver> element supports a set of attributes as described below:
Mandatory attributes
name
The value of the name attribute specifies the name used by the application
to reference the solver.
version
The value of the version attribute allows to affect a version number to the
solver.
caption
The value of the caption attribute specifies the name displayed in the GUI
for the solver.
icon
The value of the icon attribute specifies the file name of the icon displayed
in the GUI for the solver. (An icon is a 16x16 pixel image in BMP, JPG, or GIF
format. Icon files are stored in the images sub-folder of the extension folder.)
analysis
The value of the analysis attribute specifies the analysis type that the
solver addresses. The current version of ACT only supports the Static analysis.
physics
The value of the type attribute specifies the physics to be used with the
solver. The current version of the ACT only supports the Structural physics.
Optional attributes
class
contextual
toolbox
Name of the toolbox which defines the group in which the solve takes place.
<callbacks> Element
<solver name="[solver internal name (string)]"
version="[version identifier of the solver (integer)]"
caption="[load display name (string)]"
icon="[name of an image located in images folders (string)]"
analysis="[string (analysis type (Static))]"
physics="[string (physics type (Structural))]">
<callbacks>
178
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
<onmigrate>[function(newSolver,oldSolver)]</onmigrate>
<oninit>[function(solver)]</oninit>
<onshow>[function(solver)]</onshow>
<onhide>[function(solver)]</onhide>
<onbeforesolve>[function(solver)]</onbeforesolve>
<onsolve>[function(solver)]</onsolve>
<oncleardata>[function(solver)]</ onwriteinputfile >
<onwriteinputfile>[function(solver)]</oncleardata>
<getsteps>[function(solver)]</getsteps>
<isanalysisvalid>[function(solver)]</isanalysisvalid>
<getreader>[function(solver)]</getreader>
<onadd>[function(parent object, object name)]</onadd>
<onremove>[function(solver)]</onremove>
<isvalid>[function(solver)]</isvalid>
<oncheckresults>[function(solver)]</oncheckresults>
</callbacks>
...
</solver>
The <callbacks> element and its children provide the means to specify the Python functions that
are invoked based on system and user-generated events related to the solver behavior. The callbacks
children are described below:
<onmigrate>[function(new_solver,old_solver)] </onmigrate>
The onmigrate element specifies the name of the IronPython function called when Mechanical is
launched. This function allows you to maintain the extension from one version to any other more recent
one to the next. The function is called if the current version of the solver is newer than the last saved
version.
<oninit>[function(solver)]</oninit>
The oninit element specifies the name of the IronPython function called when Mechanical is launched.
<onshow>[function(solver)]</onshow>
The onshow element specifies the name of the IronPython function called when the customized analysis settings object related to the solver is activated.
<onhide>[function(solver)]</onhide>
The onhide element specifies the name of the IronPython function called when the customized analysis settings object is deactivated.
<onbeforesolve>[function(solver)]</onbeforesolve>
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
179
The onsolve element specifies the name of the IronPython function called when the solver is launched.
<oncleardata>[function(solver)]</oncleardata>
The oncleardata element specifies the name of the IronPython function called when the hosting
application requests that the data stored in relation to this solver is cleared. This event may be fired by
direct user action or implicitly as the result of upstream data changes in the application which invalidate
the solution.
<onwriteinputfile>[function(solver)]</onwriteinputfile >
The onwriteinputfile element specifies the name of the IronPython function called when the
hosting application requests that the solver write the input stream. This event may be kicked off by
direct user action or implicitly as the result of upstream request in the application.
<getsteps>[function(solver)]</getsteps>
The getsteps element specifies the name of the IronPython function called to retrieve the list of the
step end time values. This function must return a list of double values.
<isanalysisvalid>[function name(solver,firstCheck)] </isanalysisvalid>
The isanalysisvalid element specifies the name of the IronPython function called when Mechanical retrieves the status of the analysis. The declaration of the called function must be:
def function_name(solver,firstCheck):
The input argument solver defines the current solver associated to the current analysis to be checked.
The input argument firstCheck indicates if Mechanical calls this function before or after the standard
validation. Mechanical will call this function with firstCheck set to True before the standard check
and will call a second time this function with firstCheck set to False after.
This function must return an integer value equal to -1, 0 or 1.
-1 means that the user doesn't want to check anything here, 0 means that the solver definition is not
yet valid, and 1 means that the solver is ready to be launched. If the returned value is not equal to -1
and firstCheck is equal to True, then the standard check performed by Mechanical is skipped.
<getreader>[function(solver)]</getreader>
The getreader element specifies the name of the IronPython function called to retrieve the name
and string arguments of the result reader associated with this solver. This function must return a list of
string values, where the first value is the name of the IronPython class.
<onadd>[function(solver)]</onadd>
The onadd element specifies the name of the IronPython function called when Mechanical is launched
for the first time with the solver connection.
<onremove>[function(solver)]</onremove>
The onremove element specifies the name of the IronPython function called when the system linked
with the solver is removed from the schematic.
180
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
<isvalid>[function(solver)]</isvalid>
The isvalid element specifies the name of the IronPython function called when Mechanical checks
if the analysis settings object is valid. The function returns True or False.
<oncheckresults>[function(solver)]</oncheckresults>
The oncheckresults element specifies the name of the IronPython function called when Mechanical
starts a post-processing task. The function returns True or False.
<property> Element
The description of the property element on the solver is the same as the description for the
<property> element on the load. Please refer to the section 8.1.3.1.3 for more information.
Note
The applycancel and custom properties cannot be used in one customized analysis
settings object with the current version of ACT.
<propertygroup> Element
The description of the propertygroup element on the solver is the same as the description for the
<propertygroup> element on the load. Please refer to the section 8.1.3.1.3 for more information.
<propertytable> Element
The description of the propertytable element on the solver is the same as the description for the
<propertytable> element on the load. So you can refer to the section 8.1.3.1.4 for more information.
<sampling> Element
This section applies to the ANSYS DesignXplorer application only.
The <sampling> element allows you to configure the properties of the sampling and specify the
functions that are invoked based on system and user-generated events.
<optimizer>
<callbacks> ... </callbacks>
<property>
<propertygroup>
<propertytable>
</optimizer>
Mandatory Attributes
name
version
Optional Attributes
Caption
Class
181
LogFile
MaximumNumberOfInputParameters
MaximumNumberOfIntegerListParameters
For more detailed information on attributes supported by the <sampling> element, see the "Sampling"
section in the ACT Reference Guide for DesignXplorer.
<callbacks> Element
The <callbacks> element lets you specify the Python functions that are invoked based on systemgenerated and user-generated events related to the optimizer behavior. Each child of the <callbacks>
element has a specific name and corresponds to a specific callback, as shown below.
<simdata context="DesignXplorer">
<sampling name="[sampling internal name]"
caption="[sampling display name]"
icon="[name of an icon file]"
version="[version identifier of the sampling]">
<callbacks>
<OnCreate>[function(entity)]</OnCreate>
<CanRun>[function(entity)]</CanRun>
<Description>[function(entity)]</Description>
<Configuration>[function(entity)]</Configuration>
<Status>[function(entity)]</Status>
<QuickHelp>[function(entity)]</QuickHelp>
<InputParametersEdited>[function(entity)]</InputParametersEdited>
<MethodPropertiesEdited>[function(entity)]</MethodPropertiesEdited>
<OnMigrate>[function(newentity,oldentity)]</OnMigrate>
<OnRelease>[function(entity)]</OnRelease>
</callbacks>
</sampling>
</simdata>
When most callbacks are invoked, an entity object of the type DXUserSampling is passed to them,
allowing the function to easily access data and determine the context in which it has been invoked.
On the entity object,
Each attribute of the <sampling> element appears as a property. For example, the Python code entity.
LogFile allows you to access the value of the LogFile attribute.
Each <property> element appears in the Properties dictionary and is accessible by its name. For instance, if the <property> element MyProperty is defined, you can access its value in Python by writing
entity.Properties[MyProperty].Value.
Several additional properties associated with the sampling also appear as properties. For example, NumberOfInputParametersDefined is an additional property reflecting the current definition of the
samplingstudy. For a comprehensive list of properties, see the "IUserSampling" section in the ACT Reference Guide for DesignXplorer.
182
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
The following table lists the callbacks available for the <sampling> element. Subsequent sections
provide information on using several of the most common callbacks. For more detailed information on
available callbacks, see the DOE section in the ACT Reference Guide for DesignXplorer.
CanAdd
CanRun
Configuration
Description
InputParametersEdited
MethodPropertiesEdited
OnAdd
OnCreate
OnInit
OnMigrate
OnRelease
QuickHelp
Status
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
183
This function returns a Quick Help message which can be displayed when the user clicks on the Quick
Help icon in the user interface, as shown in Figure 65: Quick Help in the Optimization Outline View (p. 190).
184
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
Figure 64: Quick Help in the DOE Outline View
<optimizer> Element
This section applies to the ANSYS DesignXplorer application only.
The <optimizer> element allows you to configure the properties of the optimization and specify the
functions that are invoked based on system and user-generated events.
<optimizer>
<callbacks> ... </callbacks>
<property>
<propertygroup>
<propertytable>
</optimizer>
Mandatory Attributes
name
version
Optional Attributes
BasedOnDirectOptimizationOnly
BasedOnResponseSurfaceOnly
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
185
Class
ConstraintHandling
ConstraintImportance
ConstraintOnInputParameter
ConvergenceData
EqualToConstraint
GreaterThanConstraint
HistoryChartXAxisType
Icon
InsideBoundsConstraint
LessThanConstraint
LogFile
MaximizeObjective
MaximumNumberOfConstraints
MaximumNumberOfDoubleListParameters
MaximumNumberOfDoubleParameters
MaximumNumberOfInputParameters
MaximumNumberOfIntegerListParameters
MaximumNumberOfObjectives
MinimizeObjective
MinimumNumberOfConstraints
MinimumNumberOfObjectives
ObjectiveImportance
ObjectiveOnInputParameter
ParameterRelationship
SeekObjective
StartingPointRequired
For more detailed information on attributes supported by the <optimizer> element, see the "Optimizer" section in the ACT Reference Guide for DesignXplorer.
<callbacks> Element
The <callbacks> element lets you specify the Python functions that are invoked based on systemgenerated and user-generated events related to the optimizer behavior. Each child of the <callbacks>
element has a specific name and corresponds to a specific callback, as shown below.
186
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
<simdata context="DesignXplorer">
<optimizer name="[optimizer internal name]"
caption="[optimizer display name]"
icon="[name of an icon file]"
version="[version identifier of the optimizer]">
<callbacks>
<OnCreate>[function(entity)]</OnCreate>
<CanRun>[function(entity)]</CanRun>
<Description>[function(entity)]</Description>
<Configuration>[function(entity)]</Configuration>
<Status>[function(entity)]</Status>
<QuickHelp>[function(entity)]</QuickHelp>
<InputParametersEdited>[function(entity)]</InputParametersEdited>
<ObjectivesOrConstraintsEdited>[function(entity)]</ObjectivesOrConstraintsEdited>
<MethodPropertiesEdited>[function(entity)]</MethodPropertiesEdited>
<OnMigrate>[function(newentity,oldentity)]</OnMigrate>
<OnRelease>[function(entity)]</OnRelease>
</callbacks>
</optimizer>
</simdata>
When most callbacks are invoked, an entity object of the type DXUserOptimizer is passed to them,
allowing the function to easily access data and determine the context in which it has been invoked.
On the entity object,
Each attribute of the <optimizer> element appears as a property. For example, the Python code entity.SeekObjective allows you to access the value of the SeekObjective attribute.
Each <property> element appears in the Properties dictionary and is accessible by its name. For instance, if the <property> element MyProperty is defined, you can access its value in Python by
writing entity.Properties[MyProperty].Value.
Several additional properties associated with the optimization study also appear as properties. For example,
IsDirectOptimization and NumberOfInputParametersDefined are additional properties reflecting the current definition of the optimization study. For a comprehensive list of properties, see the
IUserOptimizer section in the ACT Reference Guide for DesignXplorer.
The following table lists the callbacks available for the <optimizer> element. Subsequent sections
provide information on using several of the most common callbacks. For more detailed information on
available callbacks, see the Optimizer section in the ACT Reference Guide for DesignXplorer.
CanAdd
CanRun
Configuration
ConvergenceDescription
Description
InputParametersEdited
MethodPropertiesEdited
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
187
OnAdd
OnCreate
OnInit
OnMigrate
OnRelease
ParameterRelationshipsEdited
QuickHelp
Status
The createRandomOptimizer function retrieves the value of the RandomSeed property and creates
a new instance of RandomOptimizer, passing the seed in an argument. The instance implements
IOptimizationMethod. It is returned to the caller.
The OnRelease callback specifies the function to allow DX to release the optimizer instance at the
end of the optimization process. It is assumed that the callback will delete the instance initially created
by invoking OnCreate.
188
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<extension> Element
own logic, based on the properties provided by the DXUserOptimizer object and with the internal
dependencies and conditions managed in your own code. For instance, this function could check with
your own mechanism whether the user has a valid license to use the optimizer. The function defined
for the CanRun callback must return a Boolean value: True if the optimizer can run, False otherwise.
If CanRun returns False, the optimization process is aborted.
def canRunOptimizer(entity):
maximumNumberOfCandidates = entity.Properties["MyMaximumNumberOfCandidates"].Value
numberOfSamples = entity.Properties["MyNumberOfSamples"].Value
if maximumNumberOfCandidates <= 0 or maximumNumberOfCandidates > numberOfSamples:
return False;
if numberOfSamples <= 0 or numberOfSamples > 10000:
return False;
if entity.NumberOfObjectivesDefined == 0 and
entity.NumberOfConstraintsDefined == 0 and
entity.NumberOfObjectivesDefinedOnInputs == 0 and entity.NumberOfConstraintsDefinedOnInputs == 0:
return False
return True
This function returns a Quick Help message which can be displayed when the user clicks on the Quick
Help icon in the user interface, as shown in Figure 65: Quick Help in the Optimization Outline View (p. 190).
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
189
In Figure 66: Information Exposed in the Optimization Properties View (p. 190), we can see that the Optimization Method group displays a summary of the information provided by the optimizer, as follows:
The first line contains a brief description of the optimization. The cell A4 contains the name of the optimizer
as defined in the XML file, and the cell B4 contains the string returned by the Description callback.
The second line contains the configuration of the current optimization. The cell B5 is contains the string
returned by the Configuration callback.
190
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Note
If the callbacks are not implemented, cells B4, B5, and B6 remain empty.
Here is an example of a callbacks implementation. Given the partial optimizer definition:
<optimizer >
<callbacks>
<Description>getDescription</Description>
<Configuration>getConfiguration</Configuration>
<Status>getStatus</Status>
</callbacks>
<property name="MyOptimizationStatus" caption="My Optimization Status" control="text"
readonly="true"></property>
<property name="MyNumberOfEvaluations" caption="My Number of Evaluations" control="integer"
readonly="true"></property>
</optimizer>
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
191
<propertygroup>
<property> ... </property>
<propertygroup> ... </propertygroup>
</propertygroup>
</controltemplate>
</templates>
<interface context="[Project | Mechanical]">
<callbacks>
<oninit>[function(context)]</oninit>
<onbeforesolve>[function(analysis)]</onbeforesolve>
<onaftersolve>[function(analysis)]</onaftersolve>
<isanalysisvalid>[function(analysis,firstCheck)]</isanalysisvalid>
<onload>[function(currentFolder)]</onload>
<onsave>[function(currentFolder)]</onsave>
<ondraw>[function()]</ondraw>
<ondraw2d>[function()]</ondraw2d>
<getprecommands>[function(analysis,stream)]</getprecommands>
<getsolvecommands timedependent="[true | false(default)]">
[function(analysis,stream)]</getsolvecommands>
<getpostcommands>[function(analysis,stream)]</getpostcommands>
<onpostfinished>[function(analysis)]</onpostfinished>
<onpoststarted>[function(analysis)]</onpoststarted>
<onterminate>[function(context)]</onterminate>
<resume>[function(binary reader)]</resume>
<save>[function(binary writer)]</save>
</callbacks>
<toolbar name="[toolbar internal name (string)]"
caption="[toolbar display name (string)]">
<entry name="[toolbar button internal name (string)]"
caption="[toolbar button display name (string)]"
icon="[image located in images folders (string)]">
userobject="[object name (string)]">
<callbacks>
192
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<onclick>[function(analysis)]</onclick>
</callbacks>
</entry>
<separator> ... </separator>
</entry>
<separator> ... </separator>
</toolbar>
</interface>
<simdata context="[Project | Mechanical | DesignXplorer]">
<load name="[load internal name (string)]"
caption="[load display name (string)]"
version="[version identifier of the load (integer)]"
icon="[image name located in images folders (string)]"
class="[class name]"
issupport="[true | false]"
isload="[true | false]"
color="[#xxxxxx]"
unit=""
contextual="[true | false]">
<attributes [attribute="" name=""]="[attribute value]" ...>
<[attribute_name (string)]>[attribute value (string)]
</[attribute_name (string)]>
</attributes>
<callbacks>
<canadd>[function(analysis,loadName)]</canadd>
<action name="[name of the action (string)]"
icon="[image name located in images folders (string)]">
[function(load)]</action>
<onmigrate>[function(newLoad,oldLoad)]</onmigrate>
<onsuppress>[function(load)]</onsuppress>
<onunsuppress>[function(load)]</onunsuppress>
<onadd>[function(load)]</onadd>
<onremove>[function(load)]</onremove>
<onshow>[function(load)]</onshow>
<onhide>[function(load)]</onhide>
<oninit>[function(load)]</oninit>
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
193
<oncleardata>[function(load)]</oncleardata>
<ongenerate>[function(load)]</ongenerate>
<onaftergenerate>[function(load)]</onaftergenerate>
<getprecommands order="[(integer)]">
[function(load,stream)]</getprecommands>
<getsolvecommands order="[(integer)]"
timedependent="[true | false(default)]">
[function(load,stream)]</getsolvecommands>
<getpostcommands order="[(integer)]">
[function(load,filename)]</getpostcommands>
<getnodalvaluesfordisplay>
[values=function(load,nodeIds)]
</getnodalvaluesfordisplay>
</callbacks>
<property name="[property internal name (string)]"
caption="[property internal name (string)]"
unit="[string]"
control="[text(default) | select | float |
integer | custom | applycancel |
[template name (string)]]"
readonly="[true | false(default)]"
visible="[true(default) | false]"
visibleon="[values (separator '|')]"
needupdate="[true(default) | false]"
default="[default value]"
class="[class name]">
<attributes> ... </attributes>
<callbacks>
<onmigrate>[function(new property,old property)]
</onmigrate>
<onactivate>[function(load,property)]</onactivate>
<onvalidate>[function(load,property)]</onvalidate>
<onapply>[function(load,property)]</onapply>
<oncancel>[function(load,property)]</oncancel>
<value2string>[string=function(load,property,value)]
</value2string>
194
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<string2value>[value=function(load,property,string)]
</string2value>
<isvalid>[isvalid=function(load,property)]</isvalid>
<isvisible>[isvalid=function(load,property)]
</isvisible>
<getvalue>[value=function(load,property,value)]
</getvalue>
<oninit>[function(load,property)]</oninit>
<onshow>[function(load,property)]</onshow>
<onhide>[function(load,property)]</onhide>
</callbacks>
</property>
<propertygroup name="[property internal name (string)]"
caption="[property display name (string)]"
unit="[string]"
control="[text(default) | select | float |
integer | custom | applycancel |
[template name (string)]]"
readonly="[true | false(default)]"
visible="[true(default) | false]"
visibleon="[values (separator '|')]"
needupdate="[true(default) | false]"
default="[default value]"
class="[class name]"
display="[none | caption(default) |
property | worksheet]">
<attributes> ... </attributes>
<callbacks>
...
</callbacks>
</propertygroup>
<propertytable name="[property internal name (string)]"
caption="[property display name (string)]"
unit="[string]"
control="[text(default) | select | float |
integer | custom | applycancel |
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
195
</load>
<object> ... </object>
<result name="[result internal name (string)]"
caption="[load display name (string)]"
version="[version identifier of the result (integer)]"
icon="[image name located in images folders (string)]"
class="[class name]"
location="[node | elemnode | element]"
type="[scalar | vector | tensor]"
timehistory="[true | false]"
unit="[quantity nale (string)]" >
<callbacks>
<onmigrate>[function(newResult,oldResult)]</onmigrate>
<onsuppress>[function(result)]</onsuppress>
<onunsuppress>[function(result)]</onunsuppress>
<onadd>[function(result)]</onadd>
<onremove>[function(result)]</onremove>
<onshow>[function(result)]</onshow>
<onhide>[function(result)]</onhide>
<oninit>[function(result)]</oninit>
196
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
<oncleardata>[function(result)]</oncleardata>
<ongeneratedata>[function(result)]</ongeneratedata>
<getvalue>[values=function(result,entityId)]</getvalue>
<onstarteval>[function(result,step)]</onstarteval>
<onendeval>[function(result,step)]</onendeval>
</callbacks>
</result>
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
197
</extension>
198
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Debug Mode
When developing an extension, we recommend you activate the Debug mode option available in the
Extensions Options, accessed on the Tools>Options menu. The two figures below illustrate how to
access this mode.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
199
200
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Debug Mode
Figure 68: Debug Mode for Extensions
The activation of the Debug mode option provides two additional buttons in the ACT toolbar of
Mechanical, as shown below.
Figure 69: ACT Debug Buttons
The Reload extensions button allows you to reload from Mechanical the extensions currently loaded.
This feature is of particular interest during the development of the extension, as it provides an efficient
method to interactively test the changes in an XML file or Python function. For major changes, ensure
the object acts as expected by deleting the ACT objects previously defined in Mechanical and recreating
them. When not in Debug mode, you can reload your extensions by quitting Workbench and restarting
your session.
The View log file button opens the log file. This file provides warning or error messages generated by
the extension. This feature is also very useful during the development of the extensions. Each time an
error occurs in an extension, the icon is shown in red. Note that you can also view the log file from the
main project page by selecting Extensions>View Log File.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
201
The Debug mode is activated when the Mechanical application is next started. If Mechanical is already
open when the Debug mode is activated, close and restart Mechanical to use Debug mode.
If the Debug mode is not activated, and you have modified the extension XML file, you must close and
restart ANSYS Workbench to reload extensions. If you have made modifications to the Python functions,
you must close and restart only the Mechanical process.
202
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Debugging an Extension
Figure 71: Console Window for ACT Extension
When you enter a period . into the Command Line Editor, a list of available functions are displayed
into the Functions list box. This list is updated only when a period is entered.
When you click on an item in the Functions list box, the prototype of this function is displayed into
the Information pane. Please note that the self argument is an internal python argument, and this
argument does not have to be specified during the call of the function.
Each extension runs with a dedicated script engine. That means that to access to global variables or
functions associated to an extension the user needs first to select the appropriate extension by selecting
it using the extension selector.
Debugging an Extension
Debug a running Python script using one of the following methods.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
203
Before attaching the process to Visual Studio, make sure you are using the correct select code. The
Managed (v.4.0) option must be selected.
After attach, you can open your Python code and set some breakpoints into it.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Debugging an Extension
Python Tools for Visual Studio (PTVS) is a free tool hosted by CodePlex.
Before installing PTVS, download and install Visual Studio 2010 Shell Isolated Mode Redistributable
package.
http://www.microsoft.com/downloads/en/details.aspx?familyid=8E5AA7B6-8436-43F0-B77800C3BCA733D3&displaylang=en
Then, download PTVS and install it.
http://pytools.codeplex.com/
You can use any version of Visual Studio from 2010 and above to develop and debug your ACT extensions.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
205
206
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Advanced Programming in C#
This section explains how to replace IronPython code with C# assemblies. C# is used in this document
but any language that creates .NET assemblies can also be used for that purpose. This section assumes
that you already know how to create an assembly in C#.
C# provides two major advantages over IronPython:
Better performance
Superior development environment which provides auto completion.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
207
Advanced Programming in C#
</extension>
In the definition of the load object, the only change is the use of the attribute class. This attribute must
be set to the name of the class to be used for the integration of the load.
The CSharp.Load class is described below:
using
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
Ansys.ACT.Interfaces.Mechanical;
Ansys.ACT.Interfaces.UserObject;
namespace CSharp
{
public class Load
{
IMechanicalExtAPI _ExtAPI = null;
public Load(IMechanicalExtAPI extApi,IUserLoad load)
{
_ExtAPI = extApi;
}
public IEnumerable<double> getnodalvaluesfordisplay(ISimLoad load, IEnumerable<int> nodeIds)
{
List<double> res = new List<double>();
var mesh = load.Analysis.MeshData;
foreach (int nodeId in nodeIds)
{
var node = mesh.NodeById(nodeId);
res.Add(Math.Sqrt(node.X * node.X + node.Y * node.Y + node.Z * node.Z));
}
return res;
}
}
}
To implement a callback in C#, create a new method in your class with the name of the callback in
lower case.
In the example, you implement the callback <getnodalvaluesfordisplay> by adding the method
getnodalvaluesfordisplay to the class.
208
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
For the load definition, the attribute class must be set to the name of the class to be used for the
integration of the result.
The CSharp.Result class is described below:
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.Linq;
System.Text;
Ansys.ACT.Interfaces.Mechanical;
Ansys.ACT.Interfaces.Post;
Ansys.ACT.Interfaces.UserObject;
namespace CSharp
{
public class Result
{
internal double[] res = new double[1];
public Result(IMechanicalExtAPI extApi, IUserResult result)
{
}
public void evaluate(IUserResult entity, IStepInfo stepInfo, IResultCollector collector)
{
foreach (var id in collector.Ids)
{
res[0] = id;
collector.SetValues(id, res);
}
}
}
}
As for the load definition, the implementation of a new callback simply requires you add a new method
with the name of the callback.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
209
210
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Limitations
You should be aware of the following limitations in the current version of ACT before developing your
extensions.
Localization of ACT is limited to the languages currently supported in ANSYS Workbench. This limitation
does not apply to the ability to manage various languages within the extension. For example, the property
names created by an extension do not have to be in the same language as the current activated language
in ANSYS Workbench. There is no mechanism to integrate localization for the property names defined by
an extension. You have to develop by yourself the localization if you want manage different languages for
your property names. Both regional settings based on the . or the , decimal symbol are available. However,
the implementation of the extension should use the . symbol for any value defined at the XML or Python
level.
You cannot specify a layer number for layered elements when using the reader to get access to ANSYS results.
Only the top of the top layer result and the bottom of the bottom layer results can be retrieved.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
211
212
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Examples
ACT supports application customization by exposing a set of interfaces for each supported application.
So far this discussion has focused on making simple additions to the ANSYS user interface and specifying
queries into the simulation project datum. This chapter focuses on more advanced usages of the API
for the data model of ANSYS Mechanical and ANSYs DesignXplorer. The examples in this section build
upon the methods and techniques discussed in the previous chapters.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
213
Examples
</extension>
Figure 72: Von-Mises Stress Details (p. 214) shows how the toolbar and result are added to the ANSYS
Mechanical user interface.
Figure 72: Von-Mises Stress Details
The Python script for the Mises extension, shown below, defines a callback function named <Create_Mises_Result>. When activated by the Von Mises Stress toolbar button, this callback creates
the result "Von Mises Stress." The callback invokes the Create_Mises_Result method on the
simDataMgr interface. The Mises.xml file provides the details needed to create the Von Mises
Stress toolbar/button and result.
In addition, the main.py file contains all the Python functions useful for this extension.
At the top of the script is the list definition for the node adjacency tables. The list, named "link," is a
list of hash maps. Each hash map uses as its hash key the numeral corresponding to the type returned
by the IElement Type property. The value for hash map is a list of arrays. The names of the arrays
match the local node numbers for a typical element of the key (element-type). Finally, the content of
each array provides the adjacent local node numbers for the corresponding elements node. This list of
arrays makes this extension compatible with all the different element topologies that Mechanical will
potentially create during the mesh generation.
The XML definition for "Von Mises Stress" specifies one other callback that we see in the Python script.
This callback is:
<evaluate>Mises_At_Nodes_Eval<evaluate>
214
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
def Create_Mises_Result(analysis):
analysis.CreateResultObject("Von Mises Stress")
# This function evaluates the specific result (i.e. the Von-Mises stress) on each element
# required by the geometry selection
# The input data "step" represents the step on which we have to evaluate the result
def Mises_At_Nodes_Eval(result, stepInfo, collector):
ExtAPI.Log.WriteMessage("Launch evaluation of the Mises result at nodes: ")
# Reader initialization
reader = result.Analysis.GetResultsData()
step = int(stepInfo.Set)
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
215
Examples
reader.CurrentResultSet = step
# Get the stress result from the reader
stress = reader.GetResult("S")
unit_stress = stress.GetComponentInfo("X").Unit
conv_stress = units.ConvertUnit(1.,unit_stress,"Pa","Stress")
# Get the selected geometry
prop_geo = result.Properties["Geometry"]
ref_ids = prop_geo.Value.Ids
nodal_stress = [0.] * 6
# Get the mesh of the model
mesh = result.Analysis.MeshData
# Loop on the list of the selected geometrical entities
for ref_id in ref_ids:
# Get mesh information for each geometrical entity
mesh_region = mesh.MeshRegionById(ref_id)
node_ids = mesh_region.NodeIds
# Loop on the nodes related to the current geometrical refId
for node_id in node_ids:
for i in range(6):
nodal_stress[i] = 0.
element_ids = mesh.NodeById(node_id).ConnectedElementIds
num = 0
# Loop on the elements related to the current node
for element_id in element_ids:
# Get the stress tensor related to the current element
tensor = stress.ElementValue(element_id,"X;Y;Z;XY;XZ;YZ")
element = mesh.ElementById(element_id)
# Look for the position of the node nodeId in the element element_id
# cpt contains this position
cpt = element.NodeIds.IndexOf(node_id)
# for corner nodes, cpt is useless.
# The n corner nodes of one element are always the first n nodes of the list
if cpt < element.CornerNodeIds.Count:
for i in range(6):
nodal_stress[i] = nodal_stress[i] + tensor[6*cpt+i]
else:
# For midside nodes, cpt is used and the link table provides the two neighbouring
# corner nodes for the midside node identified in the list by cpt
itoadd = link[element.Type][cpt]
for ii in itoadd:
for i in range(6):
nodal_stress[i] = nodal_stress[i] + tensor[6*ii+i] / 2.
num += 1
# The average stress tensor is computed before to compute the Von-Mises stress
# num is the number of elements connected with the current node node_id
for i in range(6):
nodal_stress[i] *= conv_stress / num
# Von-Mises stress computation
vm_stress = Mises(nodal_stress)
# Result storage
if node_id in collector.Ids:
collector.SetValues(node_id, [vm_stress])
# This function computes the Von-Mises stress from the stress tensor
# The Von-Mises stess is computed based on the three eigenvalues of the stress tensor
def Mises(tensor):
# Computation of the eigenvalues
216
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
# This function computes the three eigenvalues of one [3*3] symetric tensor
EPSILON = 1e-4
def Eigen_Values(tensor):
a
b
c
d
e
f
=
=
=
=
=
=
tensor[0]
tensor[1]
tensor[2]
tensor[3]
tensor[4]
tensor[5]
= -2*R*cos(phi/3)-A/3
= -2*R*cos(phi/3+2*math.pi/3)-A/3
= -2*R*cos(phi/3+4*math.pi/3)-A/3
= a
= b
= c
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
217
Examples
<toolbar name="Coupling" caption="Coupling">
<entry name="Coupling" icon="support">
<callbacks>
<onclick>CreateCoupling</onclick>
</callbacks>
</entry>
</toolbar>
</interface>
<simdata context="Mechanical">
<load name="Coupling" version="1" caption="Coupling" icon="support" issupport="true"
color="#FF0000">
<callbacks>
<getsolvecommands>SolveCmd</getsolvecommands>
<onshow>ShowCoupling</onshow>
<onhide>HideCoupling</onhide>
</callbacks>
<property name="Source" caption="Source" control="scoping">
<attributes selection_filter="edge" />
<callbacks>
<isvalid>IsValidCoupledScoping</isvalid>
<onvalidate>OnValidateScoping</onvalidate>
</callbacks>
</property>
<property name="Target" caption="Target" control="scoping">
<attributes selection_filter="edge" />
<callbacks>
<isvalid>IsValidCoupledScoping</isvalid>
<onvalidate>OnValidateScoping</onvalidate>
</callbacks>
</property>
<property name="Reverse" caption="Reverse" control="select" default="No">
<attributes options="No,Yes" />
<callbacks>
<onvalidate>OnValidateReverse</onvalidate>
</callbacks>
</property>
</load>
</simdata>
</extension>
Figure 73: Fully-defined Coupling in Mechanical (p. 219) shows how a fully defined coupling appears in
ANSYS Mechanical.
218
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
The Python script for the Coupling extension, shown below, defines a callback function named <CreateCoupling>. When activated by the Coupling toolbar button, this callback creates the load "Coupling."
The callback invokes the CreateLoadObject method for the current analysis. The function SolveCmd
is called when the solver input is being generated. SolveCmd invokes GetListNodes to obtain two
lists of nodeids corresponding to the Target and Source edges. These nodeids are then used to write
APDL CP commands to the solver input. GetListNodes is also invoked by the <ShowCoupling> callback
function. In <ShowCoupling>, the IGraphics interface is used to create a graphics context. Using the
object returned, the inter-nodal lines are drawn to provide a visual representation of the coupling.
The graphics context associated with this custom load and the validation of the user inputs impose to
manage more various situations than for the first example described in the previous section. This explains
why more functions and sub-functions are required for this example.
import graphics
def CreateCoupling(analysis):
analysis.CreateLoadObject("Coupling")
#------------------------------#
Callbacks
#------------------------------def OnValidateReverse(load, prop):
ShowCoupling(load)
def OnValidateScoping(load, prop):
ShowCoupling(load)
def IsValidScoping(load, prop):
if not prop.Controller.isvalid(load, prop):
return False
selection = prop.Value
if selection == None: return False
if selection.Ids.Count != 1: return False
return True
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
219
Examples
def IsValidCoupledScoping(load, prop):
sProp = load.Properties["Source"]
tProp = load.Properties["Target"]
if not IsValidScoping(load, sProp):
return False
if not IsValidScoping(load, tProp):
return False
sIds = sProp.Value.Ids
tIds = tProp.Value.Ids
try:
mesh = load.Analysis.MeshData
sNum = mesh.MeshRegionById(sIds[0]).NodeCount
tNum = mesh.MeshRegionById(tIds[0]).NodeCount
if sNum == 0 or tNum == 0: return False
except:
return False
def ShowCoupling(load):
delContext(load)
ctxCoupling = ExtAPI.Graphics.CreateAndOpenDraw3DContext()
sourceColor = load.Color
targetColor = 0x00FF00
lineColor
= 0x0000FF
sProp = load.Properties["Source"] ; sSel = sProp.Value
tProp = load.Properties["Target"] ; tSel = tProp.Value
ctxCoupling.LineWeight = 1.5
if sSel != None:
ctxCoupling.Color = sourceColor
for id in sSel.Ids:
graphics.DrawGeoEntity(ExtAPI, load.Analysis.GeoData, id, ctxCoupling)
if tSel != None:
ctxCoupling.Color = targetColor
for id in tSel.Ids:
graphics.DrawGeoEntity(ExtAPI, load.Analysis.GeoData, id, ctxCoupling)
if IsValidSelections(load):
ctxCoupling.Color = lineColor
ctxCoupling.LineWeight = 1.5
220
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
mesh = load.Analysis.MeshData
sList, tList = GetListNodes(load)
for sId, tId in zip(sList, tList):
sNode = mesh.NodeById(sId)
tNode = mesh.NodeById(tId)
ctxCoupling.DrawPolyline([sNode.X,sNode.Y,sNode.Z,tNode.X,tNode.Y,tNode.Z])
ctxCoupling.Close()
ctxCoupling.Visible = True
setContext(load, ctxCoupling)
def HideCoupling(load):
delContext(load)
#------------------------------#
Commands
#------------------------------def SolveCmd(load, s):
s.WriteLine("! Coupling - CP")
sList, tList = GetListNodes(load)
for sId, tId in zip(sList, tList):
s.WriteLine("CP,NEXT,ALL,{0},{1}", sId, tId)
#------------------------------#
Utils
#------------------------------def IsValidSelections(load):
return load.Properties["Source"].IsValid and load.Properties["Target"].IsValid
def GetListNodes(load):
if IsValidSelections(load):
sProp = load.Properties["Source"] ; sIds = sProp.Value.Ids
tProp = load.Properties["Target"] ; tIds = tProp.Value.Ids
geometry = ExtAPI.DataModel.GeoData
mesh = load.Analysis.MeshData
sList = GetSubListNodes(geometry, mesh, sIds[0])
tList = GetSubListNodes(geometry, mesh, tIds[0])
rev = False
r = load.Properties["Reverse"].Value
if r == "Yes": rev = True
sList = sorted(sList, key=sList.get)
tList = sorted(tList, key=tList.get, reverse=rev)
return (sList, tList)
def GetSubListNodes(geometry, mesh, refId):
entity = geometry.GeoEntityById(refId)
region = mesh.MeshRegionById(refId)
result = {}
pt = System.Array.CreateInstance(System.Double, 3)
for nodeId in region.NodeIds:
node = mesh.NodeById(nodeId)
pt[0], pt[1], pt[2] = (node.X, node.Y, node.Z)
result[nodeId] = entity.ParamAtPoint(pt)
return result
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
221
Examples
Description
PythonSampling
CSharpSampling
Description
PythonOptimizer
CSharpOptimizer
222
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
223
Examples
The file, EmptyGUI.xml, contains the following code:
<extension version="1" name="EmptyGUI">
<guid shortid="EmptyGUI">69d0095b-e138-4841-a13a-de12238c83f6</guid>
<script src="empty_gui.py" />
<interface context="Project">
<images>images</images>
</interface>
<workflow name="wf3" context="Project" version="1">
<tasks>
<task name="Empty" caption="Empty" icon="Generic_cell" version="1">
<callbacks>
<onupdate>update</onupdate>
</callbacks>
<inputs>
<input/>
</inputs>
<outputs/>
<contextmenus>
<entry name="Empty Gui Op" type="ContextMenuEntry" priority="1.0" icon="default_op"
version="1">
<callbacks>
<onclick>click</onclick>
</callbacks>
</entry>
</contextmenus>
</task>
</tasks>
<taskgroups>
<taskgroup name="Empty" caption="Empty" icon="Generic" category="ACT Custom Workflows"
abbreviation="MT" version="1">
<includeTask name="Empty" caption="Empty"/>
</taskgroup>
</taskgroups>
</workflow>
</extension>
IronPython Script
The IronPython script (empty_gui.py) contains the Python code the task executes from the context
menu and update callbacks.
Since the XML extension definition file has both the <onupdate> and <onclick> callbacks, the update
and click methods are defined in the script.
The file, empty_gui.py, contains the following code:
import clr
clr.AddReference("Ans.UI.Toolkit")
clr.AddReference("Ans.UI.Toolkit.Base")
import Ansys.UI.Toolkit
def click(container):
Ansys.UI.Toolkit.MessageBox.Show("Empty Test!")
def update(container, context):
print 'empty update'
224
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
225
Examples
Defines two parameters in the <parameters> block.
Defines a single taskgroup which contains a single task in the <taskgroups> block.
The file, Squares.xml, contains the following code:
<extension version="1" name="Squares">
<guid shortid="Squares">69d0095b-e138-4841-a13a-de12238c83f4</guid>
<script src="squares.py" />
<interface context="Project">
<images>images</images>
</interface>
<workflow name="wf1" context="Project" version="1">
<tasks>
<task name="Squares" caption="Squares" icon="squares_component" version="1">
<callbacks>
<onupdate>update</onupdate>
</callbacks>
<inputs>
<input/>
</inputs>
<outputs/>
<parameters>
<parameter name="Input" caption="Input" usage="Input" control="Double" version="1"/>
<parameter name="Output" caption="Output" usage="Output" control="Double" version="1"/>
</parameters>
</task>
</tasks>
<taskgroups>
<taskgroup name="Squares" caption="Squares" icon="squares" category="ACT Custom Workflows"
abbreviation="SQRS" version="1">
<includeTask name="Squares" caption="Squares"/>
</taskgroup>
</taskgroups>
</workflow>
</extension>
IronPython Script
The IronPython script (Squares.py) performs the following actions:
Obtains the parameters.
Prepares the inputs.
Writes the input file.
Runs the external solver.
Reads the output file.
Sets the parameters to the calculated solver values.
Since the XML extension definition file has <onupdate> callback, the update method is defined in
the script. All ACT workflow callbacks get a container (for the task) and a context.
The file, Squares.py, contains the following code:
import clr
clr.AddReference("Ans.Utilities")
clr.AddReference("Ans.Core")
import Ansys.Utilities
import Ansys.Core
#convenience method to look up parameters based on a predetermined ID
226
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
227
Examples
raise Exception("Error in update - no output value detected!")
else:
outputParam.Value = outValue
228
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
IronPython Script
The IronPython script (dataquares_complete.py) performs the following actions:
Calls GetActiveDirectory to obtain the task-specific project directory.
Calls GetCustomEntity to obtain the data entity.
Calls GetCustomEntityPropertyValue to obtain the input property value.
Executes external solver.
Sets outputVal based on the retrieved solver output file.
Calls SetCustomEntityPropertyValue to update the output property to the solved value.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
229
Examples
Updates progress information throughout the update process.
The file, datasquares_complete.py, contains the following code:
def update(container, context):
activeDir = container.GetActiveDirectory()
extensionDir = ExtAPI.ExtensionManager.CurrentExtension.InstallDir
exeName = "ExampleAddinExternalSolver.exe"
solverPath = System.IO.Path.Combine(extensionDir, exeName)
monitor = context.ProgressMonitor
monitor.BeginTask("Data Sqaures Solver", 3, None)
monitor.TaskDetails = "Preparing solver input..."
System.Threading.Thread.Sleep(2000)
monitor.UpdateTask(1, None)
#get param values
entity = ACT.GetCustomEntity(container)
inputValue = ACT.GetCustomEntityPropertyValue(entity, "Input")
#prep i/o file paths
inputFileName = "input.txt"
outputFileName = "output.txt"
dpInputFile = System.IO.Path.Combine(activeDir, inputFileName)
dpOutputFile = System.IO.Path.Combine(activeDir, outputFileName)
#write input file
f = open(dpInputFile, "w")
f.write('input='+inputValue.ToString(System.Globalization.NumberFormatInfo.InvariantInfo))
f.close()
monitor.UpdateTask(1, None)
monitor.TaskDetails = "Executing Solver..."
System.Threading.Thread.Sleep(2000)
#run exe
runInMono = Ansys.Utilities.ApplicationConfiguration.DefaultConfiguration.IsRuntimeMono
monoPath = "mono"
monoArgs = System.String.Format("{0} \"{1}\" \"{2}\"", solverPath, dpInputFile, dpOutputFile)
info = None
if runInMono:
info = System.Diagnostics.ProcessStartInfo(monoPath, monoArgs)
else:
info = System.Diagnostics.ProcessStartInfo(solverPath, System.String.Format("\"{0}\" \"{1}\"",
dpInputFile, dpOutputFile))
info.CreateNoWindow = True
info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized
p = System.Diagnostics.Process.Start(info)
p.WaitForExit()
monitor.UpdateTask(1, None)
monitor.TaskDetails = "Retrieving results from solver..."
System.Threading.Thread.Sleep(2000)
#read output file
outputValue = None
f = open(dpOutputFile, "r")
currLine = f.readline()
while currLine != "":
valuePair = currLine.split('=')
outputValue = System.Int32.Parse(valuePair[1], System.Globalization.NumberFormatInfo.InvariantInfo)
currLine = f.readline()
f.close()
monitor.UpdateTask(1, None)
#set output value
230
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
if outputValue == None:
raise Exception("Error in update - no output value detected!")
else:
ACT.SetCustomEntityPropertyValue(entity, "Output", outputValue)
monitor.TaskDetails = "Solve completed..."
System.Threading.Thread.Sleep(2000)
monitor.EndTask(None)
import clr
clr.AddReference("Ans.ProjectSchematic")
clr.AddReference("ReportUtility.Interop")
import Ansys.ReportUtility.Interop
import Ansys.ProjectSchematic
def status(container, context):
status = Ansys.ProjectSchematic.Queries.ComponentState(Ansys.ProjectSchematic.State.Unfulfilled,
"This is unfulfilled!")
return None
def report(container, context, report):
root = report.GetRootSection()
section = Ansys.ReportUtility.Interop.ReportSection("My Custom ACT Task Report Content")
text = Ansys.ReportUtility.Interop.ReportText("", "Sample text from the data squares component")
section.AddChild(text)
root.AddChild(section)
Material Transfer
This custom Workbench workflow example implements a material transfer taskgroup that passes MatMLformatted material data to a downstream Engineering Data taskgroup. This example also illustrates
input/output specification and file management capabilities.
Figure 79: Material Transfer Example Engineering Data View
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
231
Examples
Figure 80: Material Transfer Example Schematic View
232
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
IronPython Script
The IronPython script (generic_material_transfer.py ) contains the IronPython code that
provides instructions for passing the MatML-formatted material data to a downstream Engineering
Data taskgroup. This includes the update method (called by the <onupdate> callback in the XML
extension definition file), which accesses the SampleMaterials.xml file.
The file, generic_material_transfer.py, contains the following code:
def update(container, context):
extensionDir = ExtAPI.ExtensionManager.CurrentExtension.InstallDir
matFilePath = System.IO.Path.Combine(extensionDir, "Sample_Materials.xml")
matFileRef = None
isRegistered = IsFileRegistered(FilePath=matFilePath)
if isRegistered == True:
matFileRef = GetRegisteredFile(matFilePath)
else:
matFileRef = RegisterFile(FilePath=matFilePath)
AssociateFileWithContainer(matFileRef, container)
outputRefs = container.GetOutputData()
matOutputSet = outputRefs["MatML31"]
matOutput = matOutputSet[0]
matOutput.TransferFile = matFileRef
Material File
This file (Sample_Materials.xml), accessed by the IronPython update method, contains the
MatML-formatted material data:
<?xml version="1.0" encoding="UTF-8"?>
<EngineeringData version="16.1">
<Notes />
<Materials>
<MatML_Doc>
<Material>
<BulkDetails>
<Name>Sample Material</Name>
<Description>Sample material from Driver</Description>
<PropertyData property="pr0">
<Data format="string">-</Data>
<ParameterValue parameter="pa0" format="float">
<Data>494.1474492,912.7972764,1172.453938,1941.495468,2803.754154,3869.063522,5245.395513,
10378.82012,18192.58268,28438.67868,57755.1982,94951.87682,135751.6191,178064.7612,216504.4272,261538.9311,
304701.5076,333300.2826,364061.2544,397079.5705,432533.1159,457543.8578,483751.5301</Data>
<Qualifier name="Variable Type">Dependent,Dependent,Dependent,Dependent,Dependent,
Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,
Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent</Qualifier>
</ParameterValue>
<ParameterValue parameter="pa1" format="float">
<Data>0.1338,0.2675,0.3567,0.6242,0.8917,1.1592,1.4268,2.051,2.586,3.0318,3.7898,4.3694,4.8153,
5.172,5.4395,5.707,5.9299,6.0637,6.1975,6.3312,6.465,6.5541,6.6433</Data>
<Qualifier name="Variable Type">Independent,Independent,Independent,Independent,
Independent,Independent,Independent,Independent,Independent,Independent,Independent,Independent,
Independent,Independent,Independent,Independent,Independent,Independent,Independent,Independent,
Independent,Independent,Independent</Qualifier>
</ParameterValue>
</PropertyData>
<PropertyData property="prDriver">
<Data format="string">-</Data>
<Qualifier name="Data Link Version">1</Qualifier>
<Qualifier name="Model Type">Linear;Isotropic</Qualifier>
<Qualifier name="Sample Property">Value</Qualifier>
</PropertyData>
</BulkDetails>
</Material>
<Metadata>
<ParameterDetails id="pa0">
<Name>Stress</Name>
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
233
Examples
<Units>
<Unit>
<Name>Pa</Name>
</Unit>
</Units>
</ParameterDetails>
<ParameterDetails id="pa1">
<Name>Strain</Name>
<Units>
<Unit>
<Name>m</Name>
</Unit>
<Unit power="-1">
<Name>m</Name>
</Unit>
</Units>
</ParameterDetails>
<PropertyDetails id="pr0">
<Unitless />
<Name>Sample Property</Name>
</PropertyDetails>
<PropertyDetails id="prDriver">
<Unitless />
<Name>Driver Link Details</Name>
</PropertyDetails>
</Metadata>
</MatML_Doc>
</Materials>
<Loads />
<BeamSections />
</EngineeringData>
Mesh Transfer
This custom Workbench workflow example implements a mesh transfer taskgroup.
This taskgroup has both "consuming" and "providing" connections with existing ANSYS applications,
consuming a mesh from an upstream Mesh taskgroup and passing it to a downstream Fluent taskgroup.
It also illustrates input/output specification, file management capabilities, and the default Edit context
menu.
234
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
235
Examples
<extension version="1" name="GenericMeshTransfer">
<guid shortid="GenericMeshTransfer">69d0095b-e138-4841-a13a-de12238c83f7</guid>
<script src="generic_mesh_transfer.py" />
<interface context="Project">
<images>images</images>
</interface>
<workflow name="wf6" context="Project" version="1">
<tasks>
<task name="Mesher" caption="Mesher" icon="GenericMesh_cell" version="1">
<callbacks>
<onupdate>update</onupdate>
<onedit>edit</onedit>
</callbacks>
<inputs>
<input format="FluentMesh" type="MeshingMesh" count="1"/>
<input/>
</inputs>
<outputs>
<output format="FluentMesh" type="SimulationGeneratedMesh"/>
</outputs>
</task>
</tasks>
<taskgroups>
<taskgroup name="GenericMeshTransfer" caption="Generic Mesh" icon="GenericMesh"
category="ACT Custom Workflows" abbreviation="GenMeshXfer" version="1">
<includeTask name="Mesher" caption="Mesher"/>
</taskgroup>
</taskgroups>
</workflow>
</extension>
IronPython Script
The IronPython script (generic_mesh_transfer.py ) contains the IronPython code that provides
instructions for passing the mesh data to the downstream Fluent taskgroup .
The file, generic_mesh_transfer.py, contains the following code:
import clr
clr.AddReference("Ans.UI.Toolkit")
clr.AddReference("Ans.UI.Toolkit.Base")
import Ansys.UI.Toolkit
def update(container, context):
print 'in system.py update method'
#obtain input data
upstreamData = container.GetInputDataByType(InputType="MeshingMesh")
meshFileRef = None
upstreamDataCount = upstreamData.Count
if upstreamDataCount > 0:
meshFileRef = upstreamData[0]
#set our output so that we are just a pass through.
outputRefs = container.GetOutputData()
meshOutputSet = outputRefs["SimulationGeneratedMesh"]
meshOutput = meshOutputSet[0]
#meshOutput.MeshFile = meshFileRef
meshOutput.TransferFile = meshFileRef
#if no new data...nothing to process from upstream sources.
def edit(container, context):
Ansys.UI.Toolkit.MessageBox.Show("Test!")
Custom Transfer
This custom Workbench workflow example implements a custom transfer from a producing taskgroup
to a consuming taskgroup, creating connections between custom tasks (no ANSYS installed products).
It also illustrates the creation of single-task vs. multi-task task groups.
236
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
The XML extension definition file (CustomTransfer.xml) performs the following actions:
References the IronPython script customtransfer.py.
Defines two tasks in the <tasks> block: Producer and Consumer.
Defines three taskgroups in the <taskgroups> block: Producer, Consumer, and CompleteTransfer.
The Producer and Consumer taskgroups each contain a single task. The CompleteTransfer taskgroup
contains two tasks.
The file, CustomTransfer.xml, contains the following code:
<extension version="1" name="CustomTransfer">
<guid shortid="CustomTransfer">69d0095b-e138-4841-a13a-de12238c83f3</guid>
<script src="customtransfer.py" />
<interface context="Project">
<images>images</images>
</interface>
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
237
Examples
<workflow name="wf4" context="Project" version="1">
<tasks>
<task name="Producer" caption="Producer" icon="test_component" version="1">
<callbacks>
<onupdate>producer_update</onupdate>
</callbacks>
<inputs>
<input/>
</inputs>
<outputs>
<output format="" type="MyData"/>
</outputs>
</task>
<task name="Consumer" caption="consumer" icon="test_component" version="1">
<callbacks>
<onupdate>consumer_update</onupdate>
</callbacks>
<inputs>
<input/>
<input format="" type="MyData"/>
</inputs>
<outputs/>
</task>
</tasks>
<taskgroups>
<taskgroup name="Producer" caption="Producer" icon="producer_system"
category="ACT Custom Workflows" abbreviation="Producer" version="1">
<includeTask name="Producer" caption="Producer"/>
</taskgroup>
<taskgroup name="Consumer" caption="Consumer" icon="consumer_system"
category="ACT Custom Workflows" abbreviation="Consumer" version="1">
<includeTask name="Consumer" caption="Consumer"/>
</taskgroup>
<taskgroup name="CompleteTransfer" caption="CompleteTransfer" icon="consumer_system"
category="ACT Custom Workflows" abbreviation="CompleteTransfer" version="1">
<includeTask name="Producer" caption="Producer"/>
<includeTask name="Consumer" caption="Consumer"/>
</taskgroup>
</taskgroups>
</workflow>
</extension>
IronPython Script
The IronPython script (customtransfer.py) contains the Python code that provides update instructions for the producing taskgroup and for the consuming task to obtain the output data from the upstream producer.
The file, customtransfer.py, contains the following code:
def consumer_update(container, context):
#obtain input data
upstreamData = container.GetInputDataByType(InputType="MyData")
fileRef = None
upstreamDataCount = upstreamData.Count
if upstreamDataCount > 0:
fileRef = upstreamData[0]
AssociateFileWithContainer(fileRef, container)
#if no new data...nothing to process from upstream sources.
def producer_update(container, context):
filePath = r"C:\Program Files\ANSYS Inc\v162\Addins\AdvancedAddinPackage\extensions\
CustomTransfer\Sample_Materials.xml"
fileRef = None
isRegistered = IsFileRegistered(FilePath=filePath)
if isRegistered == True:
fileRef = GetRegisteredFile(filePath)
else:
fileRef = RegisterFile(FilePath=filePath)
AssociateFileWithContainer(fileRef, container)
238
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Parametric
The following custom Workbench workflow example illustrates the creation of a parametric taskgroup
using the isparametricgroup attribute. When this attribute is set to true , it indicates that that
the taskgroup operates only on design points. As such, the taskgroup is added below the Parameter
Set bar. The focus on parameters in this example enables you to incorporate DesignXplorer-like functionality.
Figure 84: Parametric Example Schematic View
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
239
Examples
</tasks>
<taskgroups>
<taskgroup name="Parametric" caption="Parametric" icon="parametric"
category="ACT Custom Workflows" abbreviation="PARAMS" isparametricgroup="True" version="1">
<includeTask name="Parametric" caption="Parametric"/>
</taskgroup>
</taskgroups>
</workflow>
IronPython Script
The IronPython script (parametric.py) performs an update on the parameters. Since the XML extension definition file has <onupdate> callback, the update method is defined in the script.
The file, parametric.py, contains the following code:
def update(container, context):
print 'test'
Wizard Examples:
For our different wizard examples, we'll use the same extension, WizardDemos. The following four
wizards are defined in this extension:
ProjectWizard: Project wizard
CreateBridge: Target app wizard (DesignModeler)
SimpleAnalysis: Target app wizard (Mechanical)
BridgeSimulation: Mixed wizard
For the wizard examples, we'll review excerpts from the XML extension file and the IronPython scripts.
240
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
241
Examples
For the Charts step, the <onrefresh> callback executes the RefreshCharts action.
The <propertygroup> blocks define properties and property attributes for the steps. For properties
requiring validation, the <onvalidate> callback executes an appropriate Python validation function.
<extension version="2" minorversion="1" name="WizardDemos">
<guid>6D33EFFC-C521-4859-8273-BA320044B6B8</guid>
<author>ANSYS Inc.</author>
<description>Simple extension to test wizards in different contexts.</description>
<script src="main.py" />
<script src="ds.py" />
<script src="dm.py" />
<interface context="Project|Mechanical">
<images>images</images>
</interface>
...
<wizard name="ProjectWizard" version="1" context="Project" icon="wizard_icon">
<description>Simple wizard for demonstration in Project page.</description>
<step name="Geometry" caption="Geometry" version="1" HelpFile="help/geometry.html">
<description>Create a geometry component.</description>
<callbacks>
<onupdate>CreateGeometry</onupdate>
<onreset>DeleteGeometry</onreset>
</callbacks>
<propertygroup display="caption" name="definition" caption="Basic properties" >
<property name="filename" caption="Geometry file name" control="fileopen" />
<property name="myint" caption="Integer value" control="integer" />
<property name="mytext" caption="Text value" control="text" />
<property name="myquantity" caption="Quantity value" control="float" unit="Pressure" />
<property name="myreadonly" caption="Readonly value" control="text" readonly="true"
default="My value" />
<propertygroup display="property" name="myselect" caption="List of choice" control="select"
default="Option1">
<attributes options="Option1,Option2" />
<property name="option1" caption="Option1 value" control="text" visibleon="Option1" />
<property name="option2first" caption="Option2 first value" control="float" unit="Pressure"
visibleon="Option2" />
<property name="option2seond" caption="Option2 second value" control="float" unit="Length"
visibleon="Option2" />
</propertygroup>
</propertygroup>
</step>
<step name="Mechanical" caption="Mechanical" enabled="true" version="1" HelpFile="help/mechanical.html">
<description>Create a mechanical component.</description>
<callbacks>
<onupdate>CreateMechanical</onupdate>
<onreset>DeleteMechanical</onreset>
</callbacks>
<property name="name" caption="System name" control="text" />
<propertytable name="table" caption="TabularData" display="worksheet" control="applycancel"
class="Worksheet.PropertyGroupEditor.PGEditor">
<property name="Temperature" caption="Temperature" unit="Temperature" control="float"></property>
<property name="Pressure" caption="Pressure" unit="Pressure" control="float"></property>
</propertytable>
</step>
<step name="Fluent" caption="Fluent" version="1" HelpFile="help/fluent.html">
<description>Create a fluent component.</description>
242
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
IronPython Script
Below is the IronPython script, main.py.
This script defines all the functions executed by the callbacks in our XML extension file. Each step defined
in the XML file may include multiple actions.
geoSystem = None
dsSystem = None
fluentSystem = None
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
243
Examples
def CreateGeometry(step):
global geoSystem
template1 = GetTemplate(TemplateName="Geometry")
geoSystem = template1.CreateSystem()
geometry1 = geoSystem.GetContainer(ComponentName="Geometry")
geometry1.SetFile(FilePath=step.Properties["definition/filename"].Value)
def DeleteGeometry(step):
global geoSystem
geoSystem.Delete()
def RefreshMechanical(step):
tree = step.UserInterface.GetPanel("Tree")
root = tree.CreateTreeNode("Root")
node1 = tree.CreateTreeNode("Node1")
node2 = tree.CreateTreeNode("Node2")
node3 = tree.CreateTreeNode("Node3")
root.Values.Add(node1)
root.Values.Add(node2)
node2.Values.Add(node1)
node2.Values.Add(node3)
root.Values.Add(node3)
tree.SetTreeRoot(root)
chart = step.UserInterface.GetPanel("Chart")
chart.Plot([1,2,3,4,5],[10,4,12,13,8],"b","Line1")
chart.Plot([1,2,3,4,5],[5,12,7,8,11],"r","Line2")
def CreateMechanical(step):
global dsSystem, geoSystem
template2 = GetTemplate(
TemplateName="Static Structural",
Solver="ANSYS")
geometryComponent1 = geoSystem.GetComponent(Name="Geometry")
dsSystem = template2.CreateSystem(
ComponentsToShare=[geometryComponent1],
Position="Right",
RelativeTo=geoSystem)
if step.Properties["name"].Value=="error":
raise UserErrorMessageException("Invalid system name. Please try again.")
dsSystem.DisplayText = step.Properties["name"].Value
def DeleteMechanical(step):
global dsSystem
dsSystem.Delete()
def CreateFluent(step):
global dsSystem, fluentSystem
template3 = GetTemplate(TemplateName="Fluid Flow")
geometryComponent2 = dsSystem.GetComponent(Name="Geometry")
solutionComponent1 = dsSystem.GetComponent(Name="Solution")
componentTemplate1 = GetComponentTemplate(Name="CFDPostTemplate")
fluentSystem = template3.CreateSystem(
ComponentsToShare=[geometryComponent2],
DataTransferFrom=[Set(FromComponent=solutionComponent1, TransferName=None,
ToComponentTemplate=componentTemplate1)],
Position="Right",
RelativeTo=dsSystem)
if step.Properties["name"].Value=="error":
raise Exception("Invalid system name. Please try again.")
fluentSystem.DisplayText = step.Properties["name"].Value
def CreateDialog(step):
dlg = step.UserInterface.Container.CreateDialog("MyDialog", "okCancelDialog", "MyTitle", 400, 150)
dlg.SetOkButton("Ok")
prop = step.Properties["nextstep"]
prop.Options.Clear()
s = step.NextStep
val = s.Caption
while s!=None:
prop.Options.Add(s.Caption)
s = s.NextStep
244
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
245
Examples
xValues.append(i)
yValues.append(abs(math.sin(i*0.2))*i/100.0)
graphB.Plot(xValues, yValues, key="y = a*sin(bx)", color="c")
graphB.Plot(xValues, yValues, key="y = x", color="m")
xValues = []
yValues = []
for i in range(0, 100):
xValues.append(i)
yValues.append(i/100.0)
graphB.Plot(xValues, yValues, key="y = x", color="m")
graphB.Plot([0, 10, 20, 30, 100], [0.2, 0.2, 0.2, 0.3, 0.3], key="Smth", color="r")
graphB.Plot([0, 10, 20, 30, 100], [0.2, 0.1, 0.3, 0.5, 0.7], key="Smth", color="r")
graphB.Plot([0, 10, 20, 30, 100], [0.2, 0.2, 0.2, 0.3, 0.3])
graphC = step.UserInterface.GetPanel("GraphC")
graphC.Title("Pie Graph")
graphC.Pie([1, 2, 3])
graphC.Pie([20, 30, 5, 15, 12], [0, "Banana", 2, 3, "42"])
graphD = step.UserInterface.GetPanel("GraphD")
graphD.Title("Bar Graph")
graphD.Bar(["Banana"], [70], key="key")
graphD.Bar([0, "Banana", 2, 3, 4], [20, 30, 5, 15, 12], key="key")
graphE = step.UserInterface.GetPanel("GraphE")
graphE.Title("Bubble Graph")
graphE.XTickFormat("f")
graphE.YTickFormat("f")
keys = ["one", "two", "three", "four", "five"]
colors = ["#BB3333", "#33BB33", "#3333BB", "#BBBB33", "#BB33BB"]
for c in range(0, 5):
xValues = []
yValues = []
sizeValues = []
for i in range(0, (c+1)*20):
rad = random.randrange(c+1, c+2) + (random.random()*2-1)
angle = random.random() * 2 * math.pi
xValues.append(math.cos(angle) * rad)
yValues.append(math.sin(angle) * rad)
sizeValues.append(random.random() * 2.0 + 0.5)
graphE.Bubble(xValues, yValues, sizeValues, key=keys[c], color=colors[c])
246
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
247
Examples
</entry>
<entry name="Support" icon="Support">
<callbacks>
<onclick>CreateSupport</onclick>
</callbacks>
</entry>
</toolbar>
</interface>
<simdata context="DesignModeler">
<geometry name="Deck" caption="Deck" icon="deck" version="1">
<callbacks>
<ongenerate>GenerateDeck</ongenerate>
</callbacks>
<property name="Length" caption="Length" control="float" unit="Length" default="300 [m]" />
<property name="Width" caption="Width" control="float" unit="Length" default="20 [m]" />
<property name="Beams" caption="Beams" control="integer" default="31" />
</geometry>
</simdata>
<simdata context="DesignModeler">
<geometry name="Support" caption="Support" icon="support" version="1">
<callbacks>
<ongenerate>GenerateSupport</ongenerate>
</callbacks>
<property name="Length" caption="Length" control="float" unit="Length" default="300 [m]" />
<property name="Height" caption="Height" control="float" unit="Length" default="100 [m]" />
<property name="Width" caption="Width" control="float" unit="Length" default="20 [m]" />
<property name="Number" caption="Number" control="integer" default="3" />
</geometry>
</simdata>
...
<wizard name="CreateBridge" version="1" context="DesignModeler" icon="wizard_icon">
<description>Simple wizard for demonstration in DesignModeler.</description>
<step name="Deck" caption="Deck" version="1" HelpFile="help/dm1.html">
<description>Create the deck.</description>
<callbacks>
<onupdate>UpdateDeck</onupdate>
</callbacks>
<propertygroup display="caption" name="Deck" caption="Deck Definition" >
<property name="Length" caption="Length" control="float" unit="Length" default="300 [m]" />
<property name="Width" caption="Width" control="float" unit="Length" default="20 [m]" />
<property name="Beams" caption="Beams" control="integer" default="31" />
</propertygroup>
</step>
<step name="Supports" caption="Supports" enabled="true" version="1" HelpFile="help/dm2.html">
<description>Create supports.</description>
<callbacks>
<onupdate>UpdateSupports</onupdate>
</callbacks>
<propertygroup display="caption" name="Supports" caption="Supports Definition" >
<property name="Height" caption="Height" control="float" unit="Length" default="100 [m]" />
<property name="Number" caption="Number" control="integer" default="3" />
</propertygroup>
</step>
</wizard>
248
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
IronPython Script
Below is the IronPython script, dm.py.
This script defines all the functions executed by the callbacks in our XML extension file. Each step defined
in the XML file may include multiple actions.
import units
def CreateDeck(ag):
ExtAPI.CreateFeature("Deck")
def CreateSupport(ag):
ExtAPI.CreateFeature("Support")
def GenerateDeck(feature,fct):
length = feature.Properties["Length"].Value
length = units.ConvertUnit(length, ExtAPI.DataModel.CurrentUnitFromQuantityName("Length"), "m")
width = feature.Properties["Width"].Value
width = units.ConvertUnit(width, ExtAPI.DataModel.CurrentUnitFromQuantityName("Length"), "m")
num = feature.Properties["Beams"].Value
builder = ExtAPI.DataModel.GeometryBuilder
bodies = []
boxGen = builder.Primitives.Solid.CreateBox([0.,-width/2.,-0.3],[length,width/2.,0.])
bodies.Add(boxGen.Generate())
w = (length-0.1*num)/(num-1.)+0.1
for i in range(num-1):
beamGen = builder.Primitives.Solid.CreateBox([i*w,-width/2.,-0.6],[i*w+0.1,width/2.,-0.3])
bodies.Add(beamGen.Generate())
beamGen = builder.Primitives.Solid.CreateBox([length-0.1,-width/2.,-0.6],[length,width/2.,-0.3])
bodies.Add(beamGen.Generate())
beamGen = builder.Primitives.Solid.CreateBox([0.,-width/2.,-1.],[length,-width/2.+0.2,-0.6])
bodies.Add(beamGen.Generate())
beamGen = builder.Primitives.Solid.CreateBox([0.,width/2.-0.2,-1.],[length,width/2.,-0.6])
bodies.Add(beamGen.Generate())
feature.Bodies = bodies
feature.MaterialType = MaterialTypeEnum.Add
return True
def GenerateSupport(feature,fct):
length = feature.Properties["Length"].Value
length = units.ConvertUnit(length, ExtAPI.DataModel.CurrentUnitFromQuantityName("Length"), "m")
height = feature.Properties["Height"].Value
height = units.ConvertUnit(height, ExtAPI.DataModel.CurrentUnitFromQuantityName("Length"), "m")
width = feature.Properties["Width"].Value
width = units.ConvertUnit(width, ExtAPI.DataModel.CurrentUnitFromQuantityName("Length"), "m")
num = feature.Properties["Number"].Value
builder = ExtAPI.DataModel.GeometryBuilder
bodies = []
w = (length-2.*num)/(num+1.)+2.
for i in range(num):
beamGen = builder.Primitives.Solid.CreateBox([(i+1)*w,-width/2.,-1.-height],
[(i+1)*w+2.,width/2.,-1.])
bodies.Add(beamGen.Generate())
beamGen = builder.Primitives.Solid.CreateBox([0.,-width/2.,-5.],[2.,width/2.,-1.])
bodies.Add(beamGen.Generate())
beamGen = builder.Primitives.Solid.CreateBox([length-2.,-width/2.,-5.],[length,width/2.,-1.])
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
249
Examples
bodies.Add(beamGen.Generate())
feature.Bodies = bodies
feature.MaterialType = MaterialTypeEnum.Freeze
return True
def UpdateDeck(step):
deck = ExtAPI.CreateFeature("Deck")
deck.Properties["Length"].Value = step.Properties["Deck/Length"].Value
deck.Properties["Width"].Value = step.Properties["Deck/Width"].Value
deck.Properties["Beams"].Value = step.Properties["Deck/Beams"].Value
ExtAPI.DataModel.FeatureManager.Generate()
def UpdateSupports(step):
supports = ExtAPI.CreateFeature("Support")
supports.Properties["Length"].Value = step.PreviousStep.Properties["Deck/Length"].Value
supports.Properties["Width"].Value = step.PreviousStep.Properties["Deck/Width"].Value+6
supports.Properties["Height"].Value = step.Properties["Supports/Height"].Value
supports.Properties["Number"].Value = step.Properties["Supports/Number"].Value
ExtAPI.DataModel.FeatureManager.Generate()
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
251
Examples
</property>
<property name="Ndiv" caption="Divisions" control="integer" />
</propertygroup>
</step>
<step name="Solution" caption="Solution" version="1" HelpFile="help/ds2.html">
<description>Setup loads.</description>
<callbacks>
<onrefresh>RefreshLoads</onrefresh>
<onreset>RemoveLoads</onreset>
<onupdate>CreateLoads</onupdate>
</callbacks>
<propertygroup display="caption" name="Mesh" caption="Mesh Statistics" >
<property name="Nodes" caption="Nodes" control="text" readonly="true" />
<property name="Elements" caption="Elements" control="text" readonly="true" />
</propertygroup>
<propertygroup display="caption" name="FixedSupport" caption="Fixed Support" >
<property name="Location" caption="Face Location" control="geometry_selection">
<attributes selection_filter="face" />
<callbacks>
<isvalid>IsLocationFSValid</isvalid>
</callbacks>
</property>
</propertygroup>
</step>
<step name="Results" caption="Results" version="1" HelpFile="help/ds3.html">
<description>View Results.</description>
<callbacks>
<onrefresh>RefreshResults</onrefresh>
</callbacks>
<property name="Res" caption="Deformation" control="text" readonly="true" />
</step>
</wizard>
IronPython Script
Below is the IronPython script, ds.py.
This script defines all the functions executed by the callbacks in our XML extension file. Each step defined
in the XML file may include multiple actions.
def IsLocationValid(step, prop):
if prop.Value==None:
return False
if prop.Value.Ids.Count!=1:
prop.StateMessage = "Select only one edge."
return False
return True
def CreateMeshControls(step):
model = ExtAPI.DataModel.Project.Model
mesh = model.Mesh
sizing = mesh.AddSizing()
sel = step.Properties["Sizing/Location"].Value
entity = ExtAPI.DataModel.GeoData.GeoEntityById(sel.Ids[0])
len = entity.Length
ids = []
for part in ExtAPI.DataModel.GeoData.Assemblies[0].Parts:
for body in part.Bodies:
for edge in body.Edges:
if abs(edge.Length-len)/len<1.e-6:
252
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
253
Examples
Mixed Wizard
Our mixed wizard example is called BridgeSimulation. It is defined in the extension WizardDemos.
It executes one step on the Project tab, reuses the bridge builder in our CreateBridge DesignModeler
wizard, reruns the bridge analysis in our SimpleAnalysis Mechanical wizard, and then returns to the
Project tab to execute a Results step.
254
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
255
Examples
<property name="Length" caption="Length" control="float" unit="Length" default="300 [m]" />
<property name="Height" caption="Height" control="float" unit="Length" default="100 [m]" />
<property name="Width" caption="Width" control="float" unit="Length" default="20 [m]" />
property name="Number" caption="Number" control="integer" default="3" />
</geometry>
</simdata>
<wizard name="ProjectWizard" version="1" context="Project" icon="wizard_icon">
<description>Simple wizard for demonstration in Project page.</description>
<step name="Geometry" caption="Geometry" version="1" HelpFile="help/geometry.html">
<description>Create a geometry component.</description>
<callbacks>
<onupdate>CreateGeometry</onupdate>
<onreset>DeleteGeometry</onreset>
</callbacks>
<propertygroup display="caption" name="definition" caption="Basic properties" >
<property name="filename" caption="Geometry file name" control="fileopen" />
<property name="myint" caption="Integer value" control="integer" />
<property name="mytext" caption="Text value" control="text" />
<property name="myquantity" caption="Quantity value" control="float" unit="Pressure" />
<property name="myreadonly" caption="Readonly value" control="text" readonly="true"
default="My value" />
<propertygroup display="property" name="myselect" caption="List of choice" control="select"
default="Option1">
<attributes options="Option1,Option2" />
<property name="option1" caption="Option1 value" control="text" visibleon="Option1" />
<property name="option2first" caption="Option2 first value" control="float" unit="Pressure"
visibleon="Option2" />
<property name="option2seond" caption="Option2 second value" control="float" unit="Length"
visibleon="Option2" />
</propertygroup>
</propertygroup>
</step>
<step name="Mechanical" caption="Mechanical" enabled="true" version="1" HelpFile="help/mechanical.html">
<description>Create a mechanical component.</description>
<callbacks>
<onupdate>CreateMechanical</onupdate>
<onreset>DeleteMechanical</onreset>
</callbacks>
<property name="name" caption="System name" control="text" />
<propertytable name="table" caption="TabularData" display="worksheet" control="applycancel"
class="Worksheet.PropertyGroupEditor.PGEditor">
<property name="Temperature" caption="Temperature" unit="Temperature" control="float"></property>
<property name="Pressure" caption="Pressure" unit="Pressure" control="float"></property>
</propertytable>
</step>
<step name="Fluent" caption="Fluent" version="1" HelpFile="help/fluent.html">
<description>Create a fluent component.</description>
<callbacks>
<onrefresh>CreateDialog</onrefresh>
<onupdate>CreateFluent</onupdate>
<onreset>EmptyReset</onreset>
</callbacks>
256
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
257
Examples
<property name="Height" caption="Height" control="float" unit="Length" default="100 [m]" />
<property name="Number" caption="Number" control="integer" default="3" />
</propertygroup>
</step>
</wizard>
<wizard name="SimpleAnalysis" version="1" context="Mechanical" icon="wizard_icon">
<description>Simple wizard to illustrate how to setup, solve and analyse results of
a simulation process.</description>
<step name="Mesh" caption="Mesh" version="1" HelpFile="help/ds1.html">
<description>Setup some mesh controls.</description>
<callbacks>
<onreset>RemoveControls</onreset>
<onupdate>CreateMeshControls</onupdate>
</callbacks>
<propertygroup display="caption" name="Sizing" caption="Mesh Sizing" >
<property name="Location" caption="Edge Location" control="geometry_selection">
<attributes selection_filter="edge" />
<callbacks>
<isvalid>IsLocationValid</isvalid>
</callbacks>
</property>
<property name="Ndiv" caption="Divisions" control="integer" />
</propertygroup>
</step>
<step name="Solution" caption="Solution" version="1" HelpFile="help/ds2.html">
<description>Setup loads.</description>
<callbacks>
<onrefresh>RefreshLoads</onrefresh>
<onreset>RemoveLoads</onreset>
<onupdate>CreateLoads</onupdate>
</callbacks>
<propertygroup display="caption" name="Mesh" caption="Mesh Statistics" >
<property name="Nodes" caption="Nodes" control="text" readonly="true" />
<property name="Elements" caption="Elements" control="text" readonly="true" />
</propertygroup>
<propertygroup display="caption" name="FixedSupport" caption="Fixed Support" >
<property name="Location" caption="Face Location" control="geometry_selection">
<attributes selection_filter="face" />
<callbacks>
<isvalid>IsLocationFSValid</isvalid>
</callbacks>
</property>
</propertygroup>
</step>
<step name="Results" caption="Results" version="1" HelpFile="help/ds3.html">
<description>View Results.</description>
<callbacks>
<onrefresh>RefreshResults</onrefresh>
</callbacks>
<property name="Res" caption="Deformation" control="text" readonly="true" />
</step>
</wizard>
<wizard name="BridgeSimulation" version="1" context="Project" icon="bridge">
<description>Simple wizard for mixed wizard demonstration.</description>
258
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
259
Examples
<property name="Nodes" caption="Nodes" control="text" readonly="true" />
<property name="Elements" caption="Elements" control="text" readonly="true" />
</propertygroup>
<propertygroup display="caption" name="FixedSupport" caption="Fixed Support" >
<property name="Location" caption="Face Location" control="geometry_selection">
<attributes selection_filter="face" />
<callbacks>
<isvalid>IsLocationFSValid</isvalid>
</callbacks>
</property>
</propertygroup>
</step>
<step name="Results" caption="Results" version="1" context="Project" HelpFile="help/prj2.html">
<description>View Results.</description>
<callbacks>
<onrefresh>RefreshResultsProject</onrefresh>
</callbacks>
<property name="Res" caption="Deformation" control="text" readonly="true" />
</step>
</wizard>
</extension>
IronPython Script
Because this is a mixed wizard incorporating steps on the Project tab with steps from our existing
DesignModeler and Mechanical wizards, the XML file references the three script files shown in previous
sections:
main.py
dm.py
ds.py
260
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
261
Examples
</extension>
IronPython Script
Below is the IronPython script, main.py.
This script defines the functions called by the callbacks in the custom template's XML extension definition
file.
The action function is the single step in our custom template. When called by the <onupdate> callback
(invoked by the Create Simulation button), it creates the Study workflow by creating and updating the
Geometry, Mesh, and Physics tasks.
The reset function, when called by the <onreset> callback, resets the UI and allows the user to modify
properties defined for the custom template. This occurs when encountering an error during the execution
of the <onupdate> callback.
The isvalid function, when called by the <isvalid> callback in the <properties> block, validates
that the property value entered is not less than 1. A custom message can be displayed when the entered
value fails validation.
tasksToDelete = []
groupsToDelete = []
def action(step):
global tasksToDelete,groupsToDelete
tasksToDelete = []
groupsToDelete = []
system1 = GetSystem(Name="Study")
importComponent1 = Study.CreateTask(
Type="Import",
System=system1)
tasksToDelete.Add(importComponent1)
study1 = system1.GetContainer(ComponentName="Study")
import1 = importComponent1.GetTaskObject()
geometryImportSource1 = study1.CreateEntity(
Type="GeometryImportSource",
Association=import1)
geometryImportSource1.FilePath = step.Properties["Geometry"].Value
geometryImportSource1.GenerateImportSourceOperation()
step.UpdateProgressInformation(10.)
pct = 10.
for i in range(step.Properties["NAnalysis"].Value):
meshingComponent1 = Study.CreateTask(
Type="Meshing",
System=system1,
Input=importComponent1)
tasksToDelete.Add(meshingComponent1)
meshingComponent1.Refresh()
physicsSolutionGroup1 = Study.CreateGroup(Name="Physics Solution")
groupsToDelete.Add(physicsSolutionGroup1)
physicsDefinitionComponent1 = Study.CreateTask(
Type="Physics Definition",
System=system1)
tasksToDelete.Add(physicsDefinitionComponent1)
solvePhysicsComponent1 = Study.CreateTask(
Type="Solve Physics",
System=system1)
tasksToDelete.Add(solvePhysicsComponent1)
physicsSolutionGroup1.Add(Component=physicsDefinitionComponent1)
physicsSolutionGroup1.Add(Component=solvePhysicsComponent1)
AddSourceToComponentInSystem(
SourceComponent=physicsDefinitionComponent1,
262
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
263
264
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Task
Input
Output
AUTODYN_Remap
AutodynSetup
Autodyn
Setup
MechanicalSetup
SimulationGeneratedMesh
Analysis
None
None
Input
Output
None
TurboGeometry
Table 2: BladeGen
Taskgroup
Task
BladeGen
Blade Design
VistaGeometry
BladeGen (Beta)
Blade Design
None
TurboGeometry
VistaGeometry
Table 3: CFX
Taskgroup
Task
Input
Output
SimulationGeneratedMesh
CFXSetup
CFXMesh
SystemCouplingSetupData
CFX (Beta)
Setup
MechanicalSetup
Solution
CFXSetup
CFXSolution
CFXSolution
CFX
Setup
SimulationGeneratedMesh
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
CFXSetup
265
Task
Input
Output
CFXMesh
SystemCouplingSetupData
MechanicalSetup
Solution
CFXSetup
CFXSolution
CFXSolution
Results
CFXSolution
CFDAnalysis
FluentSolution
VistaTFSolution
IcePakResults
PolyflowSolutionType
MechanicalSolution
ICEData
Table 4: Design Assessment
Taskgroup
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Design
Assessment
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
266
SimulationSetup
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
MechanicalMesh
MechanicalSetup
SimulationSolutionDataInternal
MechanicalSolution
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
MechanicalResults
SimulationResults
Task
Input
Output
DesignPointsDataTransfer
OptimizationModel
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Direct
Optimization
Optimization
Table 6: Electric
Taskgroup
Task
Electric
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
267
Task
Input
Output
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSolutionDataInternal
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
MechanicalResults
SimulationResults
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Engineering
Data
Engineering
Data
Task
Explicit
Dynamics
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh MechanicalMesh
CompositeEngineeringData
268
SimulationGeneratedMesh
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSolutionDataInternal
EnhancedMechanicalModel
EnhancedModelData
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
MechanicalResults
SimulationResults
Explicit
Dynamics
(LS-DYNA
Export)
Engineering
Data
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
269
Task
Input
Output
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
Input
Output
None
ExternalDataSetup
Input
Output
None
ExternalModelOutputProvider
Input
Output
None
ExternalConnectionProperties
Input
Output
MechanicalSetup
FEMMesh
SimulationGeneratedMesh
FEMSetup
MAPDLCdb
Geometry
Task
External Data
Setup
Task
External Model
Setup
Task
External
Connection
External
Connection
Task
Finite Element
Modeler
Model
FEMSetup
SolidSectionData
CompositeEngineeringData
270
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
SimulationEngineeringData
Table 13: Fluent
Taskgroup
Task
Input
Output
FluentImportable
FluentSetup
AnsoftHeatLossDataObject
SystemCouplingSetupData
Fluent
Setup
FluentMesh
FluentCase
SimulationGeneratedMesh
ICEData
ICESetupData
FluentTGridMesh
Solution
FluentSetup
FluentSolution
FluentSolution
Table 14: Fluid Flow Blow Molding (Polyflow)
Taskgroup
Task
Input
Output
FEMSetup
Geometry
Fluid Flow
Blow
Molding
(Polyflow)
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Mesh
Geometry
MechanicalModel
MeshingGeneratedMeshOutput
Provider
MeshingMesh
SimulationGeneratedMesh
MeshingGeneratedMeshOutputProvider
Setup
SimulationGeneratedMesh
PolyflowSetup
PolyflowTransferMesh
Solution
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
271
Task
Input
Output
PolyflowSetup
PolyflowSolutionType
PolyflowSolution
PolyflowSolution
ExternalDataSetup
Results
CFXSolution
CFD Analysis
FluentSolution
VistaTFSolution
IcePakResults
PolyflowSolutionType
MechanicalSolution
ICEData
Table 15: Fluid Flow Extrusion (Polyflow)
Taskgroup
Task
Input
Output
FEMSetup
Geometry
Fluid Flow
Extrusion
(Polyflow)
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Mesh
Geometry
MechanicalModel
MeshingGeneratedMeshOutput
Provider
MeshingMesh
SimulationGeneratedMesh
MeshingGeneratedMeshOutput
Provider
Setup
SimulationGeneratedMesh
PolyflowSetup
PolyflowTransferMesh
Solution
PolyflowSetup
PolyflowSolutionType
PolyflowSolution
PolyflowSolution
ExternalDataSetup
Results
CFXSolution
CFDAnalysis
FluentSolution
272
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
VistaTFSolution
IcePakResults
PolyflowSolutionType
MechanicalSolution
ICEData
Table 16: Fluid Flow (CFX)
Taskgroup
Task
Input
Output
FEMSetup
Geometry
Fluid Flow
(CFX)
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Mesh
Geometry
MechanicalModel
MeshingGeneratedMeshOutput
Provider
MeshingMesh
SimulationGeneratedMesh
MeshingGeneratedMeshOutput
Provider
Setup
SimulationGeneratedMesh
CFXSetup
CFXMesh
SystemCouplingSetupData
MechanicalSetup
Solution
CFXSetup
CFXSolution
CFXSolution
Results
CFXSolution
CFDAnalysis
FluentSolution
VistaTFSolution
IcePakResults
PolyflowSolutionType
MechanicalSolution
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
273
Task
Input
Output
ICEData
Table 17: Fluid Flow (Fluent)
Taskgroup
Task
Input
Output
FEMSetup
Geometry
Fluid Flow
(Fluent)
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Mesh
Geometry
MechanicalModel
MeshingGeneratedMeshOutput
Provider
MeshingMesh
SimulationGeneratedMesh
MeshingGeneratedMeshOutput
Provider
Setup
FluentImportable
FluentSetup
AnsoftHeatLossDataObject
SystemCouplingSetupData
FluentMesh
FluentCase
SimulationGeneratedMesh
ICEData
ICESetupData
FluentTGridMesh
Solution
FluentSetup
FluentSolution
FluentSolution
Results
CFXSolution
CFDAnalysis
FluentSolution
VistaTFSolution
IcePakResults
PolyflowSolutionType
MechanicalSolution
274
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
ICEData
Table 18: Fluid Flow (Polyflow)
Taskgroup
Task
Input
Output
FEMSetup
Geometry
Fluid Flow
(Polyflow)
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Mesh
Geometry
MechanicalModel
MeshingGeneratedMeshOutput
Provider
MeshingMesh
SimulationGeneratedMesh
MeshingGeneratedMeshOutput
Provider
Setup
SimulationGeneratedMesh
PolyflowSetup
PolyflowTransferMesh
Solution
PolyflowSetup
PolyflowSolutionType
PolyflowSolution
PolyflowSolution
ExternalDataSetup
Results
CFXSolution
CFDAnalysis
FluentSolution
VistaTFSolution
IcePakResults
PolyflowSolutionType
MechanicalSolution
ICEData
Table 19: Geometry
Taskgroup
Task
Input
Output
FEMSetup
Geometry
Geometry
Geometry
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
275
Task
Input
Output
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Table 20: Harmonic Response
Taskgroup
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Harmonic
Response
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
EnhancedModelData
EnhancedMechanicalModel
ExternalDataSetup
MechanicalSolution
AnsoftForceAndMomentDataObject
SimulationSolutionDataInternal
Solution
SimulationSetup
276
MechanicalSolution
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
MechanicalResults
SimulationResults
Task
Input
Output
FEMSetup
Geometry
Hydrodynamic
Diffraction
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
Geometry
AqwaModel
AqwaModel
AqwaSetup
AqwaSetup
AqwaSolution
AqwaSolution
AqwaResults
Setup
Solution
Results
Task
Input
Output
FEMSetup
Geometry
Hydrodynamic
Response
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
Geometry
AqwaModel
AqwaModel
AqwaSetup
Setup
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
277
Task
Input
Output
AqwaSolution
Solution
AqwaSetup
AqwaSolution
AqwaSolution
AqwaResults
Input
Output
None
ICEData
FEMSetup
Geometry
Results
Task
ICE
ICE
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Mesh
Geometry
MechanicalModel
MeshingGeneratedMeshOutput
Provider
MeshingMesh
SimulationGeneratedMesh
MeshingGeneratedMeshOutput
Provider
ICE
Solver
Setup
SimulationGeneralMesh
ICESetupData
SimulationGeneratedMesh
Setup
FluentImportable
FluentSetup
AnsoftHeatLossDataObject
SystemCouplingSetupData
FluentMesh
FluentCase
SimulationGeneratedMesh
ICEData
ICESetupData
FluentTGridMesh
Solution
FluentSetup
278
FluentSolution
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
FluentSolution
Results
CFXSolution
CFDAnalysis
FluentSolution
VistaTFSolution
IcePakResults
PolyflowSolutionType
MechanicalSolution
ICEData
Table 24: ICEM CFD
Taskgroup
Task
Input
Model
FluentImportable
Output
ICEM CFD
Geometry
SimulationGeneratedMesh
MeshingMesh
MechanicalMesh
Table 25: Icepak
Taskgroup
Task
Input
Output
Geometry
IcePakSetup
Icepak
Setup
AnsoftHeatLossDataObject
Solution
IcePakSetup
IcePakResults
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Task
Eigenvalue
Buckling
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
279
Task
Input
Output
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSolutionDataInternal
EnhancedMechanicalModel
EnhancedModelData
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
MechanicalResults
SimulationResults
ExternalModelOutputProvider
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Eigenvalue
Buckling
(Samcef )
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
280
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSolutionDataInternal
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
MechanicalResults
SimulationResults
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Magnetostatic
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
281
Task
Input
Output
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSetup
MechanicalSolution
Solution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
MechanicalResults
SimulationResults
Task
Input
Output
MechanicalSetup
None
Mechanical
APDL
Analysis
SimulationGeneratedMesh
FEMSetup
Geometry
SolidSectionData
MechanicalSolution
MAPDLSolution
MAPDLDatabase
MAPDLResults
MAPDLCdb
Table 30: Mechanical Model
Taskgroup
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
Mechanical
Model
Engineering
Data
282
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
FEMSetup
Geometry
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Table 31: Mesh
Taskgroup
Task
Input
Output
FEMSetup
Geometry
Mesh
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Mesh
Geometry
MechanicalModel
MeshingGeneratedMeshOutput
Provider
MeshingMesh
SimulationGeneratedMesh
MeshingGeneratedMeshOutput
Provider
Task
Input
Output
Microsoft
Office Excel
Analysis
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
283
Task
Input
Output
None
MSExcelSetup
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Task
Modal
(ABAQUS)
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSolutionDataInternal
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
284
MechanicalResults
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
SimulationResults
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Modal
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSolutionDataInternal
EnhancedMechanicalModel
EnhancedModelData
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
ExternalModelOutputProvider
MechanicalResults
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
285
Task
Input
Output
SimulationResults
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Modal
(NASTRAN)
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSetup
MechanicalSolution
Solution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
MechanicalResults
SimulationResults
Task
Input
Output
Modal
(Samcef )
286
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSolutionDataInternal
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
MechanicalResults
SimulationResults
Task
Input
Output
ResponseSurfaceDataTransfer
CorrelationModel
Parameters
Correlation
Parameters
Correlation
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
287
Task
Input
Output
DesignPointsDataTransfer
Task
Input
Output
SimulationGeneratedMesh
PolyflowSetup
Polyflow
Blow
Molding
Setup
PolyflowTransferMesh
Solution
PolyflowSetup
PolyflowSolutionType
PolyflowSolution
PolyflowSolution
ExternalDataSetup
Task
Input
Output
SimulationGeneratedMesh
PolyflowSetup
Polyflow Extrusion
Setup
PolyflowTransferMesh
Solution
PolyflowSetup
PolyflowSolutionType
PolyflowSolution
PolyflowSolution
ExternalDataSetup
Task
Input
Output
SimulationGeneratedMesh
PolyflowSetup
Polyflow
Setup
PolyflowTransferMesh
Solution
288
PolyflowSetup
PolyflowSolutionType
PolyflowSolution
PolyflowSolution
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
ExternalDataSetup
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Random
Vibration
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSolutionDataInternal
EnhancedMechanicalModel
EnhancedModelData
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
MechanicalResults
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
289
Task
Input
Output
SimulationResults
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Response
Spectrum
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSolutionDataInternal
EnhancedMechanicalModel
EnhancedModelData
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
290
MechanicalResults
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
SimulationResults
Task
Input
Output
None
ParametricContext
Response
Surface
Design
of
Experiments
DOEModel
DesignPointsDataTransfer
Response
Surface
ParametricContext
ResponseSurfaceModel
DOEModel
ResponseSurfaceDataTransfer
DesignPointsDataTransfer
Task
Input
Output
None
ParametricContext
Response
Surface
Optimization
Design
of
Experiments
DOEModel
DesignPointsDataTransfer
Response
Surface
ParametricContext
ResponseSurfaceModel
DOEModel
ResponseSurfaceDataTransfer
DesignPointsDataTransfer
Optimization
ParametricContext
OptimizationModel
ResponseSurfaceModel
Table 45: Results
Taskgroup
Task
Input
Output
Results
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
291
Task
Input
Output
CFXSolution
CFDAnalysis
Results
FluentSolution
VistaTFSolution
IcePakResults
PolyflowSolutionType
MechanicalSolution
ICEData
Table 46: Rigid Dynamics
Taskgroup
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Rigid
Dynamics
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSetup
MechanicalSolution
Solution
SimulationSolutionDataInternal
SimulationSolution
292
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
SimulationSolution
MechanicalResults
Results
SimulationResults
Table 47: Shape Optimization
Taskgroup
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Shape
Optimization
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSolutionDataInternal
CFXSolution
FluentSolution
IcePakResults
MechanicalSolution
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
293
Task
Input
Output
SimulationSolution
MechanicalResults
Results
SimulationResults
Table 48: Six Sigma Analysis
Taskgroup
Task
Input
Output
Six Sigma
Analysis
Design of
Experiments
(SSA)
ParametricContext
DOEModel
DesignPointsDataTransfer
Response
Surface (SSA)
ParametricContext
ResponseSurfaceModel
DOEModel
ResponseSurfaceDataTransfer
DesignPointsDataTransfer
Six Sigma
Analysis
ParametricContext
SixSigmaModel
ResponseSurfaceModel
Table 49: Static Structural (ABAQUS)
Taskgroup
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Static
Structural
(ABAQUS)
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
294
MechanicalModel
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSolutionDataInternal
CFXSolution
FluentSolution
IcePakResults
MechanicalSolution
ExternalDataSetup
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
MechanicalResults
SimulationResults
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Static
Structural
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
295
Task
Input
Output
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
EnhancedModelData
SystemCouplingSetupData
SimulationSolutionDataInternal
CFXSolution
FluentSolution
IcePakResults
MechanicalSolution
ExternalDataSetup
AnsoftForceDataObject
EnhancedMechanicalModel
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
ExternalModelOutputProvider
MechanicalResults
SimulationResults
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
Static
Structural
(Samcef )
Engineering
Data
Geometry
296
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
FEMSetup
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSolutionDataInternal
CFXSolution
FluentSolution
IcePakResults
MechanicalSolution
ExternalDataSetup
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
MechanicalResults
SimulationResults
Task
Input
Output
FEMSetup
EngineeringData
Steady-State
Thermal
(ABAQUS)
Engineering
Data
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
297
Task
Input
Output
MatML31
Material
FEMSetup
Geometry
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
FluentSolution
IcePakResults
MechanicalSolution
SimulationSolutionDataInternal
CFXSolution
ExternalDataSetup
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
MechanicalResults
SimulationResults
Task
Input
Output
Steady-State
Thermal
Engineering
Data
298
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSolutionDataInternal
SystemCouplingSetupData
CFXSolution
FluentSolution
IcePakResults
MechanicalSolution
ExternalDataSetup
AnsoftHeatLossDataObject
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
MechanicalResults
SimulationResults
Task
Input
Output
Taskgroup
Coupling
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
299
Task
Input
Output
SystemCouplingSetupData
CouplingSetupProvider
Setup
ExternalDataSetup
Solution
CouplingSetupProvider
None
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Task
Thermal-Electric
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
CFXSolution
FluentSolution
IcePakResults
ExternalDataSetup
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
300
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
SimulationSolution
MechanicalResults
Results
SimulationResults
Table 56: Throughflow
Taskgroup
Task
Input
Output
FEMSetup
Geometry
Throughflow
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Setup
VistaGeometry
VistaTFSetup
VistaTFPhysics
Geometry
Solution
VistaTFSetup
VistaTFSolution
VistaTFSolution
Results
CFXSolution
CFDAnalysis
FluentSolution
VistaTFSolution
IcePakResults
PolyflowSolutionType
MechanicalSolution
ICEData
Table 57: Throughflow (BladeGen)
Taskgroup
Task
Input
Output
None
TurboGeometry
Throughflow
(BladeGen)
Blade
Design
VistaGeometry
Setup
VistaGeometry
VistaTFSetup
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
301
Task
Input
Output
VistaTFPhysics
Geometry
Solution
VistaTFSetup
VistaTFSolution
VistaTFSolution
Results
CFXSolution
CFDAnalysis
FluentSolution
VistaTFSolution
IcePakResults
PolyflowSolutionType
MechanicalSolution
ICEData
Table 58: Transient Structural (ABAQUS)
Taskgroup
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Transient
Structural
(ABAQUS)
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
302
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSolutionDataInternal
CFXSolution
FluentSolution
IcePakResults
MechanicalSolution
ExternalDataSetup
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
MechanicalResults
SimulationResults
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Transient
Structural
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
303
Task
Input
Output
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
EnhancedModelData
SystemCouplingSetupData
Setup
SimulationSolutionDataInternal
CFXSolution
FluentSolution
IcePakResults
MechanicalSolution
ExternalDataSetup
AnsoftForceDataObject
EnhancedMechanicalModel
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
ExternalModelOutputProvider
MechanicalResults
SimulationResults
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Transient
Structural
(Samcef )
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
304
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSolutionDataInternal
CFXSolution
FluentSolution
IcePakResults
MechanicalSolution
ExternalDataSetup
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
MechanicalResults
SimulationResults
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Transient
Thermal
(ABAQUS)
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
Model
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
305
Task
Input
Output
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSolutionDataInternal
CFXSolution
FluentSolution
IcePakResults
MechanicalSolution
ExternalDataSetup
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
MechanicalResults
SimulationResults
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Transient
Thermal
Engineering
Data
Geometry
TurboGeometry
AnsoftCADObject
ICEData
Geometry
306
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
Model
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSolutionDataInternal
SystemCouplingSetupData
CFXSolution
FluentSolution
IcePakResults
MechanicalSolution
ExternalDataSetup
AnsoftHeatLossDataObject
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
MechanicalResults
SimulationResults
Task
Input
Output
FEMSetup
EngineeringData
MatML31
Material
FEMSetup
Geometry
Transient
Thermal
(Samcef )
Engineering
Data
Geometry
TurboGeometry
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
307
Task
Input
Output
AnsoftCADObject
ICEData
Geometry
Model
SimulationEngineeringData
MechanicalModel
SimulationModelGeneratedMesh
MechanicalMesh
CompositeEngineeringData
SimulationGeneratedMesh
SolidSectionData
SimulationEngineeringData
ExternalModelOutputProvider
SimulationModelGeneratedMesh
ExternalDataSetup
EngineeringData
Geometry
Setup
MechanicalModel
SimulationSetup
MechanicalMesh
MechanicalSetup
SimulationSolutionDataInternal
CFXSolution
FluentSolution
IcePakResults
MechanicalSolution
ExternalDataSetup
Solution
SimulationSetup
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
Results
SimulationSolution
MechanicalResults
SimulationResults
Task
Input
Output
FEMSetup
Geometry
Turbomachinery
Fluid Flow
(BladeEditor)
Geometry
TurboGeometry
AnsoftCADObject
ICEData
308
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
Geometry
Turbo
Mesh
TurboGeometry
TurboMesh
Geometry
CFXMesh
FluentImportable
Setup
SimulationGeneratedMesh
CFXSetup
CFXMesh
SystemCouplingSetupData
MechanicalSetup
Solution
CFXSetup
CFXSolution
CFXSolution
Results
CFXSolution
CFDAnalysis
FluentSolution
VistaTFSolution
IcePakResults
PolyflowSolutionType
MechanicalSolution
ICEData
Table 65: TurboGrid
Taskgroup
Task
Input
Output
TurboGeometry
TurboMesh
Geometry
CFXMesh
TurboGrid
Turbo
Mesh
FluentImportable
Table 66: Vista TF
Taskgroup
Task
Input
Output
VistaGeometry
VistaTFSetup
Vista TF
Setup
VistaTFPhysics
Geometry
Solution
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
309
Task
Input
Output
VistaTFSetup
VistaTFSolution
VistaTFSolution
Results
CFXSolution
CFDAnalysis
FluentSolution
VistaTFSolution
IcePakResults
PolyflowSolutionType
MechanicalSolution
ICEData
Table 67: Vista AFD
Taskgroup
Task
Input
Output
None
VistaAFDMeanlineProvider
VistaAFDMeanlineProvider
VistaAFDDesignProvider
VistaAFDDesignProvider
None
Input
Output
None
VistaCCDBladeDesignProvider
Input
Output
None
VistaCCDBladeDesignProvider
Vista AFD
Meanline
Design
Analysis
Task
Vista CCD
Blade
Design
Task
Vista CCD
(with CCM)
Blade
Design
Performance
Map
310
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Taskgroup
Task
Input
Output
VistaCCDBladeDesignProvider
None
Task
Input
Output
None
None
Input
Output
None
None
None
VistaGeometry
Vista CPD
Blade Design
Task
Vista RTD
Blade Design
EngineeringData
MatML31
Material
AnsoftCADObject
Geometry
Geometry
FEMSetup
Geometry
ICEData
TurboGeometry
Model
CompositeEngineeringData
MechanicalMesh
EngineeringData
MechanicalModel
ExternalDataSetup
SimulationEngineering
Data
ExternalModelOutputProvider SimulationGenerated
Mesh
Geometry
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
SimulationModelGenerated
Mesh
311
ACPSetupData
EngineeringData
CompositeEngineering
Data
Geometry
EnhancedModelData
SimulationGeneratedMesh
SolidSectionData
FEMSetup
EngineeringData
MatML31
Material
AnsoftCADObject
Geometry
Geometry
FEMSetup
Geometry
ICEData
TurboGeometry
Model
CompositeEngineeringData
MechanicalMesh
EngineeringData
MechanicalModel
ExternalDataSetup
SimulationEngineering
Data
ExternalModelOutputProvider SimulationGenerated
Mesh
Geometry
SimulationEngineeringData
SimulationModelGenerated
Mesh
SolidSectionData
Results
EngineeringData
MAPDLSolution
MechanicalSolution
312
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
SimulationModelGenerated
Mesh
SimulationGeneratedMesh
Table 75: Maxwell 3D
Maxwell 3D
Geometry
AnsoftCADGeometryEntity
AnsoftCADObject
AnsoftGeometryManagerData AnsoftCellInOutEntity
Object
Geometry
AnsoftGeometryManager
DataObject
AnsoftCellInOutEntity
AnsoftCellInOutEntity
Setup
FeedbackIteratorSetup
Solution
AnsoftCellInOutEntity
AnsoftForceAndMoment
DataObject
AnsoftForceDataObject
AnsoftHeatLossData
Object
AnsoftCADObject
AnsoftGeometryManagerData AnsoftCellInOutEntity
Object
Geometry
AnsoftGeometryManager
DataObject
AnsoftCellInOutEntity
AnsoftCellInOutEntity
Setup
FeedbackIteratorSetup
Solution
AnsoftCellInOutEntity
AnsoftForceAndMoment
DataObject
AnsoftForceDataObject
AnsoftHeatLossData
Object
313
AnsoftCellInOutEntity
Solution
AnsoftCellInOutEntity
Table 79: FeedbackIterator
FeedbackIterator
Feedback Iterator
FeedbackIteratorSetup
FeedbackIteratorEntity
CFXMesh
TurboGeometry
FluentImportable
TurboMesh
Setup
CFXMesh
CFXSetup
MechanicalSetup
SystemCouplingSetup
Data
SimulationGeneratedMesh
Solution
CFXSetup
CFXSolution
CFXSolution
Results
CFXSolution
FluentSolution
314
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
CFDAnalysis
ICEData
IcePakResults
MechanicalSolution
PolyflowSolutionType
VistaTFSolution
Table 82: Turbo Machinery Fluid Flow
Turbomachinery
Fluid Flow
Turbo Mesh
Geometry
CFXMesh
TurboGeometry
FluentImportable
TurboMesh
Setup
CFXMesh
CFXSetup
MechanicalSetup
SystemCouplingSetup
Data
SimulationGeneratedMesh
Solution
CFXSetup
CFXSolution
CFXSolution
Results
CFXSolution
CFDAnalysis
FluentSolution
ICEData
IcePakResults
MechanicalSolution
PolyflowSolutionType
VistaTFSolution
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
315
316
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Property
ACPSetupData
ACPFileReference
ACPPreFileReference
AnsoftCADGeometryEntity
GeometryFilePath
AnsoftCADObject
AnsoftHeatLossDataObject
AnsoftTransferXMLString
AnsoftProjectResultsFolderAtCurrentDP
AnsoftForceDataObject
AnsoftTransferXMLString
AnsoftProjectResultsFolderAtCurrentDP
AnsoftForceAndMomentDataObject
AnsoftTransferXMLString
AnsoftProjectResultsFolderAtCurrentDP
AnsoftGeometryManagerDataObject
AnsoftCellInOutEntity
FeedbackIteratorEntity
MAPDLSolution
TransferFile
AuxiliaryFiles
MAPDLDatabse
TransferFile
AuxiliaryFiles
MAPDLResults
AuxiliaryFiles
MAPDLCdb
TransferFile
AuxiliaryFiles
AqwaModel
AqwaSetup
AqwaSolution
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
317
Property
AqwaResults
AutodynSetup
CFDAnalysis
PostStateFile
CFXSetup
CFXSolverInputFile
MAPDLSolverInputFile
CFXSolution
MResLoadOption
CFXResultsFile
AuxiliaryFiles
MAPDLResultsFile
Geometry
GeometryFilePath
PlugInName
ParametricContext
DOEModel
DesignPointsDataTransfer
ResponseSurfaceModel
ResponseSurfaceDatTransfer
OptimizationModel
CorrelationModel
ROModel
SixSigmaModel
EngineeringData
TransferFile
Material
ExternalConnectionProperties
ExternalDataSetup
TransferFile
ExternalModelOutputProvider
TransferFile
InputFiles
SolidSectionData
TransferFile
AuxiliaryFiles
CompositeSectionFiles
EnhancedMechanicalModel
318
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Transfer Type
Property
EnhancedModelData
FEMMesh
ACMOFile
FEMSetup
FEModelerFile
ANSYSInputFile
ParasolidFile
FiniteElementModelMaterials
AuxiliaryFiles
FluentTGridMesh
TransferFile
FluentSetup
CaseFile
ModelInfoFile
SystemCouplingSetupData
FluentCase
MeshFile
TransferFile
FluentSolution
CaseFile
DataFile
ICEData
ICESetupData
IcePakSetup
IcePakResults
MechanicalModel
File
EdaFile
MeshingGeneratedMeshOutputProvider
PMDBFile
ACMOFile
Mechdb
MeshingMesh
TransferFile
SimulationGeneralMesh
TransferFile
SimulationGeneratedMesh
TransferFile
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
319
Property
MSExcelSetup
CouplingSetupProvider
TransferFile
PolyflowSetup
PolyflowSolutionType
DataFile
PubFile
GeneratedFiles
PolyflowSolution
MechanicalModel
MechanicalMesh
TransferFile
SimulationEngineeringData
TransferFiles
SimulationModelGeneratedMesh
TransferFile
SimulationSetup
MechanicalSetup
TransferFile
MechanicalSolution
SimulationSolutionDataInternal
SimulationSolution
MechanicalResults
SimulationResults
TurboGeometry
INFFilename
GeometryFilename
TurboMesh
FileName
CFXMesh
FileName
PreFileType
FluentImportable
MeshFile
FileType
Dimension
VistaGeometry
GeoData
320
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
Transfer Type
Property
TransferData
VistaTFPhysics
TransferData
VistaCCDBlaseDesignProvider
TransferData
VistaAFDMeanlineProvider
TransferData
VistaAFDDesignProvider
TransferData
VistaTFSetup
ControlFilename
GeoFilename
AeroFilename
CorrelationsFilename
VistaTFSolution
ResultsFile
RestartFile
FeedbackIteratorSetup
AUTODYN_Remap
MatML31
TransferFile
CompositeEngineeringData
TransferFile
FluentMesh
TransferFile
PolyflowTransferMesh
TransferFile
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.
321
322
Release 16.2 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.