ANSYS ACT Developers Guide
ANSYS ACT Developers Guide
ANSYS, ANSYS Workbench, AUTODYN, CFX, FLUENT and any and all ANSYS, Inc. brand, product, service and feature
names, logos and slogans are registered trademarks or trademarks of ANSYS, Inc. or its subsidiaries located in the
United States or other countries. ICEM CFD is a trademark used by ANSYS, Inc. under license. CFX is a trademark
of Sony Corporation in Japan. All other brand, product, service and feature names or trademarks are the property
of their respective owners. FLEXlm and FLEXnet are trademarks of Flexera Software LLC.
Disclaimer Notice
THIS ANSYS SOFTWARE PRODUCT AND PROGRAM DOCUMENTATION INCLUDE TRADE SECRETS AND ARE CONFID-
ENTIAL 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. and ANSYS Europe, Ltd. are UL registered ISO 9001: 2015 companies.
For U.S. Government users, except as specifically granted by the ANSYS, Inc. software license agreement, the use,
duplication, or disclosure by the United States Government is subject to restrictions stated in the ANSYS, Inc.
software license agreement and FAR 12.212 (for non-DOD licenses).
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, contact ANSYS, Inc.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. iii
ACT Developer's Guide
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
iv of ANSYS, Inc. and its subsidiaries and affiliates.
ACT Developer's Guide
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. v
ACT Developer's Guide
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
vi of ANSYS, Inc. and its subsidiaries and affiliates.
Introduction
ANSYS ACT is a platform, providing a unified and consistent environment for quickly developing and
deploying easy-to-use apps. With ACT, you can create apps to customize the following ANSYS products:
• AIM
• DesignModeler
• DesignXplorer
• Electronics Desktop
• Fluent
• Mechanical
• SpaceClaim
• Workbench
This guide offers an introduction to ACT, describing its capabilities and how to use them. While
primarily intended for developers of ACT apps, it also provides information for end users who manage
and execute apps.
Note:
Because ACT apps typically extend the functionality of ANSYS products, ACT uses the terms
app and extension interchangeably.
This first section describes the ANSYS Product Improvement Program, provides an overview of how this
guide is organized, supplies getting started information on using ACT, and provides important inform-
ation related to licensing, migration, and known issues and limitations:
The ANSYS Product Improvement Program
Guide Overview
Getting Started with ACT
Licensing
Migration Notes
Known Issues and Limitations
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 1
Introduction
and patterns, interests, and quality or performance issues. The data enable us to develop or enhance
product features that better address your needs.
How to Participate
The program is voluntary. To participate, select Yes when the Product Improvement Program dialog
appears. Only then will collection of data for this product begin.
Data We Collect
The data we collect under the ANSYS Product Improvement Program are limited. The types and amounts
of collected data vary from product to product. Typically, the data fall into the categories listed here:
Hardware: Information about the hardware on which the product is running, such as the:
System: Configuration information about the system the product is running on, such as the:
• country code
• time zone
• language used
• time duration
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
2 of ANSYS, Inc. and its subsidiaries and affiliates.
The ANSYS Product Improvement Program
Session Actions: Counts of certain user actions during a session, such as the number of:
• project saves
• restarts
• toolbar selections
• number and types of entities used, such as nodes, elements, cells, surfaces, primitives, etc.
• time and frequency domains (static, steady-state, transient, modal, harmonic, etc.)
• the solution controls used, such as convergence criteria, precision settings, and tuning options
• solver statistics such as the number of equations, number of load steps, number of design points, etc.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 3
Introduction
• geometry- or design-specific inputs, such as coordinate values or locations, thicknesses, or other dimen-
sional values
• actual values of material properties, loadings, or any other real-valued user-supplied data
In addition to collecting only anonymous data, we make no record of where we collect data from. We
therefore cannot associate collected data with any specific customer, company, or location.
No, your participation is voluntary. We encourage you to participate, however, as it helps us create
products that will better meet your future needs.
No. You are not enrolled unless you explicitly agree to participate.
3. Does participating in this program put my intellectual property at risk of being collected or discovered by ANSYS?
Yes, you can stop participating at any time. To do so, select ANSYS Product Improvement Program
from the Help menu. A dialog appears and asks if you want to continue participating in the program.
Select No and then click OK. Data will no longer be collected or sent.
No, the data collection does not affect the product performance in any significant way. The amount
of data collected is very small.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
4 of ANSYS, Inc. and its subsidiaries and affiliates.
Guide Overview
The data is collected during each use session of the product. The collected data is sent to a secure
server once per session, when you exit the product.
Not at this time, although we are adding it to more of our products at each release. The program
is available in a product only if this ANSYS Product Improvement Program description appears in the
product documentation, as it does here for this product.
8. If I enroll in the program for this product, am I automatically enrolled in the program for the other ANSYS products
I use on the same machine?
Yes. Your enrollment choice applies to all ANSYS products you use on the same machine. Similarly,
if you end your enrollment in the program for one product, you end your enrollment for all ANSYS
products on that machine.
9. How is enrollment in the Product Improvement Program determined if I use ANSYS products in a cluster?
In a cluster configuration, the Product Improvement Program enrollment is determined by the host
machine setting.
10. Can I easily opt out of the Product Improvement Program for all clients in my network installation?
c. Change the value from "on" to "off" and save the file.
Guide Overview
This section introduces ACT. Subsequent sections organize content as follows:
• ACT Overview (p. 17): Presents a high-level overview of ACT that introduces you to extension develop-
ment, customization capabilities, documentation and development resources, and "roadmaps" for
specific types of customizations.
• ACT Tools (p. 37): Describes the many tools that ACT provides for developing, debugging, and executing
extensions.
• Extensions (p. 69): Describes the basic components of an ACT scripted extension and provides inform-
ation about extension configuration, supplied examples, installed IronPython function libraries, advanced
programming, and extension creation.
• Feature Creation (p. 125): Provides examples of customization capabilities common to the ANSYS products
that support using ACT to leverage existing product functionality and add custom functionality and
operations.
• Simulation Wizards (p. 139): Describes wizards and how you can create them to walk non-expert users
step-by-step through simulations.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 5
Introduction
• Debugging (p. 165): Describes debug mode and the methods for debugging scripts during extension
development.
• ACT Customization Guides for Supported ANSYS Products (p. 179): Provides links to additional guides
that explain how to use ACT to customize specific ANSYS products.
This section helps you to get started with ACT by answering these questions:
What is customization?
What is extensibility?
What is ACT?
What capabilities does ACT provide?
What skills are required for using ACT?
How do I begin using ACT?
Where can I find published ACT apps?
What is customization?
Customization is the in-product operation of modifying existing functionality and exposing brand
new features. The goal of customization is to alter an existing user experience to match the needs of
the user.
What is extensibility?
Building on customization, extensibility operates at a higher level of custom user experience, out-of-
product feature exposure, and vertical applications. The goal of extensibility is to reliably and consist-
ently enhance a software package with minimal development and maintenance effort. To extend
ANSYS software, you create extensions that add and modify functionality while minimizing the impact
on existing functionality.
What is ACT?
ACT is a unified and consistent toolkit for customizing and extending ANSYS products, providing the
fastest and easiest way to create simulation engineering apps that meet your specific needs. While
tailoring simulation applications to fit your use has traditionally been complex and time-consuming,
ACT simplifies this process, allowing you to focus more on simulation analysis than on customizing
software.
ACT uses easy-to-learn yet powerful eXtensible Markup Language (XML) and IronPython programming
languages. Even if you are a non-expert user, you can create custom apps for your advanced workflows.
Unlike typical software programming, ACT does not require a commercial Integrated Development
Environment (IDE). Instead, it provides an intuitive development environment with tools, document-
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
6 of ANSYS, Inc. and its subsidiaries and affiliates.
Getting Started with ACT
ation, and lots of examples to guide you through the process. With ACT, you can create customizations
in only hours or days instead of weeks or months.
Many ANSYS products expose their own scripting solutions. However, ACT provides a single scripting
solution for customizing all ANSYS products. You can mix ACT APIs (Application Programming Inter-
faces) with product-specific APIs without needing to compile external code or link with existing ANSYS
libraries. Additionally, ACT enables you to manage the interfaces between these products and the
additional customizations, ensuring that they all interact accurately.
ACT’s intuitive APIs and simple app creation tools capture the best practices of expert engineering
analysts, thereby reducing training and implementation costs and enabling a broader range of engin-
eers and designers to effectively use simulation tools. By fostering a unified simulation workflow, ACT
allows you to integrate your non-ANSYS engineering tools and data into the ANSYS ecosystem to
maximize the productivity of your engineering teams. Leverage these streamlined simulation workflows
for faster and better decisions throughout the entire product life cycle, from concept to product use.
Note:
For additional information about ACT, including "roadmaps" designed to guide you
through the steps of creating the desired type of ACT customization for an ANSYS
product, see ACT Overview (p. 17).
Feature Creation
Feature creation is the direct, API-driven customization of ANSYS products. In addition to leveraging
the functionality already available in a product, ACT enables you to add functionality and operations
of your own. Your custom additions operate as “native” features in the target ANSYS product.
• AIM
• DesignModeler
• DesignXplorer
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 7
Introduction
• Fluent
• Mechanical
• Workbench
Feature creation capabilities common to all of these products include user interface entry creation,
ACT-based property creation, and property parameterization. Product-specific feature creation
capabilities are described in the ACT customization guide for the product. The concluding (p. 179)
section provides links to these guides.
AIM
Expose new boundary conditions
DesignModeler
Define new user interface elements to execute custom actions
Fluent
Deploy your own UDFs with ACT UDF macro encapsulation
Mechanical
Integrate your legacy APDL macros with APDL encapsulation
Develop your own criterion using IronPython and integrate it into the powerful Mechanical
Post environment
Add new boundary conditions, preprocessing and postprocessing algorithms, and custom
results
Workbench
Define new user interface elements to execute custom actions
Feature creation also includes the integration of custom solvers and sampling and optimization
algorithms. For example, you can:
• Integrate new sampling and optimization methods in DesignXplorer. ACT enables you to extend
the existing set of ANSYS-supplied sampling and optimization algorithms with your own in-house,
third-party, or commercial strategies. You can then select these integrated methods from
DesignXplorer’s setup properties.
• Integrate custom solvers directly in Mechanical. By embedding your solvers into Mechanical simu-
lations, you can create new Workbench analysis systems based on your technologies. Within
Mechanical, the solver operates seamlessly with the processing routines for the native mathemat-
ical model, solver, and results processing.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
8 of ANSYS, Inc. and its subsidiaries and affiliates.
Getting Started with ACT
5. Publish results
With ACT, you define each workflow step as a custom task (component) and then combine multiple
custom tasks into a custom task group (system). You can then insert custom task groups on the
Workbench Project Schematic to construct consistent and cohesive simulation workflows, allowing
your business-specific elements to coexist and interface with pre-built ANSYS solutions. Currently,
Workbench is the only ANSYS product to support simulation workflow integration. For more inform-
ation, see the ACT Customization Guide for Workbench.
You can use integrated workflows for various simulation scenarios, performing custom behaviors
such as specialized data processing, report generation, and application synchronization to manage
and integrate heterogeneous processes and tools into your ANSYS simulation environment. By using
ACT to integrate diverse data generated from in-house and commercial engineering software
products into your ANSYS environment, you can improve your product lines and innovate faster.
Examples follow of using custom workflows to integrate external data and applications:
• Maintain or reuse data from an external application, such as a CAD system. With ACT, you can
automate the process of mapping and linking to this data to save time and reduce errors, greatly
improving productivity. Additionally, you can use ACT to batch process the generation of images
and reports from your model results.
• Expose external applications and data with custom workflows in Workbench to achieve:
– Remote Solve Manager (RSM) job submission to send large jobs to more powerful remote high-
performance machines
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 9
Introduction
Process Compression
Process compression is the encapsulation and automation of processes available in one or more
ANSYS products. The result is a simulation wizard (p. 139), which incorporates your best practices
to reliably guide non-expert users step-by-step through a complex simulation to produce desired
results quickly. This type of ACT customization provides the greatest breadth because wizards
simplify complex processes, allowing them to be repeated whenever needed. You can create wizards
for all products listed in the introduction (p. 1).
With wizards, you can manipulate existing features and simulation components, organizing them
as needed to produce a custom automated process. A wizard can compress and automate processes
within a single ANSYS product to manage complex model interactions for one physics area. Or, a
wizard can compress and automate processes of multiple ANSYS products and even external applic-
ations for complex multi-physics simulations. By using wizards to simplify the analytical process,
you boost the performance of the entire enterprise.
Wizards allow you to leverage both the existing functionality of ANSYS products and the scripting
capabilities of the AIM and Workbench framework API. For example, you can copy a journal of the
steps that you take in an ANSYS product into an ACT script and then parametrize the syntax to
make the script generic for reuse.
The degree of automation possible depends on the product being customized. Examples of a
Workbench-based project wizard and a mixed wizard appear in this guide. Examples of wizards
specific to an ANSYS product are described in the ACT customization guide for the product. The
concluding (p. 179) section provides links to these guides.
Because simulation workflows are often so complex, the use of simulation tends to be limited to
only a few expert users, reducing the overall efficiency of the engineering process. The need to
satisfy process compliance requirements and ensure data integrity adds even more complexity.
Using wizards, you can leverage the knowledge of your engineering process experts by compressing
your business-specific processes into streamlined, simple-to-follow steps. Because each step exposes
only the critical information required to ensure successful simulation, wizards shield users from
technical complexities.
With ACT’s standard XML and IronPython approach for all ANSYS products, app creation is easy to
learn, regardless of the ANSYS products that you plan to customize. Apply the same consistent
framework and APIs to meet your customization objectives and workflows.
The ACT App Builder (p. 92) makes creating and editing XML files and IronPython scripts even easier.
Rather than manually performing these app-building actions, you can use this tool to automatically
generate reusable scripts for customization in an interactive environment, without having to write
code. Built-in journal recording eliminates manual callback programming and property substitutions,
dramatically simplifying and speeding up customization. Intuitive property definition and processing
specific to supported ANSYS products breaks down barriers to scripting. Use of the ACT App Builder
ensures easier, faster, and cheaper development of ACT apps.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
10 of ANSYS, Inc. and its subsidiaries and affiliates.
Getting Started with ACT
For apps that customize ANSYS solvers, knowledge of APDL is required. Additionally, advanced users
can take advantage of the opportunities of .NET integration and support provided by IronPython. If
you are interested in specific members or code methods, the ACT Console (p. 50) is a convenient
tool to interactively navigate the APIs through robust autocompletion.
The Extension Manager (p. 39) provides for installing and loading extensions. The Wizards launch-
er (p. 44) starts simulation wizards (p. 139), and the binary extension builder (p. 46) creates compiled
binary files from scripted extensions. With tools like the ACT App Builder (p. 92), ACT Debugger (p. 166),
and ACT Workflow Designer, modifying existing ANSYS functionalities and adding new custom func-
tionalities and workflows is easy, giving you the power to decide how ANSYS products should look
and behave.
ACT also provides a full set of supporting resources to help you with app development. The ACT
documentation includes comprehensive feature overviews and detailed API descriptions. To aid you
in development efforts, ACT supplies comprehensive examples (p. 78) for various types of ANSYS
product customizations, all of which are designed to help you to understand how to use ACT to de-
velop apps. For instance, you can easily modify supplied examples to align them with your own
simulation vision, saving you both development time and money. Written and tested on supported
Windows and Linux platforms, these examples are packaged for download from the help panel on
the ACT Start Page (p. 37). Additionally, on the App Developer Resources page, the Help & Support
tab displays a link for downloading the examples.
The ANSYS training course for ACT covers using ACT and its APIs to customize Workbench, Mechan-
ical/Meshing, and DesignModeler. After completing this course, you will be able to automate the
creation of standard tree objects in Mechanical/Meshing, create custom loads and results in Mechan-
ical, create custom objects in DesignModeler, and create wizards in Workbench or its integrated
modules.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 11
Introduction
In the left pane, you can click the link for the App Developer Resources page, where you will find a
multitude of resources for using ACT to develop your own custom apps. On this page, the Post My
ACT Application tab displays a link for downloading instructions for posting your custom apps on
the ANSYS Store.
By making complex simulations accessible to all engineers, ANSYS apps “democratize” the use of
simulation across your organization. With designers being able to perform simulations, expert engineers
can spend more time on researching and developing innovative and reliable products.
Licensing
The ACT license is bundled with most ANSYS 2020 R1 products. You must have a license to develop
scripted extensions. You do not need to have a license to run binary extensions (WBEX files).
• Ability to load scripted extensions for development, debugging, and execution. When an ACT license is
checked out, scripted extensions can be loaded. No matter how many scripted extensions are loaded, only
one ACT license is checked out. This license is released once all scripted extensions are unloaded. If no ACT
license is checked out, only binary extensions can be loaded.
• Ability to build binary extensions from scripted extensions. The ACT license is checked out when a build
starts and is released once the build finishes. If an ACT license is already checked out by a loaded scripted
extension, the building of a binary extension does not require a second ACT license.
Migration Notes
As improvements are made to ACT APIs and the way that they display and transmit data, great efforts
are taken to ensure that changes are backwards-compatible. For your convenience, this section lists
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
12 of ANSYS, Inc. and its subsidiaries and affiliates.
Known Issues and Limitations
2020 R1 API changes that might impact your existing ACT extensions so that you can determine if any
action is necessary before migrating them.
Note:
• For migration notes specific to Mechanical APIs, see Mechanical API Migration Notes in the
Scripting in Mechanical Guide.
• On the ANSYS Store, the App Developer Resources page displays a link on the Help & Support
tab to the stand-alone ACT Migration Notes document. This document may contain entries
that were added after publication of this guide. To quickly access this document, click here.
InvokeUIThread
In Mechanical, the callbacks OnSolve, OnGenerate, Evaluate, and GetCommands are now run
on the UI thread by default. A new attribute, InvokeUIThread, is exposed on the tags of these
callbacks. Setting InvokeUIThread to False will bring back the previous behavior of running the
callback on a separate background thread. The main advantage of running a callback on a background
thread is to keep the user interface responsive during the execution of the callback. However, the
behavior change was made to avoid several crashes and instabilities that occur when running arbitrary
code on a background thread. You can still offload some work safely to a background thread even
when InvokeUIThread is set to True. For more information, see Threading in the Scripting in
Mechanical Guide.
Change to callbacks executed during design point and project updates for Mechanical extensions
For Mechanical extensions, the callback onTerminate now executes in batch mode, including during
design point and project updates. Update your Mechanical extensions accordingly. Use the property
Hidden via ExtAPI.Application.Hidden to check whether Mechanical is running in batch
mode.
Note:
ACT has superseded the ANSYS Workbench Software Development Kit (SDK) and External
Connection Add-In as the best-in-class tool set for customizing ANSYS products. Support for
the SDK and External Connection Add-in ended as of 19.0. If you have used these deprecated
tool sets for Workbench customizations, click here to quickly access the migration guide. On
the App Developer Resources page, the Help & Support tab also displays a link to this mi-
gration guide.
Note:
• For known issues and limitations specific to Mechanical APIs, see Mechanical API Known Issues
and Limitations in the Scripting in Mechanical Guide.
• On the ANSYS Store, the App Developer Resources page displays a link on the Help & Support
tab to the stand-alone ACT Known Issues and Limitation document. This document may contain
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 13
Introduction
entries that were added after publication of this guide. To quickly access this document, click
here.
Workbench customization
When using ACT to create Workbench custom workflows, not all optional attributes for the tag <property>
are currently supported. For example, visibleon is not supported.
For DesignModeler, the ACT Console, Extensions Log File, and ACT wizards are supported on Windows
platform only
For DesignModeler, the ACT Console, Extensions Log File, and ACT wizards are supported only when
DesignModeler is running on the Windows platform.
ACT Debugger and App Builder are supported on Windows platform only
The ACT Debugger is supported only on the Windows platform from the Project page in ANSYS Workbench
and from DesignModeler and Mechanical. The ACT App Builder is supported only on the Windows platform.
There is no mechanism to integrate localization for the property names defined by an extension.
To manage different languages for your property names, you must develop localization yourself.
Both regional settings based on the "." or the "," decimal symbol are available. However, the imple-
mentation of the extension should use the "." symbol for any value defined at the XML or IronPython
level.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
14 of ANSYS, Inc. and its subsidiaries and affiliates.
Known Issues and Limitations
icon on the graphic-based Extension Manager accessed from the ACT Start Page to add the folder for
the default location or the folder to which you installed the extension.
Accessing UserInterface on ExtAPI in Mechanical from an onInit callback or globally causes errors
Accessing UserInterface on ExtAPI in Mechanical from an onInit callback or globally causes errors
to be thrown in the Extensions Log File, resulting in instability. Workaround: Access UserInterface
from an onLoad callback or any place other than the onInit callback. Keep in mind that an onLoad
callback is invoked only when Mechanical is started. Reloading an extension using the button in the GUI
will not invoke an onLoad callback.
• AddErrorMessage
• AddFatalMessage
• AddInfoMessage
• AddWarningMessage
• LogDebug
• LogError
• oDesktop.AddMessage
• Python logging functionality (for example, "import logging" and use the logging module)
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 15
Introduction
Some Linux versions contain a JPEG library that conflicts with the ANSYS package
In some Linux versions, a JPEG library conflicts with the ANSYS package. When using ACT wizards with
JPEG images, this conflict can produce an SIGSEV error and an application crash. If this occurs, you can
convert your images to other file formats such as GIF or PNG.
Graphics API issues in ANSYS DesignModeler and Mechanical when no extensions are loaded
When no extensions are loaded, there are some limitations on the Graphics API from the ACT Console
in ANSYS DesignModeler and Mechanical. For instance, Factory2D does not work. Therefore, you should
load one or more extensions before using the Graphics API from the ACT Console.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
16 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT Overview
ACT is a unified and consistent toolkit for the customization and expansion of ANSYS products. Using
ACT, you can create extensions to tailor the ANSYS products listed in the introduction (p. 1) to meet
your product-specific and multi-physics simulation needs. You can also engage the ANSYS simulation
ecosystem through integration and custom workflow techniques.
• Present a high-level overview of ACT, introducing you to the general concepts that you need to know
to develop extensions.
• Help you to start developing your own extensions, from the initial design phase through the implement-
ation and—when desired—to the final posting of your app to the ANSYS Store. On the App Developer
Resources page of the ANSYS Store, the Post My ACT Application tab displays a link for downloading
posting instructions.
• Provide references and links to ACT documentation and resources so that you can easily access relevant
information, such as:
• Deliver specialized customization "roadmaps" designed to guide you through the steps of creating the
desired type of ACT customization for an ANSYS product.
Extension Structure
All ACT extensions are made up of the same two basic parts: an XML extension definition file and an
IronPython script.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 17
ACT Overview
Extensions can potentially include additional components such as external Python libraries, C# code,
input files, and images to display in the custom interface. For comprehensive information, see Exten-
sions (p. 69).
Extension Formats
ACT extensions can be created in two different formats: scripted and binary.
Scripted Extensions
A scripted extension consists of an editable XML extension definition file and IronPython script. The
XML file and the folder containing the IronPython script and any supplementary supporting files are
saved at the same level. For more information, see Setting Up the Directory Structure (p. 72)
Binary Extensions
A binary extension is a compiled WBEX file resulting from the build of a scripted extension. Binary ex-
tensions can be shared with others, who are able to execute the extension but cannot edit it. For more
information, see Binary Extension Builder (p. 46).
Note:
You need an ACT license to load scripted extensions and to build binary extensions. For
more information, see Licensing (p. 12).
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
18 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT Customization Capabilities
• Feature creation
• Process compression
In subsequent roadmaps, color coding is assigned to distinguish between customization types. This
table shows the ANSYS products that currently support ACT customization capabilities.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 19
ACT Overview
Visit the ANSYS Store to view the apps offered by ANSYS and its customers. You can filter posted apps
based on product family, version, and by free or paid apps.
Additionally, on the ANSYS Store, the App Developer Resources page displays tabs with links to these
and other ACT documents. Documents of possible interest include stand-alone migration notes, a
presentation providing instructions for installing ACT extensions, and the software licensing agreement
and instructions for publishing extensions to the ANSYS Store.
• ACT API Reference Guide: Provides interface-level API information for ACT.
• ACT XML Reference Guide: Provides XML element definition and tagging information for ACT.
• Discovery AIM and Workbench Scripting Guide: Provides a general introduction to journaling and
scripting capabilities that can be used in some customizations. Also contains product-specific data
container information.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
20 of ANSYS, Inc. and its subsidiaries and affiliates.
Roadmaps for ACT Customization
• ANSYS ACT API and XML Online Reference Guide: Provides an easy-to-navigate HTML document in
which you can quickly look up all three levels of API information (global, automation, and object),
along with XML element definition and tagging information. This online version is the recommended
reference document for ACT developers. If you want, you can download a download a ZIP file con-
taining this document. Additionally, the help panel for the ACT Start Page (p. 37) provides links for
both the online and downloadable versions.
Training Materials
Training materials for ACT and IronPython are available on the ANSYS Learning Hub.
Note:
Content goes from general to specific. The following image displays the overall roadmap for ACT cus-
tomization.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 21
ACT Overview
The next section describes the steps that are common to all extensions. Subsequent sections provide
roadmaps and steps for each of the three customization types. Each section for a customization type
provides information for the specific ANSYS products that can be customized.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
22 of ANSYS, Inc. and its subsidiaries and affiliates.
Feature Creation Roadmap
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 23
ACT Overview
Note:
Fluent does not currently support using ACT to deliver custom features via extensions.
However, it does support using UDF libraries for feature creation. For more information, see
UDF Folder in the ACT Customization Guide for Fluent.
All products that support ACT-based feature creation provide the following capabilities:
Topic Reference
Common Feature Creation (p. 125) >
capabilities
• Toolbar Creation (p. 125)
The following topics describe feature creation capabilities in specific ANSYS products:
Feature Creation in DesignModeler
Feature Creation in DesignXplorer
Feature Creation in Mechanical
Feature Creation in the Workbench Project Page
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
24 of ANSYS, Inc. and its subsidiaries and affiliates.
Feature Creation Roadmap
In addition to the common capabilities listed in Feature Creation Roadmap (p. 23), DesignModeler
supports the feature creation capabilities that follow. References in this table take you to topics in
the ACT Customization Guide for DesignModeler.
Topic Reference
Capabilities specific DesignModeler Feature Creation >
to DesignModeler
• ACT-Based Property Parametrization in DesignModeler
• Creating Primitives
• Applying Operations
For comprehensive API and XML information, see the ANSYS ACT API and XML Online Reference Guide.
• Ansys.ACT.Interfaces.DesignModeler
• Ansys.ACT.Automation.DesignModeler
<extension>
<simdata>
<Geometry>
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 25
ACT Overview
In addition to the common capabilities listed in Feature Creation Roadmap (p. 23), DesignXplorer
supports the feature creation capabilities that follow. References in this table take you to topics in
the ACT Customization Guide for DesignXplorer.
Topic Reference
Capabilities specific DesignXplorer Feature Creation >
to DesignXplorer
• ACT-Based Properties for External Methods
• Optimization APIs
The package ACT Templates for DesignXplorer provides five templates for integrating sampling
and optimization methods. For more information, see ACT Templates for DesignXplorer (p. 84) in the
ANSYS ACT Developer's Guide.
For comprehensive API and XML information, see the ANSYS ACT API and XML Online Reference Guide.
• Ansys.DesignXplorer.API
• Ansys.DesignXplorer.API.Common
• Ansys.DesignXplorer.API.Optimization
• Ansys.DesignXplorer.API.Sampling
• Ansys.DesignXplorer.Automation
<extension>
<simdata>
<extensionobject>
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
26 of ANSYS, Inc. and its subsidiaries and affiliates.
Feature Creation Roadmap
<optimizer>
In addition to the common capabilities listed in Feature Creation Roadmap (p. 23), Mechanical supports
the feature creation capabilities that follow. References in this table take you to topics in the ACT
Customization Guide for Mechanical. For information on Mechanical scripting and API usage, see
Scripting in Mechanical Guide.
Topic Reference
Capabilities Mechanical Feature Creation >
specific
to • ACT-Based Property Parametrization in Mechanical
Mechanical
• Preprocessing Capabilities in Mechanical >
– Defining Objects and Loads that Do Not Affect the Solution State
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 27
ACT Overview
For comprehensive API and XML information, see the ANSYS ACT API and XML Online Reference Guide.
• Ansys.ACT.Automation.Mechanical
• Ansys.ACT.Automation.Mechanical.AnalysisSettings
• Ansys.ACT.Automation.Mechanical.BoundaryConditions
• Ansys.ACT.Automation.Mechanical.Connections
• Ansys.ACT.Automation.Mechanical.Enums
• Ansys.ACT.Automation.Mechanical.ImportedLoads
• Ansys.ACT.Automation.Mechanical.MeshControls
• Ansys.ACT.Automation.Mechanical.Results
• Ansys.ACT.Interfaces.Mechanical
• Ansys.ACT.Mechanical.Fields
<extension>
<simdata>
<load>
<object>
<result>
<solver>
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
28 of ANSYS, Inc. and its subsidiaries and affiliates.
Simulation Workflow Integration Roadmap
Topic Reference
Capabilities Simulation Workflow Integration >
specific to the
Workbench Pro- • Custom Task Group and Task Exposure in the Project Schematic
ject page
• Global Callbacks
• Progress Monitoring
• Process Utilities
• External Application Integration with Custom Data and Remote Job Execution
• Custom Transfer
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 29
ACT Overview
Topic Reference
Workbench • Appendix B: ANSYS-Installed System Component Template and Display
custom Names
workflow
information • Appendix C: Data Transfer Types
For journaling and scripting information, including product-specific data container details, see the Dis-
covery AIM and Workbench Scripting Guide.
For comprehensive API and XML information, see the ANSYS ACT API and XML Online Reference Guide.
• Ansys.ACT.Interfaces.Common
• Ansys.ACT.Interfaces.DataModel
• Ansys.ACT.Interfaces.UserInterface
• Ansys.ACT.Interfaces.UserInterface.Components
• Ansys.ACT.Interfaces.UserObject
<extension>
<workflow>
<callbacks>
<property>
<propertygroup>
<propertytable>
<taskgroups>
<tasks>
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
30 of ANSYS, Inc. and its subsidiaries and affiliates.
Process Compression Roadmap
Topics common to wizard creation follow. References in this table take you to topics in this guide.
Topic Reference
General wizard information Wizard Interface and Usage (p. 139)
Types of wizard (project, Wizard Types (p. 141)
target product, and mixed)
Creating wizards Wizard Creation (p. 142)
Creating a mixed wizard Mixed Wizard Example (p. 153)
Custom help files for wizards Custom Wizard Help Files (p. 158)
Custom interfaces for Custom Wizard Interfaces (p. 159)
Workbench-based wizards
Custom interface example Custom Wizard Interface Example (p. 161)
Note:
You use the Extension Manager (p. 39) to install and load extensions. You then use the
Wizards launcher (p. 44) to start a wizard.
For journaling and scripting information, including product-specific data container details, see the Dis-
covery AIM and Workbench Scripting Guide and refer to the sections for the specific ANSYS products being
customized.
For comprehensive API and XML information, see the ANSYS ACT API and XML Online Reference Guide.
<extension>
<application>
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 31
ACT Overview
<appstoreid>
<author>
<description>
<propertytable>
<uidefinition>
<wizard>
References in the following table take you to topics in the ACT Customization Guide for Discovery AIM.
Topic Reference
AIM project wizards, AIM Project Wizards
including an example
AIM target product AIM Product Wizards
wizards
Custom templates Custom Templates
Guided simulations Guided Simulations
Guided setups Guided Setups
Step definition Step Definition
Property definition Property Definition
Custom template Custom Template Examples >
examples
• Custom Template (Single-Step)
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
32 of ANSYS, Inc. and its subsidiaries and affiliates.
Process Compression Roadmap
For journaling and scripting information, including product-specific data container details, see the
Discovery AIM and Workbench Scripting Guide and refer to the "Workbench" section.
For comprehensive API and XML information, see the ANSYS ACT API and XML Online Reference Guide.
Topic Reference
DesignModeler wizard DesignModeler Wizards
example
For journaling and scripting information, including product-specific data container details, see the
Discovery AIM and Workbench Scripting Guide.
For comprehensive API and XML information, see the ANSYS ACT API and XML Online Reference Guide.
For more information about project wizards and mixed wizards for Workbench, see:
• Process Compression for Multiple ANSYS Products (Mixed Wizards) (p. 35)
The reference in the following table takes you to a topic in the ACT Customization Guide for SpaceClaim.
Topic Reference
Electronics Desktop wizard Electronics Desktop Wizards
example
For journaling and scripting information, including product-specific data container details, see the
Discovery AIM and Workbench Scripting Guide.
For comprehensive API and XML information, see the ANSYS ACT API and XML Online Reference Guide.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 33
ACT Overview
References in the following table take you to topics in the ACT Customization Guide for Fluent.
Topic Reference
Fluent wizard Fluent Wizards >
examples
• Fluent Wizard (MSH Input File)
For journaling and scripting information, including product-specific data container details, see the
Discovery AIM and Workbench Scripting Guide.
For comprehensive API and XML information, see the ANSYS ACT API and XML Online Reference Guide.
Topic Reference
Mechanical wizard Mechanical Wizards
example
For journaling and scripting information, including product-specific data container details, see the
Discovery AIM and Workbench Scripting Guide and refer to the "Mechanical" section.
For comprehensive API and XML information, see the ANSYS ACT API and XML Online Reference Guide.
References in the following table take you to topics in the ACT Customization Guide for SpaceClaim.
The first reference takes you to a topic describing the SpaceClaim wizard that is part of the mixed
wizard example (p. 153) described in this guide.
Topic Reference
SpaceClaim wizard SpaceClaim Wizards >
examples
• SpaceClaim Wizard for Building a Bridge
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
34 of ANSYS, Inc. and its subsidiaries and affiliates.
Process Compression Roadmap
For journaling and scripting information, including product-specific data container details, see the
Discovery AIM and Workbench Scripting Guide.
For comprehensive API and XML information, see the ANSYS ACT API and XML Online Reference Guide.
Topic Reference
Workbench project wizard Wizard Creation (p. 142)
example
For journaling and scripting information, including product-specific data container details, see the
Discovery AIM and Workbench Scripting Guide and refer to the "Workbench" section.
For comprehensive API and XML information, see the ANSYS ACT API and XML Online Reference Guide.
The reference in the following table takes you to a topic in this guide.
Topic Reference
Workbench mixed wizard Mixed Wizard Example (p. 153)
example
For journaling and scripting information, including product-specific data container details, see the
Discovery AIM and Workbench Scripting Guide and refer to the sections for the products in which wizards
are executed.
For comprehensive API and XML information, see the ANSYS ACT API and XML Online Reference Guide.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 35
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
36 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT Tools
ACT provides many tools for developing, debugging, and executing extensions. To use these tools ef-
fectively, you must first understand how extensions are created (p. 69) and debugged (p. 165).
Tool Description
ACT Start The ACT Start Page is a single page that provides you with convenient access to
Page (p. 37) ACT functionality. From this page, you can access tools for developing, debugging
and executing extensions.
Extension The Extension Manager is for installing and loading extensions. Extensions cannot
Manager (p. 39) be executed until they are installed and loaded.
Wizards The Wizards launcher is for starting a simulation wizard (p. 139). After an extension
Launcher (p. 44) with a wizard is installed and loaded, you use the Wizards launcher to start the
wizard.
Extensions Log The Extensions Log File displays messages generated by extensions. If warnings
File (p. 45) are present, they display in orange. If errors are present, they display in red.
Binary Extension The binary extension builder creates a compiled WBEX file from a scripted extension
Builder (p. 46) that can be shared with others. Once you finish developing and debugging a scripted
extension, you can compile it into a binary extension. The contents of a binary
extension cannot be viewed or edited.
ACT The ACT Console exposes the ACT API so that you can interactively test commands
Console (p. 50) as you develop and debug scripts.
ACT App The ACT App Builder is for a creating ACT extensions in a visual environment,
Builder (p. 92) saving you from having to create or modify XML files and IronPython scripts directly.
ACT The ACT Debugger extends the ACT Console to provide state-of-the-art debugging
Debugger (p. 166) capabilities. You can use it or Microsoft® Visual Studio (p. 176) for debugging.
ACT Workflow The ACT Workflow Designer is for automating the creation of custom simulation
Designer workflows on the Workbench Project page. For more information, see the ACT
Customization Guide for Workbench.
This guide assumes that you are accessing this page from Workbench. For access information to this
page from AIM and stand-alone instances of Electronics Desktop, Fluent, and SpaceClaim, see the ACT
customization guides for these products. The concluding section (p. 179) provides links to these guides.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 37
ACT Tools
The ACT Start Page displays icons for accessing many ACT tools. The Extensions menu also provides
options for accessing these tools.
The lower help panel provides links to ACT guides, supplied examples (p. 78), and release-specific
documents. Clicking the resize button in the upper right corner opens this panel in a new window in
your browser.
Note:
On the ANSYS Store, the App Developer Resources page displays tabs with links to not only
these ACT documents but also many more.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
38 of ANSYS, Inc. and its subsidiaries and affiliates.
Extension Manager
Extension Manager
The Extension Manager is for installing and loading extensions. You cannot execute an extension until
it is installed and loaded.
There are two versions of the Extension Manager, both of which offer similar capabilities:
• To access the graphic-based version, click Manage Extensions on the ACT Start Page.
The Extension Manager displays all extensions that are installed and available for loading. To define
additional folders in which ACT is to search for extensions, you use the Additional Extension
Folders (p. 77) option. This option is available when you click the gear icon in the graphic-based Exten-
sion Manager and in Tools → Options → Extensions.
Note:
While the Extension Manager always lists installed binary extensions, it lists installed scripted
extensions only if you have an ACT license.
The following topics describe how to use both versions of the Extension Manager:
Using the Graphic-Based Extension Manager
Using the Table-Based Extension Manager
Searching for an Extension
Installing and Uninstalling Extensions
Loading and Unloading Extensions
Configuring Extensions to Load by Default
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 39
ACT Tools
• Click one of the plus (+) icons to install a new binary extension.
• Click the gear icon to access Debug Mode (p. 78) and Additional Extension Folders (p. 77) options. These
options serve the same purpose as those in Tools → Options → Extensions. However, rather than having
to manually define the folders that the Extension Manager searches for the extensions to display, here
you click Add Folder and then browse to and select the folder.
• Click ANSYS App Store in the lower left corner to explore ACT apps available for download.
• Click the left-pointing arrow in the upper left corner to return to the ACT Start Page.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
40 of ANSYS, Inc. and its subsidiaries and affiliates.
Extension Manager
Right-clicking an extension displays a context menu with the options available for the extension. The
options shown depend on the current state of the extension. Descriptions follow for all possible options:
• Load extension: Available only for an unloaded extension, this option loads the extension.
• Unload extension: Available only for a loaded extension, this option unloads the extension
• Load as default: Available only for an extension that is not automatically loaded to a project by default,
this option loads the extension to either an existing or new project when Workbench or the corres-
ponding targeted product is started. For more information, see Configuring Extensions to Load by
Default (p. 44).
• Do not load as default: Available only for an extension that is automatically loaded to a project by
default, this option does not load the extension to either an existing or new project when Workbench
or the corresponding targeted product is started.
• Uninstall: Available only for unloaded binary extensions, this option uninstalls the binary extension.
• Build: Available only for scripted extensions, this option opens the binary extension builder (p. 46).
• About: Always available, this option displays extension information such as the version, format (xml
or wbex), folder, guid, context, and feature.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 41
ACT Tools
Right-clicking an extension displays a context menu with the options available for the extension. The
options shown depend on the current state of the extension. They are comparable to the options
described in the previous topic for the graphic-based Extension Manager.
Example 2: Type authorname to return all extensions with author set to authorname.
Context
Example: Type Mechanical to return all extensions with context set to Mechanical.
Note:
When Workbench or AIM is not installed, the installation location for an extension with a
Fluent or SpaceClaim wizard differs. For more information about stand-alone instances,
see the ACT customization guides for these two products. The concluding section (p. 179)
provides links to these guides.
To install a scripted extension, save the extension and associated files in one of the following loca-
tions:
• %ANSYSversion_DIR%\..\Addins\ACT\extensions
• %APPDATA%\Ansys\v201\ACT\extensions
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
42 of ANSYS, Inc. and its subsidiaries and affiliates.
Extension Manager
• Any of the additional directories specified for Additional Extension Folders (p. 77). This option is
available when you click the gear icon in the graphic-based Extension Manager and in ToolsOp-
tionsExtensions.
To uninstall a scripted extension, remove the extension and its associated files and folders. If you
uninstall a scripted extension while the Extension Manager is open, it continues to display this
extension until you close and reopen the Extension Manager.
Note:
The Uninstall option is available on the right-click context menu only for a binary exten-
sion.
• In the graphic-based Extension Manager accessed from the ACT Start Page, click one of the plus
(+) icons.
2. In the Open dialog box that appears, navigate to and select the WBEX file that you want to install and
click Open.
Installed binary extensions are installed to your application data folder (%APPDATA%\An-
sys\v201\ACT\extensions) and are available for loading in the Extension Manager.
Note:
When you install a binary extension, a new folder and WBEX file are created because
both are necessary for compatibility with ACT. If you need to move the extension to a
different folder, make sure that both the folder and WBEX file are copied to the same
folder at the same time.
To uninstall a binary extension, simply right-click it and select Uninstall, which is available only for
binary extensions.
Caution:
When uninstalling a binary extension, ACT permanently deletes both the definition
file and folder. You will lose all changes that you have made to the extension's
folder contents. Best practice is to use your application data folder %APPDATA%\An-
sys\v201\ACT\extensions only for installing WBEX files and another folder
for developing your source code.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 43
ACT Tools
• In the graphic-based Extension Manager accessed from the ACT Start Page, you can also load or
unload an extension by simply clicking the block for the extension.
• In the table-based Extension Manager accessed from the Extensions menu, you can also load or
unload an extension by selecting or clearing the check box to the left of the extension name.
Note:
• Loading is automatic for extensions that have already been loaded and saved to the project.
Any extension to be automatically loaded must be available to the Extension Manager. If the
Extension Manager cannot load a required extension when a project is opened, a warning
message appears, indicating that you might encounter limited behavior if you proceed. Clicking
Show Details in this message lists the extensions that are missing from the project. Clicking
OK proceeds with opening the project.
• If you use either version of the Extension Manager in Workbench to load an extension with
the attribute context set to Mechanical, then Mechanical knows that this extension is
loaded. However, if you unload the extension using either version of the Extension Manager
in Workbench, then Mechanical does not know that the extension has been unloaded.
• In the graphic-based Extension Manager accessed from the ACT Start Page, the word Default ap-
pears in the upper right corner of the block for the extension.
• In the table-based Extension Manager accessed from the Extensions menu, the word Default appears
in parentheses after the extension name.
If you no longer want an extension to load by default, right-click it and select Do Not Load as Default.
Wizards Launcher
The Wizards launcher is for starting a simulation wizard (p. 139). When you click Launch Wizards on
the ACT Start Page (p. 37), the Wizards launcher displays all loaded extensions that have wizards for
the current context.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
44 of ANSYS, Inc. and its subsidiaries and affiliates.
Extensions Log File
The Search option here is the same as the one in the Extension Manager. For more information, see
Searching for an Extension (p. 42).
To start a wizard, click the block for the extension. Optionally, right-click it and select Execute Wizard.
The wizard starts, showing the first step.
You can open the Extensions Log File from many different places:
In Workbench or AIM:
You can open the Extensions Log File in one of two ways:
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 45
ACT Tools
• On the ACT Start Page, click the Log button in the toolbar.
In DesignModeler:
From the ACT Development toolbar, click the button for switching between opening and closing
the Extensions Log File. This toolbar is available only when the Debug Mode (p. 78) check box is
selected in Tools → Options → Extensions.
In Mechanical:
In the ACT Development group on the ribbon's Automation tab, click View Log. This group is
available only when the Debug Mode (p. 78) check box is selected in Tools → Options → Extensions.
You can resize and drag the window displaying the Extensions Log File. You can also keep this window
open as you switch between products. To clear the Extensions Log File, you click the brush icon in
the window's upper right corner.
Tip:
To open the Extensions Log File in your web browser, you can copy all of the text that follows
WebPage: and paste it into your browser's address bar. For example, given the log file shown
in this topic, you'd copy and paste the following text:
file:///C:\Program Files\ANSYS Inc\v181\Addins\ACT\html\gridpanell.html?ACTPort=52560&ACTSocketName=Log
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
46 of ANSYS, Inc. and its subsidiaries and affiliates.
Binary Extension Builder
its own process for encapsulating all folders and files necessary for the extension into the WBEX file,
which cannot be viewed or edited.
The appearance of the binary extension builder depends on how it was accessed. The following topics
provide access and usage information:
Accessing the Binary Extension Builder
Building a Binary Extension
Compiling Multiple IronPython Scripts
• In the graphic-based Extension Manager accessed form the ACT Stat Page, right-click the extension and
select Build.
• In the ACT App Builder (p. 92), when an app builder project is open, click the toolbar button for exporting
a binary extension.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 47
ACT Tools
1. If the binary extension builder was accessed from the Extensions menu, for Scripted Extension to Build,
select the scripted extension to build as a WBEX file.
Choices include all scripted extensions in directories specified for Additional Extension
Folders (p. 77). This option is available when you click the gear icon in the graphic-based Extension
Manager and in Tools → Options → Extensions.
Both the extension name and version are shown to avoid confusion in case multiple versions of
an extension are defined.
If the binary extension builder is accessed using any other method, Scripted Extension to Build
is not shown because the scripted extension is already selected.
2. For Output Folder for Binary Extension, identify the folder in which to output the WBEX file.
Your selection specifies whether the extension can be saved within an Workbench project and,
when that project is shared, whether the extension can be loaded with the shared project. The
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
48 of ANSYS, Inc. and its subsidiaries and affiliates.
Binary Extension Builder
security level allows the developer of the extension to control how the extension can be shared
and used with various projects. Choices are:
• Can copy extension to project: Each time a user asks to save the extension with a project, the
extension itself is copied into the project and consequently is available each time the project
is opened. The extension can also be used with other projects.
• 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, the extension is not available.
• Can't copy extension to project: The extension is not saved with the project and is not shared
with other users of the project.
Note:
• The extension can be sent separate from a project. The process for saving extensions
within a project is described in Configuring Extensions to Load by Default (p. 44).
• Security options only apply when users attempt to save the extension with a project. Oth-
erwise, they are not applicable.
4. Click Build.
While the WBEX file is being built, the bottom part of the window displays build information.
The element <script> appears four times. All four of these scripts are placed in the extension folder.
When ACT processes multiple scripts, it loads them into a single scope, as if the contents of all scripts
are contained in a single flat file. This works for a scripted extension that uses import statements
because all scripts reside in the extension folder.
Before using the binary extension builder to compile a scripted extension into a WBEX file, you can
specify which scripts to compile by setting the attribute compiled to true for the element
<script>:
<script src="main.py" compiled="true" />
<script src="ds.py" compiled="true" />
<script src="dm.py" compiled="true" />
<script src="sc.py" compiled="true" />
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 49
ACT Tools
When multiple scripts are marked as compiled, the binary extension essentially pushes all of the
content in these scripts into the binary buffer stream. When you install and load the WBEX file, ACT
reads each script from the binary buffer and loads the script content into a single scope.
Consequently, the result for the binary version is the same as the scripted version. All contents in the
multiple scripts are loaded into a single scope without any module designations, just as if you had
originally combined the different scripts into one large, single script.
Unlike a scripted extension, the installed binary extension can no longer import another script as a
module because the scripts no longer reside in an extension folder. Because methods and classes are
invoked as if all scripts are in one large, single script, you must remove import statements and module
prefixes before building a binary extension. By flattening the scripts in this way, both the scripted
and binary versions of the extension run successfully.
This flattening does make it difficult to test the scripted extension before building the binary version
because you cannot truly test the implementation until after you create and install the WBEX file.
However, you can compile your IronPython modules into DLLs, remove the corresponding elements
for the scripts from the XML file, and import them as required in your main script.
Note:
You cannot currently flag files to have the binary extension builder skip them. During
the building of a WBEX file, any messages that you see about files being skipped are
the result of ACT no longer needing the plain-text scripts because the elements for
the scripts are marked as compiled="true".
ACT Console
The ACT Console exposes the ACT API so that you can interactively test commands as you develop
and debug scripts. Currently, the ACT API provides coverage for the following ANSYS products:
• Workbench
• DesignModeler
• Mechanical
The following topics describe the ACT API, the console, and how to use it:
Understanding the ACT API
Understanding Console Components
Selecting the Scope
Entering Commands in the Command Line
Working with Command History Entries
Using Autocompletion
Using Snippets
Using Console Keyboard Shortcuts
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
50 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT Console
The extensions that are loaded by the Extension Manager (p. 39) are each configured and initialized
to support Python scripting. For each extension, the global variable ExtAPI gives access to the
property DataModel. This property returns the object IDataModel, which has properties that return
all high-level interfaces available for customizations. The complete list of member interfaces is given
in the ANSYS ACT API Reference Guide.
Each ANSYS product can leverage its own scripting language and define unique object API. ACT
minimizes inconsistency and confusion introduced by product-specific syntax by providing its own
Automation API. Automation objects and methods wrap underlying product API by re-exposing user-
facing features in a clear and consistent syntax. Instead of piecemeal script statements for cross-
product customization, you can program with one ACT language.
You typically engage automation-level objects when issuing commands inside the console or invoking
ExtAPI.DataModel members. You can confirm automation API usage by executing a variable
name in the console. If the returned string starts with Ansys.ACT.*.Automation., you are
working with the automation API. ACT substitutes the appropriate product name in place of the as-
terisk (such as Ansys.ACT.WorkBench.Automation.).
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 51
ACT Tools
In Workbench:
You can open the console in one of two ways:
• On the ACT Start Page, click the ACT Console button in the toolbar.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
52 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT Console
In DesignModeler:
You can open and close the console by clicking the first button in the ACT Development toolbar. This
toolbar is available only when debug mode is enabled. For more information, see Debug Mode (p. 165).
In Mechanical:
You can open and close the Mechanical Scripting view from the ribbon's Automation tab. In the
Mechanical group, clicking Scripting switches between opening and closing this view. For more inform-
ation on using the Mechanical Scripting view, see Scripting Introduction in the Scripting in Mechanical
Guide.
Note:
You can revert to the ACT Console by changing the scripting view preference
under File > Options > Mechanical > UI Options > New Scripting UI. Mechanical
must be restarted to see the scripting view change.
The console provides smart autocompletion (p. 56), which means that syntax elements such as
brackets or quotations marks are taken into account.
You use the following key combinations to insert new lines and execute commands:
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 53
ACT Tools
Additional keyboard shortcuts are described in Using Console Keyboard Shortcuts (p. 64).
History Color-Coding
In a command history entry, you identify the type of each item by its text color:
Additional keyboard shortcuts are described in Using Console Keyboard Shortcuts (p. 64).
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
54 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT Console
9. Show hidden icons (visible only when the ACT Console window is not wide enough to display all icons
in the toolbar).
History Search
When you click the search toolbar button ( ) to search the command history, a reverse search is
performed using the text currently entered in the command line. The following figure shows five ex-
ecuted commands and command entered in the command line.
To start the search, either click the search toolbar button ( ) or press Ctrl + R. A search box appears
to the right of the command line. Besides displaying the current search string, the search box provides
buttons for stepping backward and forward through the command history entries and a button
for closing the search box. When the search starts, it immediately steps backward through the
command history, stopping when it finds an entry with a match. In this example, the search stops
when it finds command5 = 5, displaying this entry in the command line. If you wanted to execute
this command again, you would press Enter.
To resume the reverse search, you either press Ctrl + R or click the up arrow button for the search
box. To change the search direction to step forward rather than backward in the history, you either
press Ctrl + Shift + R or click the down arrow button for the search box. To clear the search string,
you click the button with the small X to the right of the search string.
As long as the result in the command line matches the current search string, no change occurs. When
the result no longer matches the search string, the search automatically steps backward to find the
next match. Assume that you enter command2 as the search string. Because command5 = 5 no
longer matches command2, the search steps back through the command entries to find a match,
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 55
ACT Tools
displaying command2 = 2 in the command line. Now assume that you enter command21 as the
search string. The search box turns red because no match exists in the command history.
If you enter command as the search string once again, the search box is no longer red. Because
command2 = 2 still matches the current search string, it remains displayed in the command line.
If the search reaches the end of the history without finding a match, it wraps around to the beginning
of the command history. When you finish searching, you click the close button for the search box.
• Add snippet: Add the command text to the Snippets panel. For more information, see Using Snip-
pets (p. 59).
• Replay: Paste the command text into the command line so that it can be executed again later.
Using Autocompletion
As you type in the command line, a scrollable list of suggestions displays above the command line.
Each suggestion has an icon with a letter and color-coding to indicate the type of suggestion. A letter
in a square icon describes the type of the member in the suggestion list. A letter in a circle icon de-
scribes the nature of the return type.
Listed alphabetically are types of members, which are shown in square icons:
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
56 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT Console
• E = Enumeration
• M = Method
• N = Namespace
• P = Property
• S = Snippet
• T = Type
• V = Variable
Once a member is selected, the nature of the return types available for this member are shown in
circle icons. Listed alphabetically are return types:
• C = Class
• E = Enumeration
• F = Field
• I = Interface
• S = Structure
Note:
No icon displays for primitive types (such as integer, Boolean, or string) or if no sug-
gestion is returned.
• green = accessibility
• purple = type
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 57
ACT Tools
• orange = warning
• blue = arguments
Properties:
Methods:
• Scope variables (accessed by pressing Ctrl + space when no defined symbol appears under the text
cursor).
• Prototype information for methods when cursor is inside brackets and indexers when cursor is inside
square brackets.
– Prototypes for overloaded methods (accessed by pressing the arrows in the prototype tooltip).
– Members for overloaded methods. (The tooltip for an overloaded method is a list of all members
from all overloaded methods.)
The following images show examples of two different tooltips for the method Equals in two dif-
ferent stages of using autocompletion.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
58 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT Console
. ( ) [ ] { } ‘ “ # , ; : ! /
= ?
For available keyboard shortcuts, see Using Console Keyboard Shortcuts (p. 64).
Using Snippets
Snippets are existing lines of code that you can quickly and easily insert in the command line, saving
you from repetitive typing. As you use the console, you can insert any of the snippets that ANSYS
supplies for ACT-specific commands. Additionally, you can begin building your own library of snippets
to either supplement or replace supplied snippets.
• The snippet ExtAPI inserts ExtAPI. in the command line, providing you with immediate access to the
API. From the autocomplete options in the tooltip, you can then begin selecting additional attributes to
build your command.
• The snippet Snippet Template provides sample code for swapping two variables. The comments explain
how a snippet can contain editable fields, which are automatically selected for modification when the
snippet is inserted. When a field is selected, you can type a new value to override the default value or let
the default value remain. Pressing the Tab key moves the cursor to the next editable field.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 59
ACT Tools
If you know the name of a snippet, you can begin typing the name to find it in the list of suggestions.
The supplied Snippet Template provides code for swapping two variables.
When a snippet selected, you can easily see all editable fields in the command line.
For example, in Snippet Template, the first editable field (foo) is highlighted.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
60 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT Console
Typing something changes the foo value to whatever you type (value1). Notice that both foo
values change to value1 in one operation.
Pressing the Tab key moves the cursor to the next editable field, causing bar to be highlighted.
Typing something changes the bar value to whatever you type (value2). Notice that both bar
values change to value2 in one operation.
To define an editable field, you must use the following notation: ${#:#}, where # is the index of
the field. For the first editable field, the value is 1. To reference an editable field that is already defined,
you simply need to specify its index (${#}) as shown in the following figure for the snippet Geometry.
For the previous example for swapping two variables, you can define the following snippet:
temp = ${1:foo}
${1} = ${2:bar}
${2} = temp
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 61
ACT Tools
the supplied Snippet Template for swapping two variables, but it does not display the snippet
lambda for this basic Python command.
In the Snippets panel, you can click a snippet to insert it in the command line.
Note:
When typing in the command line, autocompletion displays all snippets in the Snippet
panel as well as snippets for basic Python commands.
To make creating and managing snippets easy, the console panel provides toolbar bars and a context
menu.
5. Show hidden icons (visible only when the console window is not wide enough to display all icons
in the toolbar).
Context Menu
• Click the button with the three dots to the right of an entry in the command history and select Add
snippet.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
62 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT Console
• Right-click a snippet or folder in the Snippets panel and select Add Snippet or Add Folder. Where
you right-click determines where the new snippet or new folder is placed in the Snippets panel.
– When you right-click a folder, the new item is created inside this folder.
– When you right-click a snippet, the new item is created at the bottom of the containing folder.
Once the snippet or folder is created, the Snippet Properties dialog box opens so that you can
specify properties. A snippet has two properties, Caption and Value. A folder has only Caption.
• Caption specifies the text to display as the name for the snippet or folder.
• Value specifies the code that the snippet is to insert in the command line. When a snippet is created
from an entry in the command history, Value displays the code for this entry by default.
After specifying the properties for the snippet or folder, you click Apply to save your changes or
Cancel to discard the newly created snippet or folder.
Caution:
If you delete a folder, all of its contents are also deleted. Deleting a snippet from the
Snippets panel also removes it from the list of suggestions for autocompletion.
• Clicking the toolbar button for importing a snippets collection ( ) appends the snippets in the se-
lected XML file to the list already shown in the Snippets panel.
• Clicking the toolbar button for exporting a snippets collection ( ) exports all snippets in the Snippets
panel to the specified XML file.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 63
ACT Tools
The following figure an XML file created from the export of a snippets collection.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
64 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT Console
Key Action
Combination
Alt + Backspace Remove to line
end
Alt + Delete Remove to line
start
Ctrl + Delete Remove word left
Ctrl + Backspace Remove word
right
Selection Shortcuts
Key Action
Combination
Ctrl + A
Shift + ← Select all
Shift + → Select left
Ctrl + Shift + ← Select right
Ctrl + Shift + → Select word left
Shift + Home Select word right
Shift + End Select line start
Alt + Shift + → Select line end
Alt + Shift + ← Select to line end
Shift + ↑ Select to line
start
Shift + ↓ Select up
Shift + Page Up Select down
Shift + Page Select page up
Down
Ctrl + Shift + Select page
Home down
Ctrl + Shift + End Select to start
Ctrl + Shift + D Select to end
Ctrl + Shift + P Duplicate
selection
Multi-Cursor Shortcuts
Key Combination Action
Ctrl + Alt + ↑ Add multi-cursor above
Ctrl + Alt + ↓ Add multi-cursor below
Ctrl + Alt + → Add next occurrence to multi-selection
Ctrl + Alt + ← Add previous occurrence to multi-selection
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 65
ACT Tools
Go-To Shortcuts
Key Action
Combination
Page Up Go to page up
Page Down Go to page down
Ctrl + Home Go to start
Ctrl + End Go to end
Ctrl + L Go to line
Ctrl + P Go to matching
bracket
Folding Shortcuts
Key Combination Action
Alt + L, Ctrl + F1 Fold
selection
Alt + Shift + L, Ctrl + Shift + Unfold
F1
Other Shortcuts
Key Combination Action
Tab Indent
Shift + Tab Outdent
Ctrl + Z Undo
Ctrl + Shift + Y, Ctrl + Redo
Y
Ctrl + T Transpose letters
Ctrl + Shift + U Change to lower-case
Ctrl + U Change to upper-case
Insert Overwrite
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
66 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT Console
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 67
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
68 of ANSYS, Inc. and its subsidiaries and affiliates.
Extensions
Extension development consists of creating the scripted extension. During development, enabling debug
mode (p. 165) is recommended.
Once you finish developing and debugging a scripted extension, you can use the binary extension
builder (p. 46) to compile into a binary extension for sharing with others. You cannot view or edit the
contents of a binary extension.
Extensions cannot be executed until you use the Extension Manager (p. 39) to install and load them.
For information on installing and loading both scripted extensions and binary extensions, see Installing
and Uninstalling Extensions (p. 42) and Loading and Unloading Extensions (p. 44).
Note:
• An ACT license is required to create scripted extensions and build binary extensions. However,
an ACT license is not required to execute binary extensions. For more information, see Licens-
ing (p. 12).
• ACT can manage an entire set of extensions for different ANSY products. When an extension
targets multiple products, it loads the features applicable to the running product. If the end user
engages another target product, only customizations specific to that product are available.
• Once you save a project in which one or more extensions is loaded, any further use of the project
requires the same extensions to be available. If the extensions are found, Workbench loads them
automatically when the project is opened. If the extensions are not found, an error message
displays. For more information about controlling the available of extensions, see Extension
Configuration (p. 76).
• When importing a project into an active Workbench session, ACT merges attribute data from
saved extensions. However, the project import operation will fail if same-named attributes exist
in identical extensions from both the incoming and active projects. Workbench will report the
collision error, abandon the import, and restore the original active project.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 69
Extensions
Extension Definition
An ACT scripted extension has two basic components:
• XML extension definition file: Defines and configures the content of the extension using XML ele-
ments (p. 181). Each element has a set of required and optional attributes. The element <callbacks>
specifies the functions or methods that the extension is to invoke from all those defined in the extension's
IronPython script. While you can create the XML file manually, the ACT App Builder (p. 92) automates its
creation.
• IronPython script: Defines the functions invoked by user interactions and implements the extension's be-
havior. The content of the script is not case-sensitive. You can debug the script by entering commands in
the ACT Console (p. 50) or taking advantage of the ACT Debugger (p. 166).
Note:
You use the IronPython language to develop the functions that the extension executes.
Comprehensive information about IronPython is available at IronPython.net , including doc-
umentation. Additionally, obtaining a copy of David Beazley's book, Python Essential Reference,
is highly recommended. This book is considered the definitive reference guide on the Python
language.
For script examples, you have supplied extensions and templates (p. 78) that you can
download. Additionally, you can log into the ANSYS customer site and search solutions using
the following filter selections:
To further limit the solutions shown, you can use the search box at the top of the page.
In addition to the XML file and at least one IronPython script, an extension can include supporting files,
such as image files, custom wizard help files (p. 158), input files, and installed IronPython function libraries
and C# assemblies (p. 112).
While the content in the XML file and the script depend on the ANSYS product that is being customized,
the need for these two basic components remains consistent.
The following topics describe how to create a very simple extension named ExtSample1:
Creating the Extension Definition File
Creating the IronPython Script
Setting Up the Directory Structure
Viewing Exposed Custom Functionality
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
70 of ANSYS, Inc. and its subsidiaries and affiliates.
Extension Definition
The XML file for an extension always begins with the element <extension>. All other elements are
children to this base tag or root node. For descriptions of basic elements, see Appendix A: Extension
Elements (p. 181). For descriptions of all elements, see the ANSYS ACT XML Reference Guide.
In this extension, the element <entry> defines the single toolbar button. The file hand.bmp provides
the image to use as the icon. The callback <onclick> defines the name of the function to invoke
when the button is clicked. The next section addresses the script defined for the function HighFi-
veOut.
Note:
• For images to display as toolbar buttons or next to menu commands, Mechanical requires
BMP files. Workbench and all other ANSYS products require PNG files.
• To designate a transparent background for a BMP file, in an image editor, set the back-
ground color to 192, 192, 192 and then save the file with 256 colors.
def init(context):
ExtAPI.Log.WriteMessage("Init ExtSample1...")
def HighFiveOut(analysis_obj):
MessageBox.Show("High five! ExtSample1 is a success!")
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 71
Extensions
• init(): Called when the ANSYS product is opened. In the XML file, the argument context for the element
<interface> contains the name of the product ("Mechanical").
• HighFiveOut(): Called when the toolbar button HighFive is clicked. The callback <onclick> passes
an instance of the active object Analysis as an argument.
For any function, the global variable ExtAPI represents the main entry point to the ACT API (p. 51).
In this example, the function init() uses the ACT interface ILog to write a message in the log file.
For comprehensive information on available interfaces, see the ANSYS ACT API Reference Guide.
The following figure shows the top-level directory structure for the extension ExtSample1. You can
see that the extension's XML file and its folder are both named ExtSample1.
• The script sample1.py contains the code that implements the extension's behavior. By default, ACT
looks for the script in the directory of the extension. If the script is located in a different directory, in the
XML file, the element <script> must specify an explicit path to the script.
• The folder images contains the one or more image files to display as icons in the interface of this extension.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
72 of ANSYS, Inc. and its subsidiaries and affiliates.
Extension Definition
The following figure shows the contents of the folder images. The image file hand.bmp displays
as the icon for the custom button that is exposed on the tab for this extension when it is loaded in
Mechanical.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 73
Extensions
1. Create four Portable Network Graphics (PNG) files of your icon in these specific pixel sizes: 16x16,
24x24, 32x32, and 48x48.
icon_yourIconName_sizeAxsizeA.png
For example, assume that you specify "myIcon" as the icon attribute value in your extension
XML file:
• icon_myIcon_16x16.png
• icon_myIcon_24x24.png
• icon_myIcon_32x32.png
• icon_myIcon_48x48.png
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
74 of ANSYS, Inc. and its subsidiaries and affiliates.
Extension Definition
3. Store all four icon files in your extension's original images folder.
Note:
• You can use your preferred image manipulation tool to create the four PNG files in the
required pixel sizes. Using the functionality for scaling an image, start with the maximum
resolution (64x64 pixels) and work down to the minimum resolution (16x16 pixels), export-
ing a new image after each re-scale operation.
• Tree object icons continue to use the bitmap image format in the 16x16 pixel size. You
do not need to update these icons for existing extensions. In the XML file for a new exten-
sion, you specify the entire name (without the .bmp extension), just as you did before
the ribbon UI change.
Clicking the High Five button on this tab executes the extension, which opens this dialog box:
The following figure shows the Extensions Log File. It indicates that the extension ExtSample1 is
loaded for the context Project.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 75
Extensions
In Mechanical, if debug mode is enabled, you can open this file from the ACT Development group
on the Automation tab. Clicking View Log switches between opening and closing the Extensions
Log File.
Extension Configuration
You select Tools → Options → Extensions to configure ACT extension options.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
76 of ANSYS, Inc. and its subsidiaries and affiliates.
Extension Configuration
Folders that you define here are added to your ApplicationData folder: %APPDATA%\An-
sys\v201\ACT\extensions.
Because these folders are searched for extensions by default, the Extension Manager (p. 39) displays
any extensions located in them.
Note:
The default folders are not searched recursively. Because extensions stored in subdirectories
are not found, store your extensions at the top level of the directory.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 77
Extensions
During this process, warning messages are returned for any conflicts. These messages are logged in
the Extensions Log File (p. 45).
Note:
The Additional Extension Folders option is also available when you click the gear
icon in the graphic-based Extension Manager (p. 39).
• Never (default): The currently loaded extensions are not saved within the project.
• Copied but locked to the project: Extensions are saved within the project but are limited to only
this project.
• Always: The extensions are saved within the project and no restrictions exist as to their use in other
projects. This option represents what is generally expected when the project is saved. However, the
behavior depends on the security option that was selected when the binary extension was built. For
more information, see Binary Extension Builder (p. 46). In particular, the following scenarios can occur:
– The extension was built with the security option set to Can't copy extension to project. If the
save option is set to Always or Copied but locked to the project, the security option has the
priority. The extension is not saved within the project.
– The extension was built with the security option set to Can copy extension to project but locked
to this one. If the save option is set to Always, it does not impose any restriction on the extension.
However, the security level limits the use of the extension to only the given project.
Note:
The Debug Mode option is also available when you click the gear icon in the graphic-
based Extension Manager (p. 39).
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
78 of ANSYS, Inc. and its subsidiaries and affiliates.
Extension and Template Examples
Download Information
You can easily download the extension and template packages from the help panel for the ACT Start
Page (p. 37):
• To download the package of extension examples, click Extension Examples under Downloadable
Examples.
• To download template packages, click the links for the packages that you want to download under
Downloadable Examples.
Note:
On the ANSYS Store, the App Developer Resources page provides for downloading these
packages from links on the Help & Support and ACT Templates tabs.
After unzipping a package, you can install and load the extensions that they contain if you have an ACT
license. For more information, see Installing and Uninstalling Scripted Extensions (p. 42).
If you want, you can import any existing extension into the ACT App Builder (p. 92) to see and edit its
files in a visual environment.
Supplied Extensions
The package of extension examples contains the many extensions that the ACT documentation refer-
ences. This table describes these extensions and provides links to where they are explained in the
ACT documentation. For an extension specific to an ANSYS product, the referenced topic is in the
ACT customization guide for the particular product. For download information, see the previous
topic.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 79
Extensions
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
80 of ANSYS, Inc. and its subsidiaries and affiliates.
Extension and Template Examples
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 81
Extensions
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
82 of ANSYS, Inc. and its subsidiaries and affiliates.
Extension and Template Examples
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 83
Extensions
Supplied Templates
Descriptions follow for the extensions in supplied template packages:
ACT Templates for DesignModeler
ACT Templates for DesignXplorer
ACT Templates for Mechanical
ACT Wizard Templates
ACT Workflow Templates
For download information, see Extension and Template Examples (p. 78).
Folder Description
DM_Template1-SelectionManager Shows how to add toolbar items to DesignModeler, access
model entities, generate criteria-based entity listings, and
interact with the Selection Manager by adding entities to
it.
DM_Template2-PropertyGroup Shows how to add toolbar items to DesignModeler, add
custom objects to the tree, add properties and property
groups to a custom tree object, access custom object
property values from Python, and create basic primitives
from defined details.
DM_Template3-PolyExtrude Shows how to add toolbar items to DesignModeler, add
custom objects to the tree, access custom object property
values from Python, create a polygon using provided details,
use the created polygon for extrude and resolve operations,
and unite the create bodies to form a single-body object.
DM_Template4-ParametricPrimitive Shows how to how to add toolbar items to DesignModeler,
use the attribute isparameter to promote properties as
DesignModeler design parameters, access property values
from Python, and create a box primitive object.
Folder Description
CppOptimizer Shows how to implement an extension from existing C/C++ code. The interface
IOptimizationMethod is implemented in IronPython as a wrapper to the
C++ symbols, using the ctypes foreign function library for Python.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
84 of ANSYS, Inc. and its subsidiaries and affiliates.
Extension and Template Examples
Folder Description
CSharpOptimizer Show how to set up an optimization extension when the interface IOptimiz-
ationMethod is implemented in C#. While the optimization algorithm is also
implemented in C#, you could use only the implementation IOptimization-
Method as an adapter to an existing implementation in C# or another language.
A Microsoft Visual Studio 2010 project is provided.
CSharpSampling Shows how to set up a sampling extension when the interfaceISampling-
Method is implemented in C#. While the optimization algorithm is also
implemented in C#, you could use only the implementation ISamplingMeth-
od as an adapter to an existing implementation in C# or another language. A
Microsoft Visual Studio 2010 project is provided.
PythonOptimizer Shows how to define optimization features in an extension using IronPython.
This example runs a simple random exploration of the parametric space,
generating the requested number of points and returning the best candidates
identified. Fully implemented in IronPython (no build required), this example
is your sandbox. It demonstrates many optimization extension features and is
the best example to start with. PythonOptimizer is running a simple random
exploration of the parametric space, generating the number of points requested
by the user and returning the best candidates found.
PythonSampling Shows how to define sampling features in an extension using IronPython. This
example runs a simple random exploration of the parametric space, generating
the requested number of points. Fully implemented in IronPython (no build
required), this example is your sandbox. It demonstrates many sampling
extension features and is definitely the best example to start with. Python-
Sampling is running a simple random exploration of the parametric space,
generating the requested number of points.
Folder Description
Template1-APDLMacroEncapsulation Shows how to encapsulate an APDL macro within one ACT
load object.
Template2-GenericObjectionCreation Shows how to implement ACT generic objects in the model
tree above analyses and how to implement an object that
does not affect the solution state.
Template3-TabularData Shows how to implement an ACT property with tabular
data.
Template4-CustomUnit Shows how to implement an ACT load with a property
having a non-standard unit.
Template5-ExternalSolve Shows how to implement an ACT result that executes an
APDL macro on an external ANSYS solver process.
Template6-GenericPostObject Shows how to implement ACT generic objects in the
solution tree of the analyses.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 85
Extensions
Folder Description
Template7-PullDownMenus Shows how to implement an ACT load with properties
having pull-down menus.
Template8-TargetedAnalysisLoad Shows how to implement an ACT load that is valid for the
following simulation types: Static Structural, Modal, and
Thermal.
Template9-Attributes Shows how to use ACT attributes to save persistent data.
Template10-Graphics Shows how to implement graphics features in an ACT
extension.
Template11-Table_n_Graph Shows how to implement a table and graph object using
existing panes in Mechanical.
Template12-BodyView Shows how to implement objects that show single-body
and double-body views.
Template13-SolverBypass Shows how to implement a solver that will allow native
loads under it to have custom functions for property values
where functions are applicable, and how to access those
functions in the <OnSolve> callback.
Folder Description
Template-DesignModelerWizard Shows how to create a target product wizard for
DesignModeler. This wizard creates a geometry.
Template-ElectronicsDesktopWizard Shows how to create a target product wizard for Electronics
Desktop. This wizard displays a list of available projects or
designs and creates a cube.
Template-MechanicalWizard Shows how to create a target product wizard for Mechanical.
This wizard create the mesh for the geometry, adds
boundary conditions, and then solves and displays a result.
Template-MixedWizard Shows how to create a mixed wizard for multiple contexts.
This wizard creates a static structural system, opens either
DesignModeler or SpaceClaim, and creates a geometry (a
cube). It then opens Mechanical, creates the mesh, defines
the boundary conditions, and displays the maximal
deformation.
Template-ProjectSchematicWizard Shows how to create a project wizard for the Workbench
Project tab. This wizard shows all the property capabilities
for ACT. It also show how to include reports and charts.
Templates-FluentWizard Shows how to create target product wizards for importing
MSH and CAS files into Fluent. The extension FluentDemo1
shows how to import a MSH file. The extension Fluent-
Demo2 shows how to create a CAS file. After the import,
both extensions show how to run a simple analysis,
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
86 of ANSYS, Inc. and its subsidiaries and affiliates.
Extension and Template Examples
Folder Description
generates results, and display the results in a customized
panel in Fluent. For more information, see Fluent Wizard
(MSH Input File) and Fluent Wizard (CAS Input File).
Template-SpaceClaimWizard Shows how to create a target product wizard for SpaceClaim.
This wizard shows all the property capabilities for ACT. It
also show how to include reports and charts.
Folder Description
CaptionChanger Shows the dynamic update of task group captions.
CommandCancellation Shows how to cancel a command from script.
Connections Shows the filtering of connections with downstream target tasks. The
general transfer type supports connectivity with Model, Setup, and
Solution cells. Here, Setup and Solution connections are blocked,
allowing only the Model connection to be established.
CSharp Shows a simple workflow-based app that is coded using C#.
CustomCFD Shows two custom CFD-based workflow task groups that mimic the
integration of external processes. The final connection links the workflow
with CFX.
CustomContextMenu Shows the creation, registration, and filtering of a custom context menu.
The menu appears when the right mouse button is clicked on a Model
task of any ANSYS-based analysis system.
CustomContextMenu2 Shows the creation, registration, and filtering of a custom context menu
on a custom task.
CustomGeometry Shows a custom CAD generation process integrated into Workbench.
The geometry can then be passed into a downstream system for
simulation setup and analysis.
CustomLoad Shows the dual-work of a workflow extension (to interact with
Workbench) and Mechanical extension (to operate on your behalf inside
Mechanical). This example could form the basis of custom external load
processing.
CustomPropertyAction Shows the customization of an existing property. It changes the property
into a button-based, dialog box retrieval of the property value.
CustomStructural Shows a custom workflow-based analysis system (task group) that re-uses
existing Mechanical-based tasks.
CustomTab Shows the creation of a custom project tab in Workbench. You can set
the tab control to a control provided by the UI Toolkit. For example, you
can set the control to a web page viewer. The supplied IronPython script
shows a custom view with HTML content.
CustomTab2 Shows the creation of a custom project tab in Workbench. You can set
the tab control to a control provided by the UI Toolkit. For example, you
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 87
Extensions
Folder Description
can set the control to a web page viewer. The supplied IronPython script
shows the re-use of built-in and custom views in a custom pane and
displays only the parameters associated with the edited task. Each task
has its own custom tab. Switching between tabs shows unique data
loaded for each task tab.
CustomTransfer Shows the transfer of data between two custom tasks using custom
input and output data types.
DataSquares Shows a simple data-integrated external processor as a custom task
group having one task.
DemonstrationSovler Shows a custom solver integrated using ACT. It also shows how to use
an upstream custom task to provide custom data over ACT's general
transfer mechanism. A toolbar button inside Mechanical displays the
custom data retrieved from the upstream task.
Dictionary Shows dictionary use for a task property.
DynamicContextMenus Shows the creation, registration, and filtering of dynamic custom context
menus on a custom task.
DynamicParameters Shows how to dynamically create parameters from a context menu
exposed from a task.
EmbeddedEXE Shows how to embed an external application inside a Workbench pane.
Events Shows framework event processing inside an empty extension.
GenericMeshTransfer Shows a custom workflow that passes an upstream mesh to a
downstream consumer. This could be a mesh-morphing integration.
GenericTransfer Shows the use of ACT's generic transfer capability between two custom
components. It uses the TransferData data store from which to push
and pull data.
ImportedLoad Shows an imported load being read from external files into an ACT task
and fed into a Mechanical-based analysis Setup task. The behavior
leverages external data-like behavior and relies on one of the
already-supported external load types for boundary conditions. For
custom types, see the CustomLoad template.
InputGroups Shows consuming from more than one type of source. The custom task
can consume from a Mechanical-based Solution cell and a Fluent-based
Solution cell.
LicenseCheck Shows ANSYS license API invocation from a toolbar button.
ObjectTest Shows how you can use custom classes as property types on tasks. ACT
relies on serialization support to persist property values. At the same
time, Workbench relies on spec-based metadata to properly save its
projects. Combining the two requires a little coding finesse and the need
to use C# to describe the custom class definition. This is an advanced
example to be used only in projects that must use custom property
types.
Parameters Shows the Workbench integration of a custom optimizer via a parametric
task group.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
88 of ANSYS, Inc. and its subsidiaries and affiliates.
ANSYS Store Extensions
Folder Description
PasswordProperty Shows the customization of an existing property. You change the
property into a button-based, dialog setting/retrieval of the property
value to display a masked password task propertyS=.
Progress Shows progress monitor API interaction to display messages during
updates to Workbench's Progress pane.
ProjectPruner Shows a toolbar button that allows users to select "keep" systems and
delete all remaining in the project.
Properties Shows task-based property manipulation for selection-based properties.
PythonModules Shows a Python module-only load to access custom modules from the
console or script.
Quantity Show all possible declarations for task-defined quantity-based properties.
RSTProcessor Shows a custom task that consumes from an upstream ANSYS analysis
solution task. Possible uses include custom postprocessing of the results
from the generated RST file.
SaveAsHandler Shows how to detect "save-as" events inside Workbench.
SDKWrapper Shows the wrapping of an SDK integration with an ACT extension for
ANSYS App Store distribution.
Squares Shows a simple external-connection-like integration of a parameters-only
process-oriented task group.
TaskColonizer Shows custom task background color selection via a custom context
menu. The menu appears when your right-click any task in the
Workbench Project Schematic. Color data is stored within the extension.
TaskGroup Shows the most basic workflow implementation. The single-task task
group has one callback (update), no properties, and no connections.
ToolBar Shows custom Workbench toolbar buttons. Workbench does not support
toolbar captioning. A no-operation, empty entry is used to display a
caption.
The ANSYS Store provides both free and paid apps developed by ANSYS and trusted partners. While
you are required to request a quote for a paid app for offline fulfilment, you only need to log in to
download a free app. The ANSYS Store supports filtering apps based on target application, product
version, and price.
Download free apps for your licensed ANSYS products to witness firsthand how sophisticated ACT ex-
tensions can be. If an app description concludes with [Contains source code], the downloaded app
includes a directory containing the extension's XML definition file and IronPython scripts. You can view
and even copy code from these files into the files for your own custom ACT extensions.
For your convenience, the following table lists free apps that provide source code. The ANSYS Store
indicates the ANSYS product versions in which an app is supported.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 89
Extensions
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
90 of ANSYS, Inc. and its subsidiaries and affiliates.
ANSYS Store Extensions
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 91
Extensions
Note:
• From the ACT Start Page (p. 37), click Open App Builder in the toolbar.
You can also start the ACT App Builder from AIM. For more information, see ACT App Builder Access
in the ACT Customization Guide for Discovery AIM.
Home Page
When the ACT App Builder starts, the Home page displays all app builder projects that you have
created. An app builder project is a compressed file with an ACTPJ extension.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
92 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT App Builder
In the upper left corner of all ACT App Builder pages, the toolbar (p. 93) displays buttons for
performing various actions. Under the toolbar, the navigation menu displays Home to indicate that
you are currently on the initial page, where you can open (p. 95) or create (p. 96) an app builder
project or import (p. 102) an ACT extension into an app builder project.
As your projects grow in number, you can use the sort and search capabilities (p. 95) near the top
of the page to quickly find a particular project. On any page, you can click the help icon to
display an overview and relevant workflow information.
Button Action
Create (p. 96) a new app builder project.
Import (p. 102) an ACT extension into a new app builder project.
Upload (p. 102) the temporary extension for the active app builder project into the ANSYS
product for which it is being created so that you can test what has been created so far.
Save the app builder project to a specified folder to which you can write. When you click
this button, the changes that you have made in the ACT App Builder are saved to the ACTPJ
file. If you take an action that might result in losing changes, the ACT App Builder warns
that you did not save your changes. You can then choose whether to save or discard changes.
Export (p. 105) the app builder project to a scripted ACT extension, thereby creating the XML
extension definition file and IronPython script that makes up the extension.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 93
Extensions
Button Action
Open the binary extension builder (p. 46) so that you can save the app builder project as an
extension in the binary format (WBEX file).
Open the ACT Console (p. 50) in the active ANSYS product so that you can test and debug
commands in your IronPython scripts.
Open the Extensions Log File (p. 45) so that you can see all information that has been written
to this file.
Toggles between showing the XML editor (p. 106) and ACT App Builder. In the XML editor,
you can view and modify all XML elements rather than just the basic elements displayed in
the ACT App Builder.
or
Toggles between showing the resource manager (p. 108) and ACT App Builder. In the resource
manager, you can view and manage the files in your ACT extension.
or
Two additional buttons appear to the right of the ACT App Builder toolbar.
• Clicking the first button displays the app builder log. The green check mark is shown if no errors
or warnings exist. A red circle or yellow triangle with an exclamation point is shown if an error or
warning occurs. You can click this button at any time to see all information that has been written
to the app builder log. In the upper right corner of the log, the sweep button provides for clearing
the existing log content.
• Clicking the second button displays settings. The Advanced Capabilities check box is for turning
on and off more complex entities of the ACT App Builder that are not yet visible in this version.
The Advanced XML Editor check box is for turning on and off the display of additional non-pub-
lished attributes in the XML editor. The Language option is for selecting the language for the user
interface. After making a change, a notification displays in the newly selected language, indicating
that you must restart the ACT App Builder for the language change to take full effect.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
94 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT App Builder
To return to a previous page in the process, you simply click the link for the page. For example,
after adding a wizard, you might need to go back to the page from which you added it so that you
can you can either edit it or add another wizard. For more information, see Editing App Builder
Entities (p. 101). To move to the next page in the process, you either click the block itself or the link
for the next page in the navigation menu.
You can also quickly locate a particular app builder project by typing text into the Search App
Builder Projects option. Sort and search options display on the Home page and on the second
page, where you add ANSYS products to the app builder project.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 95
Extensions
• On the Home page, locate the app builder project and click its block.
• In the toolbar, click the button for opening an app builder project and then use the file browser
to navigate to and select the existing project.
When the app builder project opens, you can use the navigation menu (p. 95) to move to the
various pages in the creation process.
• In the toolbar, click the button for creating a new app builder project .
2. In the New Project window, supply the name and destination folder for the app builder project.
The name of the app builder project cannot contain spaces or certain characters and must
be unique. The destination folder can be any folder to which you can write.
3. Click OK.
In the navigation menu (p. 95), the name of your newly created app builder project displays as the
name of the second page. You can now configure the app builder project.
1. Click the Add Product block. The Add Product window opens.
2. For Product, select the product for which you will be creating one or more wizards.
For example, select Mechanical if you will be creating a wizard that is to run from Mechanical.
3. Click OK.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
96 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT App Builder
In the navigation menu (p. 95), the name of the selected product displays as the name of the third
page. You can now add the ACT wizards that are to run from this product.
Note:
In AIM, ACT wizards are implemented as custom templates, guided simulations, and
guided setups. For more information, see AIM Product Wizards in the ACT Customization
Guide for Discovery AIM. For the sake of consistency, this document uses the term wizard
throughout.
Adding Wizards
On the third page of the ACT App Builder, you add the wizards that are to run from the previously
selected ANSYS product. While the ACT App Builder currently supports only the wizard product
feature, you can open the XML editor (p. 106) to view and add other features such as custom inter-
faces for non-AIM wizards.
1. Click the New Wizard block. The New Wizard window opens.
2. Supply the name, label, number of steps, and the icon to display.
By default, the label is the name that you specify for the wizard.
3. If this wizard is for AIM and you want it to be a guided simulation, select the Guided simulation
check box. This check box is visible only when AIM was select as the product on the previous ACT
App Builder page.
All data supplied in a guided simulation is saved and restored each time the guided simu-
lation is started. For more information, see Guided Simulations in the ACT Customization
Guide for Discovery AIM.
4. Click OK.
In the navigation menu (p. 95), the name of the wizard displays as the name of the fourth page.
You can now define each of the steps for this new wizard by adding properties and callbacks.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 97
Extensions
This page has a step map for step creation and navigation in the upper left corner. It also has two
panes for step definition: Properties and Callback. Clicking the help icons for each of these panes
displays an overview and relevant workflow information.
• The step map provides buttons for navigating to existing steps and for inserting a new step.
Clicking a button for an existing step displays its properties and callbacks. Clicking the plus sign
button allows you to insert a new step after the existing step that you specify.
If you have first used the resource manager (p. 108) to import a folder with HTML files to use
for custom help, for HelpFile, you can select the file that is to display for the step. All HTML
files in the imported help folder are available for selection.
These files typically contain content that explain how to complete the steps. For more in-
formation, see Custom Wizard Help Files (p. 158).
In the XML editor (p. 106), you can also always use the optional attribute helpfile to assign
HTML files to steps.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
98 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT App Builder
When you right-click a step in the step map, you can select a button for either editing or
deleting the step.
• The Properties pane displays a toolbar for defining the properties (p. 99) that the step uses.
• The Callback pane provides for defining the callbacks (p. 100) for the step. You typically use the
Record tab to capture in a journal the actions that you take in the associated product. On the Code
tab, you then view and edit the IronPython code recorded for callbacks to replace arguments with
properties.
Tip:
For convenience, you can click a property in the toolbar and then drag and drop it
into a particular location in the Properties pane. Additionally, you can drag and drop
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 99
Extensions
properties within this pane to rearrange them in the order in which you want them
to display in the wizard.
In the main toolbar, clicking the button for uploading the temporary extension for the app
builder project allows you to see the newly added properties when the wizard is loaded in
the ANSYS product. For more information, see Testing Temporary Extensions (p. 102).
Descriptions follow for all attributes that can possibly display for properties. The product with
which a wizard is associated determines which toolbar buttons for properties display.
Attribute Description
Group Name to assign to the property group. This property displays only for a group
name property, which is not applicable to an AIM wizard.
Group Text to display for the property group in the wizard step. This property displays
label only for a slider property, which is not applicable to an AIM wizard.
Property Name to assign to the property.
name
Property Text to display for the property in the wizard step.
label
Default Value to use if no value is entered or selected when this step of the wizard is run.
value For a property that opens a folder or file, click Browse to navigate to and select
the desired folder or file.
Help Help text to display for the property. This attribute provides for easily defining the
help text for a property directly in the XML file. You can also choose to define
property-level help in HTML files. For more information, see Custom Wizard Help
Files (p. 158).
Options List of values to display for a selection-based property. This property displays only
for select, multiselect, and radio button properties. The radio button property is not
applicable to an AIM wizard.
Unit Units for the property. This property displays only for float values.
Min Minimum value to display for a slider control. This property displays only for a slider
property, which is not applicable to an AIM wizard.
Max Maximum value to display for a slider control. This property displays only for a slider
property, which is not applicable to an AIM wizard.
Read-only Indicates whether the property is read-only.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
100 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT App Builder
function to invoke when Previous is clicked to return to the previous step to reset it if the step
has not been completed correctly.
Note:
• In the Callback pane, the list for selecting a callback includes choices such as Update and
Reset rather than XML-formatted tags such as <onupdate> and <onreset>, which are
used in the XML definition file that is created for the ACT extension.
• Wizards for AIM support only three callbacks: <onupdate>, <onrefresh>, and <onre-
set>.
You use the Record and Code tabs in the Callback pane to define callbacks.
• On the Record tab, you click Start to record in a journal the actions that you take to change
project data in the interface of the associated ANSYS product. Once you finish, you return to the
Record tab and click Stop. To easily change the value of a journal entry, you can click it and then
link the entry to a property that you have defined in the Properties pane.
• On the Code tab, you can view and modify the journal, which is recorded as an IronPython script.
For example, you might need to replace arguments with properties. For information on using
journaling and scripting, as well as a complete list of all available data containers, namespace
commands, and data types, see the Discovery AIM and Workbench Scripting Guide.
Note:
If you are recording and go to the Code tab, a message on this tab indicates that the
code is currently read-only. If you want to make the code editable, you can click Make
Editable. However, this will disable the recording.
When you click the toolbar button for saving the app builder project , the IronPython code
for the callback is saved.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 101
Extensions
Button Action
Edit the entity. When you click this button, the properties for the entity display so that
you can make modifications.
Delete the entity. When you click this button, the entity is deleted.
Tip:
To quickly change the property group for a property, you can drag and drop the property
under a different group.
To easily edit properties that are not visible in the ACT App Builder, you can use the XML editor (p. 106).
1. If you are not on the Home page, click Home in the navigation bar. If any unsaved changes exist
in the currently open app builder project, you must indicate whether to save them before you
can proceed.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
102 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT App Builder
2. In the toolbar, click the button for importing an extension . The Import Extension window
opens.
4. Supply the name and destination folder for the app builder project.
The name of the app builder project cannot contain spaces or certain characters and must
be unique. The destination folder can be any folder to which you can write.
5. Click OK.
The ACT App Builder imports the extension and opens it as an app builder project. A notification
briefly appears at the top of the window when the import completes.
Because the supplied (p. 79) extension WizardDemos contains multiple target product wizards
that are run from various ANSYS products and a mixed wizard, it is often used for explanations.
The following figure shows what the second page in the ACT App Builder looks like when this
extension is imported. It has six products for which wizards have been added.
For example, clicking the WB block displays the two wizards associated with the Workbench product:
BridgeSimulation and Project Wizard.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 103
Extensions
Clicking the ProjectWizard block allows you to see the properties and callbacks defined for each
of the six steps in this wizard, which is run from the Workbench Project Schematic. The following
image displays properties for the step Geometry and the code for the callback Reset, which is
the XML-formatted tag <onreset> in the XML file created for the extension.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
104 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT App Builder
For more information about this particular extension, which has wizards that run from many different
ANSYS products, see Mixed Wizard Example (p. 153).
If you are developing apps for AIM, you can import the extensions StudyDemo and Pres-
sureLossMultiple to view examples of AIM wizards for custom templates. For more information,
see Custom Template Examples in the ACT Customization Guide for Discovery AIM. Additionally, you
can import the extension LinearBuckling to view an example of an AIM wizard for a guided
simulation. For more information, see Guided Simulation Example in the ACT Customization Guide
for Discovery AIM.
1. In the directory where you want to export the XML definition file and IronPython scripts, create
a folder in which to export them.
2. In the ACT App Builder toolbar, click the button for exporting the extension . The Select Folder
window opens.
3. After browsing to and selecting the folder created in the first step, click Select Folder.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 105
Extensions
The XML definition file is created inside this folder. A child folder contains the IronPython scripts
for the extension as well as additional folders with the extension's image files and HTML help files.
The following figure demonstrates how the XML editor shows not only the basic wizard attributes
that are visible in the ACT App Builder but also many more.
Tip:
You turn on and off the display of additional non-published attributes in the XML editor
by clicking the settings icon in the upper right corner of the ACT App Builder and
selecting and clearing the Advanced XML Editor check box. This figure displays the ad-
vanced attribute hidden.
If you have imported the extension WizardDemos into the ACT App Builder, you can use the XML
editor to view and modify all of its many elements, including <simdata>, <interface>, and
<uidefintion>. The following figure shows the attributes for the Workbench wizard named Pro-
jectWizard.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
106 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT App Builder
For example, if you expand the callback onupdate for the step Geometry in this wizard, you can
view and modify the attributes for this step.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 107
Extensions
When a callback for a wizard step is active in the XML editor, buttons in the lower portion of the
window provide for editing, creating, and deleting attributes for the callback. Clicking Delete removes
the selected attribute. Clicking Edit or New opens the Callback Editor, where you can view and
modify the code.
When finished, you click either Apply to save your changes or Cancel to discard them. You are then
returned to the XML editor. When finished, you click the second to last toolbar button to switch
back to the ACT App Builder.
To view and manage the files in your ACT extension, you click the last toolbar button to open the
resource manager. While you are using the resource manager, this button is replaced with the button
for switching back to the ACT App Builder .
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
108 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT App Builder
The resource manager displays the folders and files managed by the ACT App Builder in italics to
indicate that they are in use and are read-only. You cannot edit the name of the extension folder.
You also cannot edit the app builder project's XML file or the extension’s XML definition file or Iron-
Python scripts.
Clicking a folder expands it so that you can see child folders and files. You can use drag-and-drop
operations to organize folders and files. You can use the following toolbar buttons to add (p. 110),
import (p. 110), and export (p. 111) files and folders.
Button Action
Add a new file. In the window that opens, specify the filename and folder location. You
might use this option to add a new text file in which to enter information about the
extension.
Add a new folder. In the window that opens, specify the folder name and location.
Import a file. In the window that opens, select the file to import.
Import a folder. In the window that opens, select the folder to import. Importing a folder
also imports all files within the folder.
Export a file or folder. In the window that opens, select the file or folder to export. Exporting
a folder also exports all files within the folder.
In the resource manager, you can edit the names of files and folders that do not display in italics.
You can also edit the content of text files and custom HTML help files. For more information, see
Editing Files and Folders (p. 111).
When finished, you click the last toolbar button to switch back to the ACT App Builder.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 109
Extensions
1. In the toolbar, click the button for adding a new file. The Add New File window opens.
2. For Name, enter the name for the file, followed by the extension.
For example, to create an HTML file to display as custom help for the first wizard step,
you might enter step1.html.
For example, for an HTML file to display as custom help, you would select the child folder
help. If this folder doesn't yet exist, before performing these steps, you would first want
to add this folder by performing the steps indicated in the next bullet.
4. Click OK.
1. In the toolbar, click the button for adding a new folder. The Add New Folder window opens.
3. For Location, select the folder under which to add the new folder.
4. Click OK.
You add content to a new file by opening it in an editor. For more information, see Editing Files
and Folders (p. 111).
1. In the toolbar, click the button for importing a file. The Import Existing File window opens.
2. For Path, click Browse to navigate to and select the file that you want to import.
The name of the selected file appears for Name. You can rename the file if you want.
4. Click OK.
• To import a folder and all the files within it, do the following:
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
110 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT App Builder
1. In the toolbar, click the button for importing a folder. The Import Existing Folder window
opens.
2. For Path, click Browse to navigate to and select the folder that you want to import.
The name of the selected folder appears for Name. You can rename the folder if you
want.
3. For Location, select the folder under which to add the imported folder.
4. Click OK.
The folder and its files display in the left pane as they are imported.
You can edit the names of imported files and folders and edit content in certain files by opening
them in an editor. For more information, see Editing Files and Folders (p. 111).
When you right-click a file or folder that can be edited, a toolbar displays.
You use the following buttons to edit, duplicate, and delete the selected file or folder.
Button Action
Edit resource. When you click this button, the Edit Resource window opens so that you
can edit the name of the file or folder.
Duplicate resource. When you click this button, a copy of the resource is made. The new
file or folder is given the same name as the original followed by a space and then the
suffix (0). For example, if you copied dm1.html, the newly created file would be
named dm1 (0).html. If you copied dm1 (0).html, the newly created file would
be named dm1 (0) (0).html.
Delete resource. When you click this button, the Delete Resource window opens. You
then confirm or cancel the deletion by clicking Yes or No.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 111
Extensions
1. In the directory where you want to export the folder or file, optionally create a new destination
folder.
3. In the toolbar, click the button for exporting the selected file or folder. The Export Selected File
or Folder window opens.
• Select Folder (default) if you want to export the selected file or folder to the path indicated in
the next step.
• Select Archive if you want to export the selected file or folder to a compressed file (ZIP) to the
path indicated in the next step.
5. For Path, click Browse to navigate to and select the destination folder.
The name of the selected file or folder appears for Name. You can rename the file or folder
if you want.
6. Click OK.
The file or folder or file is exported to the destination directory. A notification briefly appears
at the top of the window when the export completes.
Note:
While C# assemblies are specifically referenced, you can use any language that creates .NET
assemblies.
Function Libraries
Libraries of IronPython functions are installed with ACT to help you to customize ANSYS products. In
C:\Program Files\ANSYS Inc\v201\Addins\ACT\libraries), libraries exist in the fol-
lowing folders:
• AppLauncher
• DesignModeler
• ElectonicsDesktop
• Fluent
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
112 of ANSYS, Inc. and its subsidiaries and affiliates.
Libraries and Advanced Programming
• Mechanical
• Project
• SpaceClaim
• Study
You can use the IronPython functions within these libraries to develop extensions more efficiently. If
desired, you can interactively test them in the ACT Console (p. 50).
Location
• libraries/Mechanical/materials.py
• libraries/Project/materials.py
• libraries/Study/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).
• vy represents a list of values for the property that depends on the input variable defined by vx.
• vin is the value on which the function has to evaluate the property.
Examples
Assume that you enter these commands:
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 113
Extensions
import materials
mat = ExtAPI.DataModel.GeoData.Assemblies[0].Parts[0].Bodies[0].Material
materials.GetListMaterialProperties(mat)
prop
val
val
201111111111.0
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 ANSYS product.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
114 of ANSYS, Inc. and its subsidiaries and affiliates.
Libraries and Advanced Programming
Location
• libraries/DesignModeler/materials.py
• libraries/ElectonicsDesktop/materials.py
• libraries/Fluent/materials.py
• libraries/Mechanical/materials.py
• libraries/Project/materials.py
• libraries/SpaceClaim/materials.py
• libraries/Study/materials.py
Usage
import units
Function
ConvertUnit(value,fromUnit,toUnit[,quantityName])
This function converts the value from the unit fromUnit to the unit toUnit. A quantity name
can be specified to avoid conflict during conversion. However, a quantity name is not mandatory.
Example
Assume that you enter these commands:
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
Assume that you enter these commands:
import units
units.ConvertUserAngleUnitToDegrees(api,3.14)
A result like this is returned if the angle unit is set to radius when the command is called:
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 115
Extensions
180
A result like this is returned if the angle unit is set to degrees when the command is called:
3.14
Function
ConvertToSolverConsistentUnit(api, value, quantityName, analysis)
This function converts the value of the quantity quantityName from the currently activated
unit in the ANSYS product to the corresponding consistent unit used by the solver for the resolution
of the analysis analysis.
Example
Assume that you enter these commands:
import units
units.ConvertToSolverConsistentUnit(api,1.,”pressure”,”Static Structural”)
A result like this is returned if the unit system is set to Metric(mm,dat,N,s,mV,mA) when the command
is called:
10
Function
ConvertToUserUnit(api, value, fromUnit, quantityName)
This function converts the value of the quantity quantityName from the unit fromUnit to
the currently activated unit system in the ANSYS product.
Example
Assume that you enter these commands:
import units
units.ConvertToUserUnit(api,1.,”m”,”length”)
A result like this is returned if the current activated unit is millimeter when the command is called:
1000
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.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
116 of ANSYS, Inc. and its subsidiaries and affiliates.
Libraries and Advanced Programming
Example
Assume that you enter these commands:
import units
units.ConvertUnitToSolverConsistentUnit(api,1.,”m”,”length”,”Static Structural”)
A result like this is returned if the consistent unit is millimeter when the command is called:
1000
Function
GetMeshToUserConversionFactor(api)
This function returns the scale factor to be applied to convert a length from the unit associated
with the mesh and the currently activated unit in the ANSYS product.
Example
Assume that you enter these commands:
import units
units.GetMeshToUserConversionFactor(api)
A result like this is returned if the unit associated with the mesh is meter and if the current activated
unit in the application is millimeter:
1000
MAPDL Helpers
Description
This library implements some helpers to write APDL command blocks or to execute Mechanical
APDL programs.
Location
• libraries/ElectronicsDesktop/ansys.py
• libraries/Fluent/ansys.py
• libraries/Mechanical/ansys.py
• libraries/Project/ansys.py
• libraries/Study/ansys.py
Usage
import ansys
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 117
Extensions
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 Mechanical APDL program with the command line initialized by args. The
folder from which to execute the program can be specified with runDir. The location of the ex-
ecutable is also managed with exelocation.
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
Workbench Project tab.
Location
• libraries/Mechanical/ansys.py
• libraries/Project/ansys.py
• libraries/Study/ansys.py
Usage
import wbjn
Functions
ExecuteCommand(api,cmd,**args)
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
118 of ANSYS, Inc. and its subsidiaries and affiliates.
Libraries and Advanced Programming
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…). Note that the standard Python dictionary does
not implement this interface by default. If a dictionary is required, use the class Serializable-
Dictionary provided by ACT.
Examples
Numerical Library
The numerical library that IronPython supports is Math.net. This library is available for use with ACT
and is installed in the following directory:
Note:
Because Numpy and SciPyY are numerical libraries supported by Python rather than
IronPython, they cannot be used with ACT.
The following code sample provides three examples for using Math.net:
import clr
import System
import os
clr.AddReferenceToFileAndPath("C:\\Program Files\\ANSYS Inc\\v201\\Addins\\ACT\\bin\\Win64\\MathNet.Numerics.dll
# Example 1
import MathNet
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 119
Extensions
m = M.Random(3,4)
v = V.Random(3)
r=v*m
print r
# Example 2
import MathNet.Numerics.LinearAlgebra as la
A = la.Double.Matrix.Build.DenseOfRowArrays(
array(3, 2,-1),
array(2,-2,4),
array(-1,.5,-1)
)
print x
# Example 3
A1 = la.Double.Matrix.Build.DenseOfRowArrays(
array(3.0, 4.0, -1.0, 0.0),
array(4.0, 5.0, 0.0, -1.0),
array(5.0, 6.0, 0.0, 0.0),
array(6.0, 7.0, 0.0, 0.0)
)
b1 = la.Double.Vector.Build.DenseOfArray(array(0, 0, 20, 0))
x1 = A1.Solve(b1)
print x1
Advanced Programming in C#
C# provides two major advantages over IronPython:
• Better performance
It is assumed that you already know how to create assemblies in C#. The following topics explains
how to replace IronPython code with C# assemblies:
Initialize the C# Project
C# Implementation for a Load
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
120 of ANSYS, Inc. and its subsidiaries and affiliates.
Libraries and Advanced Programming
Note:
While C# assemblies are specifically referenced, you can use any language that creates
.NET assemblies.
Tip:
Included in the supplied workflow templates (p. 87) is a folder CSharp. This folder contains
files for a simple workflow-based app that is coded using C#. While this example is for
Mechanical, the concept is supported ACT-wide. For download information, see Extension
and Template Examples (p. 78).
<author>ANSYS</author>
<description>This extension demonstrates how to use CSharp to write extension.</description>
<interface context="Mechanical">
<images>images</images>
</interface>
<simdata context="Mechanical">
</simdata>
</extension>
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 121
Extensions
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.
namespace CSharp
{
public class Load
{
private readonly IMechanicalExtAPI _api;
private readonly IMechanicalUserLoad _load;
public Load(IExtAPI api, IUserLoad load)
{
_api = (IMechanicalExtAPI) api;
_load = (IMechanicalUserLoad) load;
}
}
return res;
}
}
}
To implement a callback in C#, create a new method in your class with the name of the callback
in lower case.
<author>ANSYS</author>
<description>This extension demonstrates how to use CSharp to write extension.</description>
<interface context="Mechanical">
<images>images</images>
</interface>
<simdata context="Mechanical">
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
122 of ANSYS, Inc. and its subsidiaries and affiliates.
Libraries and Advanced Programming
</simdata>
</extension>
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.
namespace CSharp
{
public class Result
{
internal double[] res = new double[1];
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 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 123
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
124 of ANSYS, Inc. and its subsidiaries and affiliates.
Feature Creation
Feature creation is the direct, API-driven customization of ANSYS products. In addition to leveraging
the functionality already available in a product, ACT enables you to add functionality and operations
of your own. Examples of feature creation include creating custom loads and geometries, adding custom
preprocessing or postprocessing features, and integrating third-party solvers, sampling methods, and
optimization algorithms.
• DesignModeler
• DesignXplorer
• Mechanical
• Workbench
Note:
• Extensions referenced in this section are supplied (p. 78). In the extension's XML file, the element
<interface> has an attribute <context>. This attribute specifies the ANSYS product in which
the extension is to execute. For most of the supplied extensions, the attribute <context> is set
to Mechanical. The only significant product difference is that Mechanical requires BMP files
for the images to display as toolbar buttons. All other products require PNG files.
• For feature creation capabilities specific to a product, see the ACT customization guide for the
particular product. Links to these guides are available in ACT Customization Guides for Supported
ANSYS Products (p. 179).
Toolbar Creation
You can add custom toolbars to ANSYS products that expose their own toolbars. A toolbar is a parent
container for one or more toolbar buttons. Conceptually, the toolbar should address a specific feature,
with each toolbar button being associated with a function that supports the feature. This relationship
is reflected in the structure of the extension's XML file, which defines the toolbar and its buttons.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 125
Feature Creation
In the introductory example (p. 70), the extension ExtSample1 shows how to create a custom
Mechanical toolbar with a single button that displays this message when clicked: High five!
ExtSample1 is a success!.
Here, the extension ExtToolbarSample shows how to create two custom Mechanical toolbars, each
with multiple button that call IronPython functions. This extension's XML file follows.
<extension version="1" name="ExtToolbarSample">
<guid shortid="ExtToolbarSample">ccdbbed4-9fdd-4157-acea-abccddbd62fc</guid>
<script src="toolbarsample.py" />
<interface context="Mechanical">
<images>images</images>
<callbacks>
<oninit>init</oninit>
</callbacks>
<toolbar name="ToolBar1" caption="ToolBar1">
<entry name="TB1Button1" icon="button1Red">
<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>
When the extension ExtToolbarSample is loaded in Mechanical, to the right of the ribbon's Auto-
mation tab, two additional tabs display: ToolBar1 and Toolbar 2. When the Toolbar1 tab is selected,
you see three red buttons:
When the Toolbar2 tab is selected, you see three blue buttons:
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
126 of ANSYS, Inc. and its subsidiaries and affiliates.
Toolbar Creation
To define each of these toolbars, the XML file uses the element <toolbar>. Each of these elements
has two attributes, name and caption. The attribute name is required and is used for internal references.
The attribute caption is the text to display in Mechanical.
The element <toolbar> has a child element <entry> that defines the buttons in the toolbar. The
element <entry> has two attributes, name and icon. The attribute name is required and is used for
internal references. It also displays as the tooltip for the button. The attribute icon is the name of the
image file to display as the button.
The element <entry> has a child element <callbacks> that defines callbacks to events. For instance,
the callback <onclick> specifies the name of the IronPython function to invoke when the button is
clicked.
This line defines toolbarsample.py as the IronPython script for the extension. This script follows.
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)
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 127
Feature Creation
The script in toolbarsample.py makes use of the namespace datetime from the .NET framework.
The namespace datetime exposes a class that is also called datetime. The function LogButton-
Clicked invokes datetime to query the current date and time and then stores the result in the
variable named now. The utility str() is used to extract the string definition of the variable now to
write out the date and time.
<simdata context="Mechanical">
<result name="My_Result" version="1" caption="My_Result" icon="result" location="elemnode"
type="scalar">
</result>
</simdata>
As an example, if the ACT button is bound with an ACT load in Mechanical, 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 Mechanical, 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 callback <onclick> is not used.
The following figure illustrates behavior based on selection of an environment object in the tree. The
button is inactive.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
128 of ANSYS, Inc. and its subsidiaries and affiliates.
Dialog Box Creation
This next figure illustrate the behavior based on selection of a solution object in the tree. The button
is active.
In addition to the control provided by the connection between the ACT button and the ACT object,
the callback <canadd> can be implemented to add new criteria to consider for the activation and
deactivation of the button. If the callback <canadd> 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.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 129
Feature Creation
<callbacks>
<onclick>GUIMenuOpenFile</onclick>
</callbacks>
</entry>
</toolbar>
</interface>
</extension>
The callback function specified for the GetFilename menu button is GUIMenuOpenFile. The IronPython
script dialogsample.py defines this function.
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 GUIMenuOpenFile(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)
When the function GUIMenuOpenFile is invoked, an instance of a modal file selection dialog box is
created by calling FileDialog.ShowOpenDialog. The class FileDialog is provided by the UI
Toolkit. When running the extension, the necessary information is supplied in the dialog box. When
the Open or Cancel button is clicked, the file selection dialog box closes. The supplied information is
returned to the function GUIMenuOpenFile, which uses it to create the message dialog box. The
message shown in this dialog box validates the result that is returned from the file selection dialog box.
• The callback <onsave> is called each time the target product saves the project. Consequently, this
callback allows the creation of dedicated files in which to store data. It also allows data to be stored in
the standard ANSYS Workbench project.
• The callback <onload> is called each time the target product loads the project. The process here is
similar to the callback <onsave>, but it is now devoted to reading in additional data.
• Attributes represent an interesting way to store data because they do not require the creation of ex-
ternal files. The remainder of this describes how to use attributes to store data.
Attributes are defined by name and content. The content can be defined by a single value, such as an
integer or a double, or it can be defined with more complex data. The content must be serializable. To
accomplish this, implement the serialization interface provided by the .NET framework. Types such as
integer, double, list, and dictionary are serializable by default.
Attributes are automatically saved and resumed with the project. Attributes can be associated with an
ACT extension, load or result, or property.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
130 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT-Based Property Creation
An attribute associated with an extension can be shared between products using the same extension.
For example, two Mechanical sessions can share data.
Similarly, the command to retrieve the content stored in a shared repository is:
ExtAPI.ExtensionMgr.CurrentExtension.UpdateAttributes()
v = ExtAPI.ExtensionMgr.CurrentExtension.Attributes["MyData"]
• The element <PropertyGroup> encapsulates a list of child properties under one group.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 131
Feature Creation
• The element <PropertyTable> encapsulates a list of child properties under one table. Each child
property creates a new column in the table. You can control the line number of this table.
Assume that you want to create a group of properties with a caption and that you want to be able
to collapse and expand this group. The following figure shows the caption Simple group with caption.
The element propertygroup has a special attribute, display. In this case, display is set to
caption, which indicates that all child properties are to display under the caption. If caption is
omitted, display defaults to hidden, which indicates that the property group is hidden.
Assume now that you want to show or hide properties according to the value of another selected
property. In the following figure, the visibility of the properties depends on the value of the property
Group Select.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
132 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT-Based Property Creation
In this case, the attribute display is set to property. The element propertygroup named
Group3 defines a standard ACT property that provides additional capabilities for all child properties.
Each child property can specify an attribute visibleon, which can take a value or a set of values.
If the current value of the parent property fits with the attribute visibleon, the property is displayed.
Otherwise, the property is hidden.
You can also create properties that open a worksheet in which to access the content for properties.
You use the type PropertyTable if you want to create a worksheet that exposes a set of properties
for your customization. To facilitate development, ACT provides two different types of predefined
worksheets:
• Time-dependent
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 133
Feature Creation
Time-Dependent Worksheets
In a time-dependent worksheet, the row number is initialized with the number of steps defined in
the object AnalysisSettings. When time steps are added to or removed from the object Ana-
lysisSettings, the worksheet is automatically updated. Consequently,this type of worksheet
represents an efficient way to manage time-dependent data within an extension.
In this example, the attribute display is set to worksheet. In addition, the attribute class specifies
the name of the IronPython class that manages the worksheet. This example uses the class TFTabu-
larData, which is defined in the function library TimeFreqTabularData.py. This library (p. 112)
is installed with ACT and located in %ANSYSversion_DIR%\Addins\ACT\libraries\Mechan-
ical\Worksheet.
The properties Step and Time integrate a specific treatment, as they are automatically populated
with the information specified in the object AnalysisSettings. These two properties are optional.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
134 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT-Based Property Creation
This example uses the class PGEditor, which is defined in the function library PropertyGroupEd-
itor.py. This library (p. 112) is installed with ACT and located in %ANSYSver-
sion_DIR%\Addins\ACT\libraries\Mechanical\Worksheet.
You access the content of the worksheet in the same manner as you do any other standard ACT
property.
For example, the folder Mechanical contains the template controltemplates.xml for Mech-
anical. The content of this file includes several templates, each of which is assigned a name. The
template coordinatesystem_selection follows.
<!-- Coordinate System Selection -->
<controltemplate name="coordinatesystem_selection" version="2">
<property name="selectCoordinateSystem" control="select" class="templates.select.SelectCoordinateSystem">
</property>
</controltemplate>
This template uses the class SelectCoordinateSystem, which is defined in the template se-
lect.py and located here: ANSYS_INSTALL_DIR\Addins\ACT\libraries\Mechanical\tem-
plates. A template has to be made of one single property. If several properties need to be defined,
you must integrate them into a group. In the same folder, the template scoping.py supplies a
definition with different properties.
To link this template to a property, for the property, you set the attribute control to the name of
the template.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 135
Feature Creation
• In DesignModeler, you can incorporate parameters into a number of custom ACT-based features, such as
renaming selected bodies and specifying geometry generation information.
• In Mechanical, you can define parameters for any ACT object, regardless of its location in the tree.
• In Workbench, you can define parameters for custom task-level properties in the Project Schematic.
• In a third-party solver implemented by ACT, you can incorporate parameters into the load, analysis settings,
and result.
Once parameterized, an ACT property is added to the Parameter Set bar in the Workbench Project
Schematic, where it behaves and is treated as any other parameter.
The following topics provide general information on parametrizing ACT properties in extensions and
for third-party solvers:
Parametrizing ACT-Based Properties in Extensions
Parametrizing ACT-Based Properties for Third-Party Solvers
Note:
When you define a property as a parameter, it is not parameterized by default. Defining a property
as a parameter only makes parameterization possible by adding a check box to the ANSYS product.
To actually parameterize the property, you must select the check box that the attribute isparameter
makes available in the product.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
136 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT-Based Property Parameterization
Once you select a parameter for parameterization, it is automatically sent to the Parameter Set bar
in the Workbench Project Schematic. You can view it in both the Outline and Table panes for the
Parameter Set bar. While output parameters are read-only, you can set input parameters from ACT
in the same way as any other input parameter. For example, you can:
• Change the unit of the parameterized input property. The unit proposed respects the type of unit specified
in the XML file.
• Add a design point for the input parameter by clicking in the bottom row of the design points table.
• Modify the value of a design point by selecting an input parameter and entering a new value. However,
the type of value must respect the one specified in the XML file. As such, design point values in the previous
value must be floats. They cannot be strings.
There should be at least one input parameter and one output parameter. When you finish setting up
the system and working with parameters and design point values, you can solve the problem by
updating the design points for the Parameter Set bar.
You can also parameterize analysis settings for a third-party external solver. The settings available
depend on the definition of the third-party solver. For example, you can parameterize the maximum
number of iterations:
In the XML file, the element <solver> defines the property MaxIter. For this property, you set
the attribute isparameter to true.
<solver…
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 137
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
138 of ANSYS, Inc. and its subsidiaries and affiliates.
Simulation Wizards
You can use ACT to create simulation wizards for all ANSYS products listed in the introduction (p. 1).
A wizard automates a simulation process by walking non-expert users step-by-step through the simula-
tion.
A wizard is part of an ACT extension (p. 69). Within the element <extension>, you add the element
<wizard> and then define each step, along with step callbacks and properties. A wizard can access
the functionality defined in the wizard and leverage API scripting capabilities, which allows you to be-
nefit from ANSYS simulation capabilities while minimizing interactions with ANSYS products.
Note:
You use the Extension Manager (p. 39) to install and load extensions. You then use the
Wizards launcher (p. 44) to start a wizard.
• The top panel shows general information about the wizard and a logo of your choice.
• The left panel shows a list of the steps in the wizard, with the current step highlighted.
• The right panel shows data-entry and data-display fields for the selected step.
• The bottom panel shows custom help for the selected step.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 139
Simulation Wizards
Note:
The overall content and function of a wizard is consistent across ANSYS products. While the
interface of a Workbench-based wizard can be customized (p. 159), the interface of an AIM
wizard cannot be customized. For wizard information specific to a particular product, see
the ACT customization guide for the product. The concluding section (p. 179) provides links
to these guides.
The wizard definition can include a progress bar to display progress as the step executes and a message
box to display a confirmation when the step execution completes successfully. In the Project tab,
you can verify completion of the step.
Once you are past the first step, the Back button is enabled. When you click this button, the wizard
returns to the previous step, but the data generated for this step is lost.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
140 of ANSYS, Inc. and its subsidiaries and affiliates.
Wizard Types
1. Click Edit.
4. When finished, click either the green check box icon to save the data or the red stop icon to cancel.
Exiting a Wizard
On the final step of a wizard, the Finish button is enabled. When you click this button, the wizard
completes. You are returned to the ACT Start Page.
To exit a wizard at any time, you can click Exit Wizard in the lower left corner of the wizard interface.
You are returned to the Wizards launcher.
Note:
If you exit the wizard midway through, the changes to the project are retained and
can be saved, but the data that you entered in the wizard is not retained. You cannot
resume the wizard where you left off.
To exit the project with a wizard still in progress, save the project and exit as usual. On reopening
the project, the wizard is still in its last saved state, so you can resume where you left off.
Wizard Types
You can create three different types of wizards: project wizards, target product wizards, and mixed
wizards.
Tip:
The extensions referenced in this section are supplied. For download information, see Exten-
sion and Template Examples (p. 78).
Project Wizards
A project wizard is executed from the Project tab in either Workbench or AIM.
• When executed from the Project tab in Workbench, a project wizard can engage any data-integrated
ANSYS product with Workbench journaling and scripting capabilities and incorporate them into the
project workflow. The extension DemoWizards includes a project wizard named ProjectWizard.
This wizard is described in Wizard Creation (p. 142).
• When executed from the Project tab in AIM, a project wizard can automate an AIM simulation. The
extension PressureLoss contains an AIM project wizard. This wizard is described in AIM Project
Wizards in the ACT Customization Guide for Discovery AIM.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 141
Simulation Wizards
Target product wizards for some products, such as native products like DesignModeler and Mechanical,
execute only within the Workbench environment. Target product wizards for other products, such as
Electronics Desktop, Fluent, and SpaceClaim, can execute either within the Workbench environment or
in a stand-alone instance of the product.
The following table shows where different target product wizards can be executed. For product-specific
wizard examples, see the ACT customization guides for these products. The guides for Electronics
Desktop, Fluent, and SpaceClaim also provide usage information for a stand-alone instance of the
product. The concluding section (p. 179) provides links to these guides.
Mixed Wizards
A mixed wizard is executed from the Workbench Project tab and engages one or more supported ANSYS
products to automate the entire simulation process. A mixed wizard is used when interactive selection
on the model is required at a given step in one given product. It provides native workflow guidance in
both the Project tab and the included products.
The extension DemoWizards includes a mixed wizard named BridgeSimulation, which is described
in Mixed Wizard Example (p. 153).
Note:
Because DesignXplorer is part of Workbench, you can create project wizards and mixed
wizards that can engage DesignXplorer. For the wizard step, you simply need to set the at-
tribute <context> to Project. Because DesignXplorer does not have a stand-alone ap-
plication interface, you cannot create target product wizards for DesignXplorer.
Wizard Creation
To create a wizard, in the extension's XML file, you include specific elements that define the wizard. If
desired, you can create HTML files to supply custom wizard help (p. 158).
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
142 of ANSYS, Inc. and its subsidiaries and affiliates.
Wizard Creation
The following topics describe how to create a project wizard, using the supplied extension WizardDemos
as an example:
Adding the XML Element for the Wizard
Defining the Wizard
Defining Functions for the Wizard
Tip:
To customize the appearance of a Workbench-based wizard, you can add the optional
element <uidefinition>. In this element, you can define layouts both for the
wizard interface as a whole and for individual wizard components. For more informa-
tion, see Custom Wizard Interfaces (p. 159) and Custom Wizard Interface Example (p. 161).
The extension WizardDemos contains a project wizard named ProjectWizard that is executed
from the Project tab in Workbench. An excerpt from the file WizardDemos.xml follows. Code is
omitted for the element <uidefinition> and all wizards other than the wizard ProjectWizard.
<extension version="2" minorversion="1" name="WizardDemos">
<guid shortid="WizardDemos">7fdb141e-3383-433a-a5af-32cb19971771</guid>
<author>ANSYS Inc.</author>
<description>Simple extension to test wizards in different contexts.</description>
<interface context="Project|Mechanical|SpaceClaim">
<images>images</images>
</interface>
<interface context="DesignModeler">
<images>images</images>
</interface>
...
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 143
Simulation Wizards
<componentStyle component="Submit">
<background-color>#b6d7a8</background-color>
</componentStyle>
<componentData component="TabularData">
<CanAddDelete>false</CanAddDelete>
</componentData>
<callbacks>
<onupdate>EmptyAction</onupdate>
<onreset>DeleteGeometry</onreset>
<oninit>InitTabularData</oninit>
</callbacks>
</step>
<callbacks>
<onupdate>EmptyAction</onupdate>
<onreset>DeleteMechanical</onreset>
</callbacks>
</step>
<callbacks>
<onrefresh>CreateDialog</onrefresh>
<onupdate>EmptyAction</onupdate>
<onreset>EmptyReset</onreset>
</callbacks>
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
144 of ANSYS, Inc. and its subsidiaries and affiliates.
Wizard Creation
</step>
<callbacks>
<onrefresh>RefreshReport</onrefresh>
<onreset>EmptyReset</onreset>
</callbacks>
</step>
<callbacks>
<onrefresh>RefreshMechanical</onrefresh>
<onupdate>LogReport</onupdate>
<onreset>EmptyReset</onreset>
</callbacks>
</step>
<callbacks>
<onrefresh>RefreshCharts</onrefresh>
</callbacks>
</step>
</wizard>
...
</extension>
As indicated in the element <description>, this extension is for testing wizards in different contexts.
It has two elements <interface>. In the first element <interface>, the attribute context is
set to Project|Mechanical|SpaceClaim, which indicates that wizards with their context set
to these products use this interface. In the second element <interface>, the attribute context
is set to DesignModeler, which indicates that wizards with their context set to this product use
this interface.
In addition to the project wizard named ProjectWizard, the extension WizardDemos includes
target product wizards for DesignModeler, SpaceClaim, and Mechanical. Additionally, it includes a
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 145
Simulation Wizards
mixed wizard (p. 153). For information on the product-specific wizards in this extension, see the ACT
customization guides for these products. The concluding section (p. 179) provides links to these guides.
• The attribute icon specifies the filename of the image to display as the icon for the wizard: wiz-
ard_icon. Any image file specified for use as an icon must be placed in the folder declared for images
in the element <interface> for the extension. The child element <images> specifies the folder
name.
• The attribute description specifies the text to display in the About window for the extension
when it is accessed from the Extension Manager and in the About window for the wizard when it
is accessed from the Wizards page.
Note:
• For a project wizard that is to execute from the Project tab in AIM, the attribute <context>
is still set to Project. For a target product wizard for AIM, the attribute <context> is set
to Study. For comprehensive information, see AIM Wizards in the ACT Customization Guide
for Discovery AIM.
• For a mixed wizard, the attribute context is set to Project. A mixed wizard can only be
executed from the Project tab in Workbench.
Step Definition
You use the element <step> to define a step in the wizard. The wizard ProductWizard has six
steps: Geometry, Mechanical, Fluent, ReportView, CustomStep, and Charts.
Required attributes for the element <step> are name and version. The optional attribute caption
sets the display text for the step.
You only need to set the attribute context if the context for the step differs from the context for
the wizard. Because all six steps in the wizard ProjectWizard are executed from the Workbench
Project tab, the attribute context does not have to be set.
Note:
• For a target product wizard for AIM, the attribute context is not used in step definitions.
• For a mixed wizard, the attribute context is set to the ANSYS product from which the step
is executed.
Additional optional attributes can be defined for steps. For example, the attribute HelpFile can
specify an HTML file with custom help (p. 158) to display for the step.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
146 of ANSYS, Inc. and its subsidiaries and affiliates.
Wizard Creation
The attribute enabled specifies whether to show or hide the step. This attribute is set to true by
default.
In the IronPython script, you can programmatically change the state of the attribute enabled to
create branches where certain steps are executed in only specific circumstances: step.Enabled
= True or step.Enabled = False.
Consequently, when the wizard is executed, the choices made in the step determine which subsequent
steps display.
Callback Definition
Each step defined in the XML file can have multiple callbacks invoking functions defined in the Iron-
Python script. You use the element <callbacks> to define the callbacks for a step. Each callback
receives the current step as a method argument.
• The required callback <onupdate> is invoked when Next is clicked to move to the next wizard step.
• The callback <onrefresh> 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 wizard, initialize a value to
use in the current step, instantiate variables, access data of an existing project, and so on.
• The callback <onreset> resets the state of the step so that a step completed incorrectly can be
corrected.
Note:
Target product wizards for AIM support only three callbacks: <onupdate>, <onre-
fresh>, and <onreset>.
A summary follows of the callbacks for the steps in the wizard ProductWizard:
• For the step Geometry, the callback <onupdate> executes the function EmptyAction. The
callback <onreset> executes the function DeleteGeometry. The callback <oninit> executes
the function InitTabularData.
• For the step Mechanical, the callback <onupdate> executes the function EmptyAction. The
callback <onreset> executes the function DeleteMechanical.
• For the step Fluent, the callback <onrefresh> executes the function CreateDialog. The
callback <onupdate> executes the function EmptyAction. The callback <onreset> executes
the function EmptyReset.
• For the step ReportView, the callback <onrefresh> executes the function RefreshReport.
The callback <onreset> executes the function EmptyReset.
• For the step CustomStep, the callback <onrefresh> executes the function RefreshMechanical.
The callback <onupdate> executes the function LogReport. The callback <onreset> executes
the function EmptyReset.
• For the step Charts, the callback <onrefresh> executes the function RefreshCharts.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 147
Simulation Wizards
Functions can also be executed by callbacks within property definitions for steps.
Tip:
In IronPython scripts, functions can use ANSYS journaling and scripting commands. You
can paste commands obtained from a session journal file—either from the temporary
journal stored in your folder %TEMP% or from a journal generated by using the Record
Journal menu option—and then edit these commands.
Property Definition
You use the element <propertygroup> to define a group of properties within a step. You use the
element <property> to define a property and its attributes. For a property requiring validation, the
callback <onvalidate> executes the appropriate validation function.
For the element <property>, required attributes are control and name. The attribute control
specifies the property type. Standard property types are select, float, integer, scoping, text,
and fileopen. Advanced property types such as applycancel and custom are also supported.
• The attribute caption specifies the display text for the property.
• The attribute visibleon specifies whether a property is to display. In this example, the property
visibleon is used to control the display of conditional options in a property group.
In the wizard ProjectWizard, the step Geometry includes multiple occurrences of the element
<propertygroup>. The first is named definition. Because the attribute control is not defined,
this property group lists properties individually. Embedded with this property group is a second
property group named myselect. It sets the attribute control to select, which provides a drop-
down list:
• The attribute visibleon indicates that the properties in the group are conditional based on selection
from the drop-down.
The step Geometry also includes the element <propertytable>, which creates a table for the
entry of property values in tabular format. The properties Temperature and Pressure are nested
inside the element <propertytable> to create columns for data entry. For information on entering
tabular data, see Entering Data in a Wizard (p. 140).
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
148 of ANSYS, Inc. and its subsidiaries and affiliates.
Wizard Creation
The script main.py defines the functions executed by the callbacks for steps in the wizard Pro-
jectWizard.
geoSystem = None
dsSystem = None
fluentSystem = None
def EmptyAction(step):
pass
def InitTabularData(step):
table = step.Properties["TableB"]
for i in range(1, 10):
table.AddRow()
table.Properties["Integer"].Value = i
table.Properties["FileOpen"].Value = "super"
table.Properties["Number"].Value = 45.21
table.Properties["ReadOnly"].Value = 777
table.Properties["myselect"].Properties["TestStr"].Value = 777
table.Properties["myselect"].Properties["Number B"].Value = 777
table.SaveActiveRow()
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.GetComponent("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.GetComponent("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
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 149
Simulation Wizards
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):
comp = step.UserInterface.Panel.CreateOKCancelDialog("MyDialog", "MyTitle", 400, 150)
comp.SetOkButton("Ok")
comp.SetMessage("My own message")
comp.SetCallback(cbDialog)
prop = step.Properties["nextstep"]
prop.Options.Clear()
s = step.NextStep
val = s.Caption
while s!=None:
prop.Options.Add(s.Caption)
s = s.NextStep
prop.Value = val
def worker(step):
progressDialog = step.UserInterface.GetComponent("Progress")
progress = progressDialog.GetFirstOrDefaultComponent()
progress.Reset()
stopped = progress.UpdateProgress("Start progress...", 0, True)
progressDialog.Show()
for i in range(100):
System.Threading.Thread.Sleep(100)
stopped = progress.UpdateProgress("Start progress...", i+1, True)
if stopped:
break
progressDialog.Hide()
def RefreshReport(step):
report = step.UserInterface.GetComponent("Report")
report.SetHtmlContent(System.IO.Path.Combine(ExtAPI.Extension.InstallDir,"help","report.html"))
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
150 of ANSYS, Inc. and its subsidiaries and affiliates.
Wizard Creation
report.Refresh()
def EmptyReset(step):
pass
def LogReport(step):
ExtAPI.Log.WriteMessage("Report:")
for s in step.Wizard.Steps.Values:
ExtAPI.Log.WriteMessage("Step "+s.Caption)
for prop in s.AllProperties:
ExtAPI.Log.WriteMessage(prop.Caption+": "+prop.DisplayString)
import random
import math
def RefreshCharts(step):
graph = step.UserInterface.GetComponent("Graph")
graph.Title("Line Bar Graph")
graph.ShowLegend(False)
graph.Plot([-1, 0, 1, 2, 3, 4], [0.5, -0.5, 0.5, -0.5, 0.5, 0.5], key="Variable A", color='g')
graph.Bar([-1, 0, 1, 2, 3, 4], [10, 20, 30, 10, 5, 20], key="Variable B")
graphB = step.UserInterface.GetComponent("GraphB")
graphB.Title("Plot Graph")
graphB.YTickFormat("0.2f")
xValues = []
yValues = []
for i in range(0, 100):
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.GetComponent("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.GetComponent("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.GetComponent("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])
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 151
Simulation Wizards
def CreateStaticStructural(step):
template1 = GetTemplate(
TemplateName="Static Structural",
Solver="ANSYS")
system1 = template1.CreateSystem()
system1.DisplayText = "toto"
nextStep = step.NextStep
if nextStep!=None:
nextStep.SystemName = system1.Name
nextStep.ComponentName = "Geometry"
nextStep = nextStep.NextStep
if nextStep!=None:
nextStep.SystemName = system1.Name
nextStep.ComponentName = "Geometry"
nextStep = nextStep.NextStep
if nextStep!=None:
nextStep.SystemName = system1.Name
nextStep.ComponentName = "Geometry"
nextStep = nextStep.NextStep
if nextStep!=None:
nextStep.SystemName = system1.Name
nextStep.ComponentName = "Geometry"
nextStep = nextStep.NextStep
if nextStep!=None:
nextStep.SystemName = system1.Name
nextStep.ComponentName = "Model"
nextStep = nextStep.NextStep
if nextStep!=None:
nextStep.SystemName = system1.Name
nextStep.ComponentName = "Model"
firstGeoStep = step.NextStep
if prop.Value == "DesignModeler":
firstDMStep.IsEnabled = True
secondDMStep.IsEnabled = True
firstSCStep.IsEnabled = False
secondSCStep.IsEnabled = False
elif prop.Value == "SpaceClaim":
firstDMStep.IsEnabled = False
secondDMStep.IsEnabled = False
firstSCStep.IsEnabled = True
secondSCStep.IsEnabled = True
panel = step.UserInterface.Panel.GetComponent("Steps")
panel.UpdateData()
panel.Refresh()
def RefreshResultsProject(step):
step.Properties["Res"].Value = ExtAPI.Extension.Attributes["result"]
panel = step.UserInterface.Panel.GetComponent("Properties")
panel.UpdateData()
panel.Refresh()
For a mixed wizard, the definition of the first step executed in the Project tab specifies the ANSYS
products from which subsequent steps are executed. For instance, in the following excerpted code,
multiple actions are defined. Steps in the mixed wizard call these actions.
…
def action1(step):
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
152 of ANSYS, Inc. and its subsidiaries and affiliates.
Mixed Wizard Example
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"
…
The ACT customization guides for DesignModeler, SpaceClaim, and Mechanical describe the target
product wizards. The concluding section (p. 179) provides links to these guides. The following topics
describe the mixed wizard BridgeSimulation:
Defining the Mixed Wizard
Defining Functions for the Mixed Wizard
An excerpt from the file WizardDemos.xml follows. Code is omitted for the element <uidefini-
tion> and all wizards other than the mixed wizard BridgeSimulation.
<extension version="2" minorversion="1" name="WizardDemos">
<guid shortid="WizardDemos">7fdb141e-3383-433a-a5af-32cb19971771</guid>
<author>ANSYS Inc.</author>
<description>Simple extension to test wizards in different contexts.</description>
<interface context="Project|Mechanical|SpaceClaim">
<images>images</images>
</interface>
<interface context="DesignModeler">
<images>images</images>
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 153
Simulation Wizards
</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>
...
<callbacks>
<onupdate>CreateStaticStructural</onupdate>
<!--<onreset>DeleteStaticStructural</onreset>-->
</callbacks>
</step>
<callbacks>
<onupdate>UpdateDeck</onupdate>
</callbacks>
</step>
<callbacks>
<onupdate>UpdateSupports</onupdate>
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
154 of ANSYS, Inc. and its subsidiaries and affiliates.
Mixed Wizard Example
</callbacks>
</step>
<callbacks>
<onupdate>UpdateDeckSC</onupdate>
</callbacks>
<callbacks>
<onupdate>UpdateSupportsSC</onupdate>
</callbacks>
<callbacks>
<onreset>RemoveControls</onreset>
<onupdate>CreateMeshControls</onupdate>
</callbacks>
</step>
<callbacks>
<onrefresh>RefreshLoads</onrefresh>
<onreset>RemoveLoads</onreset>
<onupdate>CreateLoads</onupdate>
</callbacks>
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 155
Simulation Wizards
</step>
<callbacks>
<onrefresh>RefreshResultsProject</onrefresh>
</callbacks>
</step>
</wizard>
</extension>
• The first element <interface> has the attribute context set to Project|Mechanical|Space-
Claim, which indicates that wizards with their contexts set to any of these products use this interface.
• The second element <interface> has the attribute context set to DesignModeler, which in-
dicates that wizards with their contexts set to this product use this interface. This element <inter-
face> has a child element <toolbar> that defines two toolbar buttons for exposure in Design-
Modeler. When the buttons are clicked, the callback <onclick> executes the functions CreateDeck
and CreateSupport, creating a deck geometry with supports.
Simdata Definition
The element <simdata> provides data. This extension has two such elements to provide data for cre-
ating the geometries Deck and Support in DesignModeler.
Wizard Definition
The element <wizard> named BridgeSimulation defines the mixed wizard BridgeSimulation.
The attribute context specifies the product in which the wizard is executed. Because this wizard accesses
the target product from the Project tab instead of executing in the target product directly, context
is set to Project.
Step Definition
The element <step> defines a step in the mixed wizard BridgeSimulation. This wizard has eight
steps: Project, DeckDM, SupportsDM, DeckSC, SupportsSC, Mesh, Solution, and Results.
The steps with DM in their names are executed in DesignModeler. The steps with SC in their names are
executed in SpaceClaim.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
156 of ANSYS, Inc. and its subsidiaries and affiliates.
Mixed Wizard Example
• The attributes name, version, and caption specify the name, version, and display text for the
step.
• The attribute context specifies the ANSYS product in which the specific step is executed. You only
need to set the context for the step if it differs from the context for the wizard.
• The attribute HelpFile specifies the HTML file to display as the custom help for the step.
• The element <callbacks> specifies callbacks to functions defined in all four IronPython scripts
referenced in this extension's XML file.
– For the step Project, the callback <onupdate> executes the function CreateStaticStruc-
tural in the script main.py.
– For the step DeckDM, the callback <onupdate> executes the function UpdateDeck in the script
dm.py.
– For the step SupportsDM, the callback <onupdate> executes the function UpdateSupports
in the script dm.py.
– For the step DeckSC, the callback <onupdate> executes the function UpdateDeckSC in the
script sc.py.
– For the step SupportsSC, the callback <onupdate> executes the function UpdateSupportsSC
in the script sc.py.
– For the step Mesh, the callbacks <onreset> and <onupdate> execute the functions Remove-
Controls and CreateMeshControls in the script ds.py.
– For the step Solution, the callback <onrefresh>, <onreset>, and <onupdate> execute
the functions RefreshLoads, RemoveLoads, and CreateLoads in the script ds.py.
– For the step Results, the callback <onrefresh> executes the function RefreshResultsPro-
ject in the script main.py.
• main.py
• dm.py
• ds.py
• sc.py
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 157
Simulation Wizards
Custom help files can contain any valid HTML5 syntax and supported media, such as images and graphs.
You simply place the supported media files in the same folder as the HTML files.
In the following example, the help file step1.html is located in the folder wizardhelp within the
extension folder.
<step name="Geometry" caption="Geometry" version="1" helpFile="wizardhelp/step1.html">
If you give the help files for steps the same names as the steps themselves and then store these files
in a folder named help, you do not need to use the attribute helpFile to reference them. The ex-
tension automatically finds and displays the appropriate help file for each step.
The custom help for a Workbench-based wizard displays by default in a help panel at the bottom of
the wizard. However, you can customize the wizard interface (p. 159). For example, you could change
the location of this panel.
Note:
For information on how AIM displays custom help for wizards (custom templates), see
Providing Custom Wizard Help in the ACT Customization Guide for Discovery AIM.
To provide custom help for the properties that are defined within a step, you can either create HTML
files or define help text directly in the extension's XML file:
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
158 of ANSYS, Inc. and its subsidiaries and affiliates.
Custom Wizard Interfaces
Note:
For HTML files for properties, the recommended practice is to avoid images and to
limit the text to no more than 200 characters.
In the extension's XML file, you use the optional element <uidefinition> to define wizard interface
customizations. The basic definition of this element follows:
<uidefinition>
<layout>
<component/>
<component/>
<component/>
<component/>
</layout>
</uidefinition>
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 159
Simulation Wizards
Layout Definition
The element <layout> defines a single custom layout for the wizard. A separate layout can be defined
for each step in the wizard. The attribute name defines the name of the layout. The name is referenced in
a wizard step in the following format:
LayoutName@ExtensionName
Component Definition
The element <component> defines a single component in a custom layout for the wizard.
• The mandatory attribute name defines the name for the component. The component name is required
to position it next to another component. To do this, the name is used in conjunction with the following
attributes:
– leftAttachment
– rightAttachment
– bottomAttachment
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
160 of ANSYS, Inc. and its subsidiaries and affiliates.
Custom Wizard Interface Example
– topAttachment
The component name is also used in the IronPython script with the method GetComponent().
For instance, in a step, the callback Onrefresh can use the following code:
component = step.UserInterface.GetComponent(ComponentName)
• The mandatory attribtues heightType, height, widthType, and width define the dimensions of
the component. Possible values are as follows:
– FitToContent: The component is to have a default size that is set by ACT. When selected, the at-
tributes height and width become irrelevant.
• The mandatory attribute componentType defines the type of component. Some examples of possible
component types are:
– propertiesComponent
– chartComponent
– tabularDataComponent
– buttonsComponent
– stepsListComponent
• The attributes leftOffset, rightOffset, bottomOffset, and topOffset specify the distance
and the margin between the different components.
Because the basics of constructing a wizard are described elsewhere, the following topics focus solely
on aspects of layout customization:
Defining the Custom Wizard Interface
Defining Functions for the Custom Wizard Layout
Reviewing the Custom Wizard Layouts
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 161
Simulation Wizards
• TabularDataLayout
– This layout has five components: Title, Steps, TabularData, Help, and Submit.
• ChartLayout
– This layout has four components: Title, Steps, Chart, and Submit.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
162 of ANSYS, Inc. and its subsidiaries and affiliates.
Custom Wizard Interface Example
def onrefreshTabularDataSample(step):
comp = step.UserInterface.GetComponent("TabularData")
table = step.Properties["Table"]
comp.SetPropertyTable(table)
def onrefreshChartSample(step):
table = step.PreviousStep.Properties["Table"]
tableValue = table.Value
rowCount = table.RowCount
x = []
y = []
for rowIndex in range(0, rowCount):
x.append(tableValue["Table/Time"][rowIndex].Value.Value)
y.append(tableValue["Table/Pressure"][rowIndex].Value.Value)
comp = step.UserInterface.GetComponent("Chart")
comp.Plot(x, y)
def onresetTabularDataSample(step):
#nothing to do
pass
Data must be entered into the component TabularData for the Next button in the component
Submit to become enabled.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 163
Simulation Wizards
The component Chart contains the chart generated for the tabular data entered in the previous
step.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
164 of ANSYS, Inc. and its subsidiaries and affiliates.
Debugging
This section provides information about debugging IronPython scripts during extension development:
Debug Mode
ACT Debugger
Debugging with Microsoft® Visual Studio
A short video shows how to load the supplied extension (p. 78) DebuggerDemo in Workbench, add
a custom Pre-Design system and a Static Structural analysis system in the Project Schematic, and
then view the properties of the Pre-Geometry cell, which determine how the model is created. The
video then explains how to start the ACT Debugger (p. 166) and use some of its features. If you are new
to debugging scripts, you can follow along with this video by performing the same actions to learn
how to use the ACT Debugger. To watch this video now, click here.
Note:
The ACT Debugger currently supports debugging scripts for extensions that execute from
the Project page in Workbench and from DesignModeler and Mechanical. It does not yet
support debugging scripts on the Linux platform or from AIM. However, you can use Microsoft
Visual Studio (p. 176) to debug scripts from AIM.
Debug Mode
Regardless of whether you intend to debug scripts in the ACT Debugger (p. 166) or in Microsoft Visual
Studio (p. 176), you must first enable debug mode. To accomplish this, from the AIM or Workbench
menu, you select Tools → Options → Extensions and then select the Debug Mode check box. You
can also select this check box in the settings that become available when you click the gear icon in the
graphic-based Extension Manager (p. 39), which is started from the ACT Start Page (p. 37).
Once debug mode is enabled, you can debug extensions. To help you debug, the debug mode exposes
the following features:
• In AIM and Workbench, the Reload Extensions button displays. This button persists throughout all
native AIM and Workbench AIM tabs when debug mode is enabled so that you can easily reload all
loaded extensions.
• In DesignModeler, the ACT Development toolbar displays. Clicking the second button reloads all
loaded extensions. The other buttons open the ACT Console, the Extensions Log File, the ACT Debug-
ger, and help panel provided on the ACT Start Page.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 165
Debugging
• In Mechanical, the ACT Development group displays on the ribbon's Automation tab. This first button
in this group reloads all loaded extensions. The other buttons open the Extensions Log File, ACT De-
bugger, and help panel provided on the ACT Start Page. To the left, the ACT group includes a button
for opening the ACT Console. To the right of the Automation tab are tabs for any loaded extensions.
Access points for debugging are provided in AIM, DesignModeler, Mechanical, and the Workbench
Project tab.
• In AIM and in the Workbench Project tab, debug mode is enabled as soon as you select the Debug
Mode check box. To debug scripts from AIM, you must use Microsoft Visual Studio. Currently, you
cannot debug scripts on the Linux platform.
• In DesignModeler and Mechanical, debug mode is not enabled until you restart the product. After se-
lecting the Debug Mode check box, you must exit and restart the product to make debugging func-
tionality available.
When debug mode is enabled, you can use a debugger to observe the run-time behavior of IronPython
scripts in loaded extensions. You typically use a debugger to either verify that correct values are being
stored for variables or determine why an exception is thrown. Once you have finished debugging a
scripted extension, you can use the binary extension builder (p. 46) to compile it into a binary extension
(WBEX file) that you can share with others.
ACT Debugger
The ACT Debugger provides state-of-the-art capabilities for debugging the IronPython scripts for ACT
extensions. With a graphical user interface that includes a simplified version of the ACT Console (p. 50),
you can reproduce, diagnose, and resolve script issues faster and easier.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
166 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT Debugger
Because the ACT Debugger performs product-specific initialization, always start it from the ANSYS
product where you intend to execute the extension. This ensures that the debugger attaches to the
correct process. For example, assume that you start the debugger from the Workbench Project tab
and then try to debug an extension that is meant to be executed in Mechanical. Because you did not
open the debugger from Mechanical, you cannot debug the Mechanical extension.
When the extension is to execute from the Workbench Project tab, start the debugger using one of
the following methods:
• From the ACT Start Page (p. 37), click ACT Debugger.
When the extension is to execute from DesignModeler, in the ACT Development toolbar, click the
button for starting the debugger. In the following figure, this is the third button.
When the extension is to execute from Mechanical, in the ACT Development group on the ribbon's
Automation tab, click the button for starting the debugger. In the following figure, this is the third
button.
Once the debugger starts, the Sources pane displays a folder for each loaded extension, which contains
its XML file and IronPython scripts. If you expand a folder and click a file, you can see and edit this
file in the pane to the right.
To begin debugging a loaded extension, you expand the folder for the extension, click a script, and
then set breakpoints (p. 169). When you click the button in the debugger toolbar for attaching to the
ANSYS product where the extension is to execute, the debugger begins listening to this product as
it executes the underlying scripts. By viewing this product next to the debugger, you can observe
the run-time behavior of the attached extension to reproduce unexpected behaviors, investigate issues,
and test script changes.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 167
Debugging
The debugger allows you to execute the extension while inspecting the logic and memory of the
script, step by step, directly in the source file. You can pause execution at breakpoints, explore and
edit variables, browse the stack of function calls, and even change the script.
• Breakpoints: Locations in the script where the debugger is to pause so that you can investigate the state
of the extension.
• Call stack: List of executed method calls that have led to the current statement, ordered from deepest
(most nested) to shallowest (top level).
• Console: Tool for interactively testing commands during development and debugging.
• Exceptions: Error states that occur while a script is executed. You want to pause the debugger when an
exception is thrown so that you have a chance to examine it before a handler is invoked.
• Locals: Variables that are currently available for the active location in the script.
• Watches: Variables and expressions that you want to observe and evaluate during debugging.
To view the files for a loaded extension, you expand the extension's folder. When you select a script,
it opens in an editor in the pane to the right, where you can set breakpoints (p. 169).
If you edit or save an XML file or script, the debugger automatically reloads the extension, thereby
providing an efficient method for interactive testing of your changes.
The following figure shows the supplied extension (p. 78) DebuggerDemo loaded. If you want, you
can use the Extension Manager (p. 39) to install and load this extension. You can then follow along
with the short video on the ACT Debugger to learn how to use some of its features.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
168 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT Debugger
In this figure, the debugger is started from the Workbench Project tab, and it is attached and listening
to the extension DebuggerDemo. A breakpoint is set at line 13 in the script main.py, where the
debugger is currently paused. Line numbers for lines with breakpoints are highlighted in red. The
line at which the debugger is paused is highlighted in yellow.
Note:
The Log tab in the lower right pane displays the Extensions Log File (p. 45).
Setting Breakpoints
Breakpoints are essential to debugging. You set a breakpoint in each script location where you want
to pause the debugger to investigate the current state of the extension. When the debugger encounters
a breakpoint, it pauses extension execution, placing you in break mode. Most debugger features are
available only in break mode.
Repeatedly clicking to the left of a line number switches between setting and clearing a breakpoint.
To set or clear breakpoints, do not click the line number but to the left of it. You can set a breakpoint
on any line with an executable statement. While it is possible to set a breakpoint on a commented
line, blank line, or a declaration of a namespace, class, or method, such a breakpoint serves no purpose.
In the extension DebuggerDemo, assume that you have inserted breakpoints at lines 13 and 24 in
the script main.py.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 169
Debugging
Also assume that you have set a breakpoint at line 12 in the script mechanical.py. In the lower
right pane of the debugger, the Breakpoints tab displays all three breakpoints that are currently set,
displaying the filename first and the line number second:
You can double-click any entry in the Breakpoints tab to have the debugger move to this script and
line. This tab is especially handy when you are debugging large or complex scripts.
After setting one or more initial breakpoints, you click the button in the debugger toolbar for attaching
to the product so that the debugger begins listening to the execution of the extension. In the lower
left corner of the debugger, the status bar displays operational information.
At a breakpoint, you can use buttons in the debugger toolbar (p. 171) to progress through script
statements to investigate the state of the extension. In break mode, you can also set new breakpoints
and clear existing ones. After you finish debugging, you can click the debugger toolbar button for
clearing all breakpoints from the loaded scripts.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
170 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT Debugger
Navigating Scripts
Merely opening and attaching the debugger to an extension does not engage interactive debugging
activity. You must also perform actions within the target product that call a loaded extension's script.
Only then are breakpoints hit and execution details populated. For example, in the Workbench Project
tab, to invoke the callback update() for the extension DebuggerDemo, you right-click the Pre-
Geometry cell in the custom Pre-Design system and select Update.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 171
Debugging
The debugger listens as the script is executed. When it encounters the first breakpoint in main.py,
the debugger pauses execution, highlighting the line in yellow to indicate that it is the next statement
to execute.
In the debugger toolbar (p. 171), you have a button for stepping over to the next function call. Addi-
tionally, if the current breakpoint is for a method, you have buttons for stepping into the method
call and then subsequently for stepping back out of the method call. You can also use the shortcut
keys assigned to these buttons.
When execution of the extension is paused at a breakpoint, all functions, variables, and objects remain
in memory. Using the various tabs in the debugger's lower panes, you can look at current values and
review the call stack to determine if script violations or issues exist.
When you step over, into, or out of a function, the debugger automatically follows line execution. If
you double-click a breakpoint, the debugger takes you to the script and line where this breakpoint
is set. Similarly, when execution is paused, you can double-click an entry in the call stack (p. 172) to
have the debugger take you to the script and corresponding line.
When the function OnUpdate() is executed, it calls the function LoadData(), which calls the
function readFile(), which calls the function buildPath(). At the breakpoint set on line15, the
debugger pauses while the function readFile() is executing.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
172 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT Debugger
If you click an entry in the call stack, the debugger takes you to the corresponding script and line.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 173
Debugging
In the Locals tab, you inspect variables to observe how values change as you step through subsequent
statements. Clicking the arrow to the left of a variable switches between expanding and hiding its
properties. By navigating through these variables, you can verify that they are storing the values that
you expect at particular points in the execution of the script.
For the extension DebuggerDemo, assume that after completing the update to the Pre-Geometry
cell, you inserted a breakpoint at line 50 of the script main.py. When you right-click this same
cell in the Project Schematic and select Edit, the debugger listens as the extension executes, pausing
execution at line 50.
In the Console tab, you can access the available local variables and change values. For example,
typing system1 and pressing the Enter key accesses your system:
As you execute commands in the console, the debugger reevaluates entries in both the Locals and
Watch Expressions tabs.
As you advance the debugger through the execution of the script, you use this tab to see how values
change for the available watched variables. For the extension DebuggerDemo, assume that you have
finished setting up the geometry in the Project Schematic. In the Outline view in Mechanical, you
can right-click Solution in the tree and select Insert → Debugger Result.
To debug the script that Mechanical executes, you must first detach from the Workbench Project tab
and close the debugger. You must then start the debugger from Mechanical and click the button in
the debugger toolbar for attaching to Mechanical.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
174 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT Debugger
To have the debugger pause where the callback <evaluate> is adding the custom debugger result
to the Mechanical tree, you can insert a breakpoint at the line where the result values are collected.
In the Outline view in Mechanical, you then right-click Solution again and select Evaluate All Results
to invoke the callback <evaluate>.
When the debugger pauses where the results values are collected, in the Watch Expressions tab,
you can enter ids_list[3] in the Name column to see the index 3 value as the script executes:
To view the entire list of values for this IDs list, you can type the name for the variable in the Name
column and then watch as the values populate:
In the Console tab, you can directly manipulate this variable. After entering ids_list to access the
list values, you can enter ids_list[3]=ids_list[3]*5 to multiply the index 3 value by 5,
changing it from 4 to 20. Entering ids_list again would allow you to see the changed value.
In the Watch Expressions tab, the value for the index 3 value changes accordingly:
You can navigate through the variables that you've added in the Watch Expressions tab and in some
cases modify values in the Value column to see the effect. For example, for ids_list(3), rather
than programmatically changing the value in the Console tab, you can change the value for
ids_list[3] directly to 20 in the Value column.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 175
Debugging
Any variables that cannot be set in the Watch Expressions tab are grayed out. If an expression has
a syntax error, the Value column displays the same compiler error as you would see when entering
this command in the console.
Handling Exceptions
Exceptions are error states that occur while a script is executed. When an exception is thrown, the
debugger automatically stops and displays an error message, as shown in the following figure. When
you click OK, you return to the debugger, where you can use the various tabs to debug the script
and understand the exception. However, after an exception occurs, you cannot continue debugging
the remaining statements. The script will finalize its execution without you having the ability to debug
it.
3. For the Attach to field, verify that the code type Managed (v.4.0) is selected.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
176 of ANSYS, Inc. and its subsidiaries and affiliates.
Debugging with Microsoft® Visual Studio
Refer to Microsoft Visual Studio documentation for information on using this program to debug your
script.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 177
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
178 of ANSYS, Inc. and its subsidiaries and affiliates.
ACT Customization Guides for Supported ANSYS Products
Once you are familiar with the general ACT usage information in this guide, you can explore the ACT
guides for customizing supported ANSYS products:
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 179
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
180 of ANSYS, Inc. and its subsidiaries and affiliates.
Appendix A. Extension Elements
This appendix describes the basic XML elements used in an ACT extension. The XML file for an extension
always begins with the element <extension> (p. 181). For comprehensive information on XML elements,
see the ANSYS ACT XML Reference Guide.
<extension>
The XML file has the element <extension> as the base tag or root node. It provides initialization and
configuration information for the extension. All other elements fall under the element <extension>.
<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>
Descriptions follow of the secondary elements and attributes for the element <extension>. Click the
links to view the corresponding sections in this appendix.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 181
Extension Elements
Mandatory attribute.
version="[version number (integer)]"
name
Name of the extension.
Mandatory attribute.
name="[extension name (string)]"
minorversion
Minor version of the extension.
Optional attribute.
minorversion="[minor version number (integer)]"
debug
Specifies if the scripted version of the extension should be opened in the debug mode.
Optional attribute.
icon
Icon for the extension.
Optional attribute.
<application>
Defines a new application.
<application>
<callbacks> ... </callbacks>
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
182 of ANSYS, Inc. and its subsidiaries and affiliates.
<extension>
<description>
<description>
<panel>
</application>
<description>
Description of the application.
<Panel>
Defines a panel to display.
Mandatory.
class
Class name of the controller of the application.
Optional.
context
Defines a context or combination of contexts (separated using '|') in which the application can be
launched.
Optional.
MainPanel
Name of the first panel to display.
Optional.
<OnApplicationInitialized>
Invoked when the application initializes.
<OnApplicationStarted>
Invoked when the application starts.
<appstoreid>
Defines the unique identifier to use in the ANSYS Store. This tag must be written exclusively in
lowercase.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 183
Extension Elements
<assembly>
Defines the assembly to be loaded.
<assembly src="[file name]" namespace="[namespace]"/>
Mandatory.
namespace
Namespace to import.
Mandatory.
namespace="[namespace]"
src
Name of the DLL file to import.
Mandatory.
src="[file name]"
<author>
Defines the author of the extension.
<description>
Defines the description of the extension.
<guid>
Defines the GUID (global unique identifier) for the extension.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
184 of ANSYS, Inc. and its subsidiaries and affiliates.
<extension>
A GUID ensures that two different extensions with the same name are never in conflict. A GUID must
be added before the first build of a binary extension and must never changed. When you update an
extension, add features to an extension, or create a new version of the extension, never change the
GUID.
Because ACT considers two extensions with the same GUID as the same extension, you can change
the extension name in a new version of the extension without compromising compatibility with
projects that were saved with the older version of the extension.
Optional.
shortid="[extension name (string)]"
<interface>
Defines the user interface for the extension.
<extension version="[version id (integer)]" name="[extension name (string)]"
<interface context="[Project | Mechanical]">
...
</interface>
<filter>
Defines a filter.
<images>
Defines the default folder where images to be used by the extension are stored.
<images>[folder]</images>
<toolbar>
Defines a toolbar.
<toolbar name="[toolbar internal name (string)]" caption="[toolbar display name (string)]">
<entry>...</entry>
</toolbar>
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 185
Extension Elements
Mandatory.
context="[context name]”
<IsAnalysisValid>
Called to check if an analysis is valid.
<isanalysisvalid>[function(solver)]</isanalysisvalid>
<OnActiveObjectChange>
Called when the active object is changed.
<OnAfterGeometryUpdate>
Called after the geometry has been updated.
<OnAfterRemove>
Called after the object has been removed.
<OnAfterSolve>
Called after an analysis has been solved.
<onaftersolve>[function(analysis)]</onaftersolve>
<OnBeforeGeometryUpdate>
Called before the geometry is starts to update.
<OnBeforeSolve>
Called before an analysis starts to solve.
<onbeforesolve>[function(analysis)]</onbeforesolve>
<OnBodySuppressStateChange>
Called when the body suppress state has been changed.
<OnDraw>
Called when the application is drawn.
<OnDraw2D>
Called when the application is drawn.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
186 of ANSYS, Inc. and its subsidiaries and affiliates.
<extension>
<ondraw>[function()]</ondraw>
<OnInit>
Called when the given context is initialized.
<oninit>[function name(application context)] </oninit>
<OnLoad>
Called when a project is loaded.
<onload>[function(currentFolder)]</onload>
<OnMeshCleaned>
Called when the mesh is cleaned.
<OnMeshGenerated>
Called when the mesh is generated.
<OnPostFinished>
Called when the postprocessing ends for a given analysis.
<onpostfinished>[function(analysis)]</onpostfinished>
<OnPostStarted>
Called when the postprocessing starts for a given analysis.
<onpoststarted>[function(analysis)]</onpoststarted>
<OnReady>
Called when the application is fully loaded and in a "ready" state.
<OnSave>
Called when the project is saved.
<onsave>[function(currentFolder)]</onsave>
<OnTerminate>
Called when the given context is terminated.
<onterminate>[function(context)]</onterminate>
<Resume>
Called when a project is loaded.
<resume>[function(binary reader)]</resume>
<Save>
Called when a project is saved.
<save>[function(binary writer)]</save>
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 187
Extension Elements
<licenses>
Defines a licenses collection for the extension.
<script>
Specifies the IronPython script referenced by the extension.
<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 extension definition file or use the
attribute src to specify the path to the script.
An additional script can be specified by adding a new element <script>. For example:
<script src="[Path]\filename.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" />
Optional.
compiled="[false(default) | true]"
src
Specifies the IronPython script referenced by the extension.
Optional.
src="[python file name (string)]"
<simdata>
Defines a general section that stores all user object definitions.
The element <simdata> information pertains specifically to the simulation environment. Child ele-
ments are used for integrating custom simulation features into the application. These main features
are nested as child elements within the <simdata> element.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
188 of ANSYS, Inc. and its subsidiaries and affiliates.
<extension>
<simdata>
<load>
<object>
<optimizer>
<solver>
<geometry>
<result>
<step>
<ExtensionObject>
<Sampling>
</simdata>
<object>
Defines a simulation object.
<object>
<callbacks> ... </callbacks>
<property>
<propertygroup>
<propertytable>
<target>
</object>
<optimizer>
Defines an optimizer.
<optimizer>
<callbacks> ... </callbacks>
<property>
<propertygroup>
<propertytable>
</optimizer>
<solver>
Specifies a third-party solver to be used in the simulation.
<solver>
<callbacks> ... </callbacks>
<property>
<propertygroup>
<propertytable>
</solver>
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 189
Extension Elements
<geometry>
Defines a geometry feature.
<geometry>
<callbacks> ... </callbacks>
<property>
<propertygroup>
<propertytable>
</geometry>
<result>
Defines a custom result.
<result>
<callbacks> ... </callbacks>
<property>
<propertygroup>
<propertytable>
</result>
<step>
Defines a step in a wizard.
<step>
<callbacks> ... </callbacks>
<description>
<property>
<propertygroup>
</step>
<ExtensionObject>
Extends the extension object definition. (Inherited from DesignXplorer SimEntity)
<extensionobject>
<callbacks> ... </callbacks>
<property>
<propertygroup>
<propertytable>
<target>
</extensionobject>
<Sampling>
Defines a custom sampling.
<sampling>
<callbacks> ... </callbacks>
<property>
<propertygroup>
<propertytable>
<target>
</sampling>
Mandatory.
context="[Project | targetproduct | targetproduct]">
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
190 of ANSYS, Inc. and its subsidiaries and affiliates.
<extension>
<templates>
Defines a collection of control templates.
<templates>
<controltemplate name="[template name (string)]" version="[version id (integer)]">
<propertygroup>
<property> ... </property>
<propertygroup> ... </propertygroup>
</propertygroup>
</controltemplate>
</templates>
<uidefintion>
Defines one or more layouts that can be used for wizards.
<uidefinition>
<layout>
</uidefinition>
<wizard>
Defines one or more wizards within the extension.
<wizard>
<author>
<description>
<step></step>
</wizard>
Mandatory.
<name>
Name of the wizard.
Mandatory.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 191
Extension Elements
<version>
Version of the wizard.
Mandatory.
<caption>
Caption for the wizard.
Optional.
<icon>
Icon for the wizard.
Optional.
<layout>
Layout of the wizard.
Optional.
<description>
Description of the wizard.
Optional.
<workflow>
Defines custom workflows composed of process integration items (tasks and task groups). Defines
the top-level workflow tag within an ACT app.
<workflow>
<callbacks> ... </callbacks>
<taskgroups>
<tasks>
</workflow>
<TaskGroups>
Task groupings to be exposed as organized blocks within the workflow.
<Tasks>
Tasks exposed by this workflow.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
192 of ANSYS, Inc. and its subsidiaries and affiliates.
<extension>
Optional.
class
Class name of the controller of the object. (Inherited from SimEntity)
Optional.
context
Context (application) to which this workflow applies.
Mandatory.
contextual
Indicates whether the object must be displayed in the contextual menu. (Inherited from SimEntity)
Optional.
icon
Icon for the object. (Inherited from SimEntity)
Optional.
name
Name of the object. (Inherited from SimEntity)
Mandatory.
version
Version of the object. (Inherited from SimEntity)
Mandatory.
<onafterdesignpointchanged>
Invoked after the design point changes.
<onbeforetaskreset>
Invoked before the task is reset back to its pristine, new state.
<onaftertaskreset>
Invoked after the task has been reset back to its pristine, new state.
<onbeforetaskrefresh>
Invoked before the task consumes all upstream data and prepares any local data for an ensuing update.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 193
Extension Elements
<onaftertaskrefresh>
Invoked after the task has consumed all upstream data and has prepared any local data for an ensuing
update.
<onbeforetaskupdate>
Invoked before the task generates all broadcast output types that render the component fully solved.
<onaftertaskupdate>
Invoked after the task has generated all broadcast output types that render the component fully solved.
<onbeforetaskcreate>
Invoked before the task is created based on an underlying template.
<onaftertaskcreate>
Invoked after the task has been created based on an underlying template.
<onbeforetaskdelete>
Invoked before the task is removed from a task group.
<onaftertaskdelete>
Invoked after the task has been removed from a task group.
<onbeforetaskduplicate>
Invoked before an identical, yet independent, clone of the task is created.
<onaftertaskduplicate>
Invoked after an identical, yet independent, clone of the task has been created.
<onbeforetasksourceschanged>
Invoked before the task processes a change in upstream sources.
<onaftertasksourceschanged>
Invoked after the task has processed a change in upstream sources.
<onbeforetaskcanusertransfer>
Invoked before the task checks whether it can consume data from a specific upstream task.
<onaftertaskcanusertransfer>
Invoked after the task has checked whether it can consume data from a specific upstream task.
<onbeforetaskcanduplicate>
Invoked before the task checks whether it permits duplication.
<onaftertaskcanduplicate>
Invoked after the task has checked whether it permits duplication.
<onbeforetaskstatus>
Invoked before the task calculates its current state.
<onaftertaskstatus>
Invoked after the task has calculated its current state.
<onbeforetaskpropertyretrieval>
Invoked before the task determines the visibility of its property-containing objects.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
194 of ANSYS, Inc. and its subsidiaries and affiliates.
<extension>
<onaftertaskpropertyretrieval>
Invoked after the task has determined the visibility of its property-containing objects.
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates. 195
Release 2020 R1 - © ANSYS, Inc. All rights reserved. - Contains proprietary and confidential information
196 of ANSYS, Inc. and its subsidiaries and affiliates.