ansys act developers guide

330
ANSYS ACT Developer's Guide Release 16.2 ANSYS, Inc. July 2015 Southpointe 2600 ANSYS Drive ANSYS Customization Suite Canonsburg, PA 15317 ANSYS, Inc. is certified to ISO 9001:2008. [email protected] http://www.ansys.com (T) 724-746-3304 (F) 724-514-9494

Upload: wilder-molina

Post on 09-Dec-2015

961 views

Category:

Documents


118 download

DESCRIPTION

tutorial

TRANSCRIPT

Page 1: ANSYS ACT Developers Guide

ANSYS ACT Developer's Guide

Release 16.2ANSYS, Inc.July 2015Southpointe

2600 ANSYS Drive ANSYS Customization SuiteCanonsburg, PA 15317 ANSYS, Inc. is

certified to ISO9001:2008.

[email protected]://www.ansys.com(T) 724-746-3304(F) 724-514-9494

Page 2: ANSYS ACT Developers Guide

Copyright and Trademark Information

© 2015 SAS IP, Inc. All rights reserved. Unauthorized use, distribution or duplication is prohibited.

ANSYS, ANSYS Workbench, Ansoft, AUTODYN, EKM, Engineering Knowledge Manager, CFX, FLUENT, HFSS, AIMand any and all ANSYS, Inc. brand, product, service and feature names, logos and slogans are registered trademarksor trademarks of ANSYS, Inc. or its subsidiaries in the United States or other countries. ICEM CFD is a trademarkused 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.

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 productsand documentation are furnished by ANSYS, Inc., its subsidiaries, or affiliates under a software license agreementthat contains provisions concerning non-disclosure, copying, length and nature of use, compliance with exportinglaws, warranties, disclaimers, limitations of liability, and remedies, and other provisions. The software productsand documentation may be used, disclosed, transferred, or copied only in accordance with the terms and conditionsof that software license agreement.

ANSYS, Inc. is certified to ISO 9001:2008.

U.S. Government Rights

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 softwareand third-party software. If you are unable to access the Legal Notice, please contact ANSYS, Inc.

Published in the U.S.A.

Page 3: ANSYS ACT Developers Guide

Table of Contents

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Add-Ins and Customization .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Defining the Extension Concept .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Project and Extensions .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Defining an Extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Basic Extension Definition .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3XML Extension Definition .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Python Callbacks for Extensions .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Customizing an Application .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Extensions and Libraries ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Using Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Extension Types .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Loading and Unloading Extensions .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Installing and Uninstalling an Extension .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Compiling an Extension .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Generation Options for Extensions Handling .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

Licensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21Extension Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Common Capabilities ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23Defining Toolbars and Toolbar Buttons .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23Binding Toolbar Buttons with ACT Objects ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26Defining Pop-up Dialogs .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27Storing Data in Your Extension .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

ACT-Based Properties ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29Creating Property Groups .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Using PropertyGroup and PropertyTable .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29Using Templates to Create Property Groups .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

Parameterizing Properties ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34Common Property Parameterization Processes .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34Parameterization in ANSYS Mechanical ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Defining Input Parameters in ANSYS Mechanical ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35Defining Output Parameters in ANSYS Mechanical ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

Parameterization in ANSYS DesignModeler ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37Parameterization in a Third-Party Solver ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

Defining Parameters under a Load in a Third-Party Solver ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39Defining Parameters in Analysis Settings in a Third-Party Solver ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39Defining Parameters under Results in a Third-Party Solver ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

Defining DesignXplorer Properties ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40Properties in the DX Interface .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40Additional Attributes for DX Extensions .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42Advanced Usage Examples .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

Managing Dependencies between Properties ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42Controlling Property Visibility with a Callback .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

DOE Example .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43Optimization Example .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

Modifying an Attribute with a Callback .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43DOE Example .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44Optimization Example .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

Capabilities for ANSYS Mechanical ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44Adding a Pre-Processing Feature in ANSYS Mechanical ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

iiiRelease 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 4: ANSYS ACT Developers Guide

Adding a Post-Processing Feature in ANSYS Mechanical ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50Creating Results with Imaginary Parts ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56Obsolete ”OnStartEval” and “GetValue” Callbacks .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56Connecting to a Third-Party Solver ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

Third-Party Solver Connection Extension .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57Post Processing .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61Load and Save Data .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

Capabilities for ANSYS DesignModeler ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65Geometry Definition in the XML File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65Geometry Definition in the Python File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

Functions Associated with the <ongenerate> Callback .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68Functions Associated with the <onaftergenereate> Callback .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

Capabilities for ANSYS DesignXplorer .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71The Design Exploration Process .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

The DX Component .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73The DOE Component .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74The Optimization Component .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

The DX Extension .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75Implementing a DX Extension .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

Implementation Requirements .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75DX Extension Definition and Configuration .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75DX Extension Capabilities ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

Main Capabilities ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78Optional Capabilities ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

Notes on Method Class Implementation .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80Notes on Monitoring .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80Notes on Results ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

Capabilities for Custom ACT Workflows in Workbench .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82The Custom Workflow Creation Process .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83Creating the Extension Definition XML File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

Defining a Task .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86Defining a Taskgroup .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89

Creating the IronPython Script ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89Upstream Data Consumption (Input) ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89Data Generation (Output) ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89Convenience APIs ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

Capabilities for ANSYS AIM .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90Adding a Pre-Processing Feature in ANSYS AIM Structural ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

Custom Load Definition in the XML File .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91Custom Load Definition in the Python File .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

Creating a Custom Object to Merge Existing AFD Features (Process Compression) ... . . . . . . . . . . . . . . . . . . . . . . . . 94Fluidic System Definition in the XML File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94Fluidic System Definition in the IronPython File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

Custom Guided Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99Types of Guided Processes .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99Creating Guided Processes .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

Parts of a Guided Process .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100The XML Extension Definition File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

Example: XML Extension File for a Project Wizard .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101The IronPython Script ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

Example: IronPython Script for a Project Wizard .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105The Custom Help Files ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.iv

ANSYS ACT Developer's Guide

Page 5: ANSYS ACT Developers Guide

Wizard Help ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107Custom Template Help ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

Installing and Loading Guided Processes .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108Using Guided Processes .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

Using a Workbench or Target Application Wizard .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109Launching a Wizard .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109The Wizard Interface .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110Entering Data in a Wizard .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111Exiting a Wizard or Project ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112

Using an AIM Custom Template .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112Entering Data in a Custom Template .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113Accessing Custom Help .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

Viewing the Guided Process Log File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115APIs Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

APIs for ANSYS Mechanical ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117Directly Accessing an Object ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118Handling Property Types .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118API Examples: Model Object ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

Geometry: Point Mass .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119Mesh: Mesh Control ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119Connections: Frictionless Contact and Beam ..... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120Analysis: Load Magnitude .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120Result: Total Deformation Maximum ..... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

API Examples: TraverseExtension .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123Traversing the Geometry .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123Traversing the Mesh .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125Traversing Results ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126

User Interface and Toolbars ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128APIs for ANSYS Design Modeler ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128

Using the Selection Manager in DesignModeler .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128Working with the Current Selection ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129Creating a New Selection and Adding Entities ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

Creating Primitives .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129Creating a Sheet Body .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130Creating a Wire Body .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131Creating a Solid Body .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

Applying Operations .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133Applying the Extrude Operation .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134Applying the Transform Edges to Wire Tool ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

APIs for ANSYS DesignXplorer ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136DOE APIs ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136

DOE Architecture .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136The Sampling Process .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137

Optimization APIs ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138Optimization Architecture .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138The Optimization Process .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139

Associated Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141Query to Material Properties ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141Units Conversion .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142MAPDL Helpers .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144Journaling Helper .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

XML Extension Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

vRelease 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

ANSYS ACT Developer's Guide

Page 6: ANSYS ACT Developers Guide

<extension> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147<GUID> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148<script> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148<interface> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

<images> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149<callbacks> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149<toolbar> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

Child Elements .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153<workflow> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

<tasks> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154<task> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

<callbacks> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155<contextsmenus> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156<propertygroup> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156<property> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157<parameters> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158<inputs> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159<outputs> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159

<taskgroups> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159<taskgroup> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160

<simdata> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161<load> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

<callbacks> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162<property> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

<callbacks> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169<propertygroup> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171<propertytable> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172

<result Element> .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172<callbacks> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174<property> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177<propertygroup> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177<propertytable> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177

<solver> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177<callbacks> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178<property> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181<propertygroup> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181<propertytable> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181

<sampling> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181<callbacks> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182<OnCreate> and <OnRelease> Callbacks .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183<canRun> and <QuickHelp> Callbacks .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

<optimizer> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185<callbacks> Element .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186

<OnCreate> and <OnRelease> Callbacks .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188<canRun> and <QuickHelp> Callbacks .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188<Description>, <Configuration>, and <Status> Callbacks .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190

XML File Definition .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191Development and Debugging Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199

Prerequisites .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199Debug Mode .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199ACT Console Extension .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202Debugging an Extension .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.vi

ANSYS ACT Developer's Guide

Page 7: ANSYS ACT Developers Guide

Debugging with Microsoft® Visual Studio .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204Using Python Tools for Visual Studio® .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204

Advanced Programming in C# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207Initialize the C# Project ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207C# Implementation for a Load .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207C# Implementation for a Result ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208

Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213

ANSYS Mechanical Extension Examples .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213Von-Mises Stress as a Custom Result ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213An Edge-Node Coupling Tool ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217

DesignXplorer Extension Examples .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222DOE Extension Examples .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222Optimization Extension Examples .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222

Custom ACT Workflows in Workbench Examples .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223Custom User-Specified GUI Operation .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223

XML Extension Defintion File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223IronPython Script ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224

Custom, Lightweight, External Application Integration with Parameter Definition .... . . . . . . . . . . . . . . . . . . . . . . . 224XML Extension Definiton File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225IronPython Script ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226

Custom, Lightweight, External Application Integration with Custom Data .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228XML Extension Definiton File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228IronPython Script ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229

Material Transfer ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231XML Extension Definition File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232IronPython Script ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233Material File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233

Mesh Transfer ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234XML Extension Definition File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235IronPython Script ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236

Custom Transfer ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236XML Extension Definition File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237IronPython Script ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238

Parametric ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239XML Extension Definition File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239IronPython Script ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240

Custom Guided Process Examples .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240Workbench Project Wizard .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240

XML Extension Definition File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240IronPython Script ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243

Target Application Wizard (DesignModeler) ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246XML Extension Definition File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246IronPython Script ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249

Target Application Wizard (Mechanical) ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250XML Extension Definition File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250IronPython Script ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252

Mixed Wizard .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254XML Extension Definition File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254IronPython Script ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260

AIM Custom Template .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260XML Extension Definition File ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260

viiRelease 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

ANSYS ACT Developer's Guide

Page 8: ANSYS ACT Developers Guide

IronPython Script ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262Defining Custom Help .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263

A. ANSYS Workbench Task Inputs and Outputs .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265B. Data Transfer Types .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.viii

ANSYS ACT Developer's Guide

Page 9: ANSYS ACT Developers Guide

Introduction

Add-Ins and Customization

ANSYS Workbench is built on a modular architecture that allows you to extend the functionality of theframework using add-in development.

The ANSYS Workbench Framework Software Developer's Kit (SDK) is designed to manage data andworkflow, allowing you to integrate ANSYS tools with third-party applications at the framework level.In contrast, the Application Customization Toolkit (ACT) is designed to allow customizations at the ap-plication level. These customizations are done with the goal of inserting specific needs within onegeneral process. Using ACT in the ANSYS Mechanical application, the customizations include specializedloads and post processing. You can also use ACT to customize ANSYS DesignModeler, ANSYSDesignXplorer, and ANSYS AIM. Both ACT and the SDK are part of the ANSYS Customization Suite.

ACT provides internal mechanisms that allow you to customize an ANSYS Workbench application withoutneeding to compile external code or link with existing ANSYS libraries.

ACT manages the interfaces between the standard application and the additional customization so thatthey will interact accurately.

This document describes the steps for creating a custom application, or extension, with ACT. The examplesuse ANSYS Mechanical, ANSYS DesignModeler, ANSYS DesignXplorer, and ANSYS AIM as the target ap-plications.

The examples shown are basic ones and intended as a primer. Note that the development of extensionsrequires some knowledge of IronPython and XML. For extensions that customize the ANSYS solver,knowledge of APDL is also required.

The examples included were written and tested on all Windows platforms.

Defining the Extension Concept

ACT provides the ability to create extensions that integrate a set of customized features with thestandard application. This Developer's Guide is primarily intended for those developing the extensionsthat provide additional capabilities to ANSYS tools. However, this guide also includes information forthe end user who will be managing the extensions.

ACT can manage an entire set of extensions. When desired, the ANSYS Mechanical, DesignModeler,DesignXplorer, and AIM applications can be customized by loading a set of extensions. In that case,each extension provides its own customization level, and the end user can define a personal configur-ation based on the extensions previously loaded in ANSYS Workbench. Consequently, the level of cus-tomization is directly dependent on the choices that the end user made before opening the customizedapplication.

For more detailed information on defining extensions, see Defining an Extension (p. 3).

1Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 10: ANSYS ACT Developers Guide

Project and Extensions

Once the ANSYS Workbench project has been created and saved using extensions developed usingACT, any further use of the project must integrate any previously used extensions. If these extensionsare available, then ANSYS Workbench loads the extensions automatically when the project is opened.In the case where an expected extension has not been detected, then an error message occurs. Theavailability of extensions is discussed in more detail in Defining an Extension (p. 3).

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.2

Introduction

Page 11: ANSYS ACT Developers Guide

Defining an Extension

ACT has two basic components:

• XML is used to define and configure the content of the extension.

• Python script functions are used to respond to user/GUI interactions and implement the behavior of theextensions. Typically, the Python functions are invoked through the different events or callbacks managedby the extension.

An extension can potentially be created using additional components such as external Python librariesor even C# code. However, the two components described above represent the basic definition for anextension.

Basic Extension Definition

This section refers to a simple extension ExtSample that customizes the ANSYS Mechanical application.Depending on the application to be customized, the content of the extension differs but the main or-ganization of an ACT extension remains consistent with the one presented in this section whatever thetargeted application.

This extension adds a toolbar with one button to the user interface of ANSYS Mechanical. When thisbutton is clicked, a dialog box appears and displays the message "High five! ExtSample1 is a success!".

Figure 1: Extension Configuration File Hierarchy (p. 4) illustrates the ExtSample1 configuration. Notethat the XML file ExtSample1.xml a nd the ExtSample1 folder lie at the same level in a given folder.A common name has to be used for both the XML file and the folder of the extension.

3Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 12: ANSYS ACT Developers Guide

Figure 1: Extension Configuration File Hierarchy

The next figure shows the contents of the ExtSample1 folder. The file sample1.py contains the Pythonscript needed to fulfill the behavior of the example extension and the images folder holds the icon fileused by the GUI of the extension.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.4

Defining an Extension

Page 13: ANSYS ACT Developers Guide

Figure 2: Extension Folder Content

Figure 3: Images Folder Content (p. 5) shows the contents of the images folder. The icon file hand.bmpis used by the example extension to expose the specific button from the toolbar. The BMP image formatis the only format supported by the ACT.

Figure 3: Images Folder Content

5Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Basic Extension Definition

Page 14: ANSYS ACT Developers Guide

XML Extension Definition

The XML file used to configure the ExtSample1 extension is named ExtSample1.xml. The contentsof this file are listed below.

<extension version="1" name="ExtSample1"> <guid>e0e0f6c2-b50f-425e-a778-5b3e527f65c1</guid> <script src="sample1.py" /> <interface context="Mechanical"> <images>images</images> <callbacks> <oninit>init</oninit> </callbacks> <toolbar name="ExtSample1" caption="ExtSample1"> <entry name="HighFive" icon="hand"> <callbacks> <onclick>HighFiveOut</onclick> </callbacks> </entry> </toolbar> </interface></extension>

Key elements of the XML file include:

• The extension name in line 1

• The GUID of the extension in line 2

• The Python script file name in line 3

• The interface context in line 4

• The oninit callback method name in line 7

• The toolbar and toolbar button definition in lines 9 through 15

The <entry> tags define the HighFive toolbar button, which uses the icon image from the filehand.bmp. The <onclick> tags define the name of the callback function to invoke when the buttonis selected. The next section addresses the Python script definition of the function HighFiveOut.

The XML extension definition is discussed in more detail in Using Extensions (p. 11).

For more information on the GUID, see Installing and Uninstalling an Extension (p. 13), Compiling anExtension (p. 15), and <extension> Element (p. 147).

Python Callbacks for Extensions

Python script functions are used to respond to user/GUI interactions and implement the extension’sbehavior. As previously discussed, the Python script for ExtSample1 is located inside the filesample1.py.Here are the script file contents.

clr.AddReference("Ans.UI.Toolkit")clr.AddReference("Ans.UI.Toolkit.Base")from Ansys.UI.Toolkit import *def init(context): ExtAPI.Log.WriteMessage("Init ExtSample1...")def HighFiveOut(analysis_obj): MessageBox.Show("High five! ExtSample1 is a success!")

The script contains two functions:

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.6

Defining an Extension

Page 15: ANSYS ACT Developers Guide

• The function init() is called when the application (for example, Mechanical) is opened. The argumentcontext contains the name of the application (“Mechanical”).

• The function HighFiveOut() is called when the user clicks the toolbar button HighFive. As with all<onclick> callback functions, the application passes an instance of the active Analysis object as anargument.

For any function, the global variable ExtAPI represents the main entry point for all the services providedby ACT. As an example, the init() function uses the ILog interface of the ACT to write one messagein the log file. For more information on the available interfaces, see the Application Customization ToolkitReference Guide.

Customizing an Application

In the following figure, the ExtSample1 extension toolbar and HighFive button are now part of theANSYS Mechanical user interface. The context of this extension has been set to “Mechanical.” Con-sequently, this extension was loaded with the Mechanical application. You can refer to Using Exten-sions (p. 11) for more information about the load of extensions.

Figure 4: ExtSample1 Toolbar

The next figure shows an open extension log that demonstrates that ExtSample1 was initialized forthe Mechanical application context.

7Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Customizing an Application

Page 16: ANSYS ACT Developers Guide

Figure 5: ExtSample1 Extension Log

Extensions and Libraries

As you develop extensions to integrate customizations in the application, you can use additional librariesto share Python functions between extensions. Some libraries are installed by default with ACT to helpdevelopers customize the application.

Supported libraries related to the Mechanical application are located in the following folder:

%ANSYSversion_DIR%\..\Addins\AdvancedAddinPackage\libraries\Mechanical

Supported libraries related to the AIM application are located in the following folder:

%ANSYSversion_DIR%\..\Addins\AdvancedAddinPackage\libraries\Study

The libraries included with ACT are described below:

ansys.pyProvides helpers to generate an APDL command block.

chart.pyProvides helpers to generate charts, such as curves and histograms.

materials.pyProvides a set of generic functions to convert data from one unit system to another.

wbjn.pyProvides a tool to communicate data to and from the Workbench project page.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.8

Defining an Extension

Page 17: ANSYS ACT Developers Guide

For more information on these libraries, refer to Associated Libraries (p. 141).

9Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Extensions and Libraries

Page 18: ANSYS ACT Developers Guide

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.10

Page 19: ANSYS ACT Developers Guide

Using Extensions

From the main menu in Workbench, ACT provides a set of capabilities to handle the extensions. Thissection describes these capabilities in detail. Using these capabilities, you have the ability to work withthe extensions as needed during the development and use phases.

Extension Types

ACT handles two different types of extensions. The following sections describe the scripted extensionscomprised of XML and IronPython functions. Another type is binary, resulting from the build of ascripted extension. In essence, the development phase uses scripted extensions. Once those extensionsare complete, the binary extensions are shared by the developer with other users. The way these exten-sions can be used is explained more in detail in Licensing (p. 21).

Loading and Unloading Extensions

Extensions are loaded with an application if they are pre-selected in the Workbench Extension Managertool. Note that this pre-selection is done automatically for extensions that were loaded and saved withthe project. In that case, the extensions to be automatically loaded must be available to the ExtensionManager. If an extension is not found, an error message is written in the Messages window of the mainWorkbench project page and the AIM Messages tab. An example message is shown in Figure 6: ErrorMessage Generated by ACT (p. 11). The message is repeated each time an extension is found.

Figure 6: Error Message Generated by ACT

The Extension Manager tool is available from the Manage Extensions menu, shown below.

Figure 7: Manage Extensions Menu

11Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 20: ANSYS ACT Developers Guide

Figure 8: Extension Manager (p. 12) shows the Extension Manager, which lists the available extensions.Both binary and scripted extensions are listed in this menu. In addition to the name of the extension,the type and version specified in the XML file are also displayed.

Figure 8: Extension Manager

To load an extension, check the Loaded check box for the extension. For binary extensions, it is alsopossible to selected the Load option from the context menu by right-clicking a binary extension, shownin Figure 9: Binary Extension Loading (p. 12).

Figure 9: Binary Extension Loading

To unload an extension, uncheck the Loaded check box or select the Unload option from the right-click context menu.

You can select a set of extensions to be loaded by default in the Extension Manager. These extensionsare automatically loaded when ANSYS Workbench is launched. The selection of default extensions isdone by selecting Load as Default from the right-click context menu. Both scripted and binary extensionsare available for this selection. There is no limit to the number of extensions which can be loaded bydefault. Figure 10: Default Extensions (p. 13) shows two extensions configured to be loaded by default.For these two extensions, the (Default) label is added to the extension name and the Loaded checkbox is automatically checked.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.12

Using Extensions

Page 21: ANSYS ACT Developers Guide

Figure 10: Default Extensions

To remove an extension from the list of extensions to be automatically loaded, select the extensionand select Do Not Load as Default from the right-click context menu, as illustrated in Figure 11: Remov-ing a Default Extension (p. 13).

Figure 11: Removing a Default Extension

The Extension Manager identifies the available extensions based on the directories defined in the ACToptions. For information on how to add directories to this list, see Generation Options for ExtensionsHandling (p. 17).

The default directories used by the Extension Manager are:

%ANSYSversion_DIR%\..\Addins\AdvancedAddinPackage\extensions%APPDATA%\Ansys\v162\AdvancedAddinPackage\extensions

Installing and Uninstalling an Extension

From the Install Extension menu, you can select a binary extension, a WBEX file, for installation.

To install a binary extension:

1. In the Project Schematic window, select Extensions > Install Extension.

13Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Installing and Uninstalling an Extension

Page 22: ANSYS ACT Developers Guide

2. A file selection dialog opens and shows files that end in .wbex.

3. Select the WBEX file for the extension you want to install and select Open.

Extensions installed this way are located in the current user’s Application Data folder and are availablefor loading through the Extension Manager.

Note

When a binary extension is installed, a new folder is created in addition to the WBEX file.Both the folder and the WBEX file are necessary for compatibility with ACT. If you need tomove this new extension to a different folder, make sure that both the folder and the WBEXfile are copied at the same time to the same folder.

Figure 12: Install Extension menu

To uninstall an extension, select the extension in the Extension Manager and select the Uninstall optionin the right-click context menu, as shown in Figure 13: Uninstalling an Extension (p. 14).

Figure 13: Uninstalling an Extension

The process for uninstalling extensions is only available for binary extensions. To uninstall scripted ex-tensions, delete the associated files and directories related to the extension. If you remove a scriptedextension while the Extension Manager is running, it will not appear the next time the Extension Manageris launched.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.14

Using Extensions

Page 23: ANSYS ACT Developers Guide

Compiling an Extension

Compiling an extension means encapsulating a scripted extension into a binary format. This processdoes not require you to use a specific compiler. ACT provides its own process for migrating the extensionto a binary format unreadable by any other user. The encapsulation of the scripted extension, also calledthe build of the binary extension, generates a unique WBEX file. This file contains all the files or direct-ories necessary for the extension. Once the extension is built, it must be installed before it can be used.Installing and Uninstalling an Extension (p. 13) explains how to install a binary extension. The BinaryExtension Builder is available from Extensions > Build Binary Extension, as shown below.

Figure 14: Build Binary Extension Menu

The Binary Extension Builder allows you to define all the required input parameters for building an ex-tension. Figure 15: Binary Extension Builder Interface (p. 15) illustrates the dedicated window that appearswhen the user selects the Build Binary Extension option. When all expected input parameters aredefined, the Build button is activated.

Figure 15: Binary Extension Builder Interface

The Scripted Extension to Build option is populated with a list of scripted extensions from directoriesdefined in the ACT options. Both the name and the version are displayed in the list to avoid any confusionwhen multiple versions of one extension are present. Generation Options for Extensions Handling (p. 17)exposes this process in more detail.

15Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Compiling an Extension

Page 24: ANSYS ACT Developers Guide

Figure 16: Contextual List of Scripted Extensions

Once the scripted extension is defined, you must identify a directory where the binary extension willbe stored. The final required parameter defines a security level. This security level defines if the extensioncan be saved within an ANSYS Workbench project, and thus, when that project is shared, if the extensionscan be loaded with the shared project. This security level enables the developer of the extension tocontrol how the extension can be shared along their use with various projects. With the option Cancopy extension to project, each time a user asks to save this extension with a project, the extensionitself is copied into the project and consequently is available each time this project is opened. This ex-tension can also be used with other projects. However, if you select Can copy extension to projectbut locked to this one, the extension can be saved within a project, as with the previous option, butthe use of the extension is limited to the current project. If a user opens a new project, this extensionis not available. If you select Can't copy extension to project, the extension is not saved with theproject and is not shared with other users with the project. Note that the extension can be sent in ad-dition to the project. The process for saving extensions within a project is described in Generation Optionsfor Extensions Handling (p. 17). Note that these security options only apply if the user wants to savethe extension with the project, and are otherwise not applicable.

When all parameters are defined, the Build button is available, and you can launch the creation of thebinary extension. The bottom part of the window displays build information as illustrated below.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.16

Using Extensions

Page 25: ANSYS ACT Developers Guide

Figure 17: Binary Extension Generation

Generation Options for Extensions Handling

From the main Tools > Options menu, you can define a set of dedicated options for ACT. When youselect Extensions in the left pane of the main Options window, you can define the three propertiesused to configure ACT.

Figure 18: Options Menu

17Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Generation Options for Extensions Handling

Page 26: ANSYS ACT Developers Guide

Figure 19: Extensions Options

The first option, Additional Extension Folders, provides the ability to define additional folders in whichACT will search for extensions in order to expose them in the Extension Manager. You can define sev-eral folder names, separated by a semi-colon (;). These folders are in addition to the two folders usedby default. These two default folders are the default installation folder for extensions:

%ANSYSversion_DIR%\..\Addins\AdvancedAddinPackage\extensions

and the user's Application Data folder:

%APPDATA%\Ansys\version\AdvancedAddinPackage\extensions

Because these folders are searched for extensions by default, the Extension Manager contains any ex-tensions located in them.

During the scan of the available extensions, the folders are analyzed in following order:

1. The application data folder.

2. The installation folder.

3. Additional folders defined in the Additional Extension Folders option.

During this process, warning messages are returned for any conflicts; these messages are also loggedin the ACT log file.

The second property in the Extensions Options specifies if the extensions should be saved when theproject is saved. Figure 20: Save Extensions Option (p. 19) shows the available options for this property.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.18

Using Extensions

Page 27: ANSYS ACT Developers Guide

Figure 20: Save Extensions Option

If you choose Never, the current loaded extensions are not saved within the project.

If you choose Copied but locked to the project, the extensions are saved within the project but arelimited to that project.

If you choose Always, the extensions are saved within the project and no restriction exists as to theiruse in other projects. This option represents what most users expect when the project is saved. However,note that this behavior is dependent on the security options of the extension defined by the developer,as described in Compiling an Extension (p. 15). In particular, the following scenarios can occur:

• The extension was built with the security option set to Can’t copy extension to project and the user setthe save option to Always or Copied but locked to the project. In that case, the security option has thepriority and the user will not have the extension saved in the project.

• The extension was built with the security option set to Can copy extension to project but locked to thisone and the user set the save option to Always. Although the save option does not impose any restrictionfor the extension, the security level will limit the use of the extension for the current given project.

The third property allows you to activate Debug mode. When activated, this mode allows the developerto debug the scripted extension. In addition, the Debug mode exposes one additional feature in thetoolbar of the main project page that enables to reload the extension once a modification has beendone in a script. This feature is similar to the feature 1 described below. When the ANSYS Mechanicalapplication is used, the Debug mode exposes two additional features in Mechanical that will help youdebug the extension under development. These two features are available from a new toolbar inMechanical.

19Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Generation Options for Extensions Handling

Page 28: ANSYS ACT Developers Guide

For more information on debugging capabilities, see Debug Mode (p. 199).

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.20

Using Extensions

Page 29: ANSYS ACT Developers Guide

Licensing

ACT development is licensed, but binary extension usage is not. In other words, developers creatingnew extensions must have a license. However, once the extension is built, a license is not required torun it.

The ACT license enables two main capabilities, which are:

• The ability to build an extension in the Binary Extension Builder. The ACT license is checked out when thebuild is launched and is released once the build has been completed.

• The ability to load a scripted extension. As a consequence, only the binary extensions can be loaded whenno ACT license is available. No matter the number of scripted extensions that are loaded, only one ACT licenseis checked out. This license is released once all the scripted extensions have been unloaded from the ExtensionManager.

Note

If an ACT license is already checked out by a loaded scripted extension, the build operationwill not require a second ACT license to run.

21Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 30: ANSYS ACT Developers Guide

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.22

Page 31: ANSYS ACT Developers Guide

Extension Capabilities

In the introductory chapter, the sample extension ExtSample1 was used to describe the fundamentalelements of an extension. The ExtSample1 extension demonstrated how to create a toolbar whichcontains a button that responds by calling a Python scripted function. This chapter expands on thisdescription and introduces the main capabilities an extension can address.

This chapter divides extension capabilities in to the following categories:Common CapabilitiesACT-Based PropertiesCapabilities for ANSYS MechanicalCapabilities for ANSYS DesignModelerCapabilities for ANSYS DesignXplorerCapabilities for Custom ACT Workflows in WorkbenchCapabilities for ANSYS AIM

Common Capabilities

ACT provides customization capabilities that are common to all target applications: ANSYS Mechanical,ANSYS DesignModeler, ANSYS DesignXplorer, and ANSYS AIM.

This section discusses the following common capabilities:Defining Toolbars and Toolbar ButtonsBinding Toolbar Buttons with ACT ObjectsDefining Pop-up DialogsStoring Data in Your Extension

Defining Toolbars and Toolbar Buttons

This section is focused on applications that expose their own toolbars and toolbar buttons that can becustomized using the methodology explained below. The ANSYS Mechanical application is used fordemonstration purposes.

A toolbar serves as a parent container for one or more toolbar buttons. Conceptually the toolbar shouldaddress a specific feature wherein each toolbar button's focus is on a function that supports the feature.This relationship is reflected in the structure of the XML that defines a toolbar and its buttons. Belowis the XML from the ExtToolbarSample extension.

The ExtToolbarSample extension adds two toolbars, Toolbar1 and Toolbar2. Each toolbar hasthree distinct buttons.

<extension version="1" minorversion="0" name="ExtToolbarSample"> <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">

23Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 32: ANSYS ACT Developers Guide

<callbacks> <onclick>OnClickTB1Button1</onclick> </callbacks> </entry> <entry name="TB1Button2" icon="button2Red"> <callbacks> <onclick>OnClickTB1Button2</onclick> </callbacks> </entry> <entry name="TB1Button3" icon="button3Red"> <callbacks> <onclick>OnClickTB1Button3</onclick> </callbacks> </entry> </toolbar> <toolbar name="Toolbar2" caption="Toolbar2"> <entry name="TB2Button1" icon="button1Blue"> <callbacks> <onclick>OnClickTB2Button1</onclick> </callbacks> </entry> <entry name="TB2Button2" icon="button2Blue"> <callbacks> <onclick>OnClickTB2Button2</onclick> </callbacks> </entry> <entry name="TB2Button3" icon="button3Blue"> <callbacks> <onclick>OnClickTB2Button3</onclick> </callbacks> </entry> </toolbar> </interface></extension>

The ExtToolbarSample extension adds two toolbars, Toolbar1 and Toolbar2. Each toolbar hasthree buttons, as shown in Figure 21: User-Defined Toolbars in Mechanical (p. 24).

Figure 21: User-Defined Toolbars in Mechanical

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.24

Extension Capabilities

Page 33: ANSYS ACT Developers Guide

The XML example defines two toolbar elements. Each element starts with a begin tag <toolbarname="..." caption="..."> and ends with a terminal tag </toolbar>. The toolbar elementhas two attributes, name and caption. The name attribute is required and is used for internal references.The caption attribute is the text displayed in the application.

The button entry elements define the buttons in the toolbar. Each button entry element starts witha begin tag <entry name="..." icon="..."> and ends with a terminal tag </entry>. Theentry element has two attributes: name and icon. The name attribute is required and is used forinternal references. The name is also displayed as a tooltip. The icon attribute is the name of the iconfile mapped on to the button.

The entry element for each button is parent to a callbacks element. The <callbacks> elementencapsulates element(s), which are named on the basis of an event. For instance, the name specifiedby the onclick element, <onclick>name</onclick>, provides the name of the Python functionto be called when the button is selected.

Referring again to the XML in the above code, the second line:

<script src="toolbarsample.py" />

defines the name of the Python script file for the ExtToolbarSample extension, toolbarsample.py,the contents of which are shown below. By default, ACT will look for the Python script file in the directoryof the extension. If the Python script file is located in a different directory, an explicit path to the filemust be inserted into the extension XML file.

import osimport datetimeclr.AddReference("Ans.UI.Toolkit")clr.AddReference("Ans.UI.Toolkit.Base")from Ansys.UI.Toolkit import *

def init(context): ExtAPI.Log.WriteMessage("Init ExtToolbarSample ...")

def OnClickTB1Button1(analysis): LogButtonClicked(1, 1, analysis)

def OnClickTB1Button2(analysis): LogButtonClicked(1, 2, analysis)

def OnClickTB1Button3(analysis): LogButtonClicked(1, 3, analysis)

def OnClickTB2Button1(analysis): LogButtonClicked(2, 1, analysis)

def OnClickTB2Button2(analysis): LogButtonClicked(2, 2, analysis)

def OnClickTB2Button3(analysis): LogButtonClicked(2, 3, analysis)

def LogButtonClicked(toolbarId, buttonId, analysis): now = datetime.datetime.now() outFile = SetUserOutput("ExtToolbarSample.log", analysis) f = open(outFile,'a') f.write("*.*.*.*.*.*.*.*\n") f.write(str(now)+"\n") f.write("Toolbar "+toolbarId.ToString()+" - Button "+buttonId.ToString()+" Clicked. \n") f.write("*.*.*.*.*.*.*.*\n") f.close() MessageBox.Show("Toolbar "+toolbarId.ToString()+" - Button "+buttonId.ToString()+" Clicked.")

def SetUserOutput(filename, analysis):

25Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Common Capabilities

Page 34: ANSYS ACT Developers Guide

solverDir = analysis.WorkingDir return os.path.join(solverDir,filename)

Each button in ExtToolbarSample has a unique callback function. Each callback function passes thetoolbar ID and the ID of the button pressed to the function LogButtonClicked, which stores themin the variables toolbarId and buttonId. These variables are referenced within the function wheretheir string values are written. The functions LogButtonClicked and SetUserOutput demonstratehow to reduce redundant code in callbacks using utility functions. The Analysis object is passed toeach <entry> callback and then used in the SetUserOutput function to query for the workingdirectory of the analysis. The script in toolbarsample.py makes use of the datetime namespacefrom the .NET framework. The datetime namespace exposes a class also called datetime. LogBut-tonClicked invokes datetime to query the current date and time and stores the result in the variablename now. The str() utility is used to extract the string definition of the variable now to write outthe date and time.

Binding Toolbar Buttons with ACT Objects

ACT provides the ability to bind a button from the ACT toolbar with an ACT object created in the treeof the application. This capability allows you to control the contextual availability of the buttons depend-ing on the object selected in the tree. This method is similar to the control used for standard objectsin Mechanical. The connection between the ACT object and the ACT button is made using the user-object tag in the entry element of the interface definition in the XML file. The following codedemonstrates this type of connection for a result object:

<interface context="Mechanical"> <images>images</images> <toolbar name="My_Toolbar" caption="My_Toolbar"> <entry name="Button_For_My_Result icon="result" userobject="My_Result"> </entry> </toolbar></interface>

<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, then this button is activatedonly if the object is selected in the Mechanical environment; otherwise it is inactive.

In the same way, if the ACT button is bound with an ACT result in Mechnical, this button is active onlyif the object is selected in the solution; otherwise it is inactive.

For any ACT object bound to a button, the <onclick> callback is not used.

Based on the above example, Figure 22: Selecting an Environment Object (p. 27) and Figure 23: Selectinga Solution Object (p. 27) illustrate the GUI behavior based on selection of an object in the tree.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.26

Extension Capabilities

Page 35: ANSYS ACT Developers Guide

Figure 22: Selecting an Environment Object

Figure 23: Selecting a Solution Object

In addition to the control provided by the connection between the ACT button and the ACT object,the <canadd> callback can be implemented to add new criteria to be considered for the activationand deactivation of the button. If the <canadd> callback of the object returns false, the associatedbutton is deactivated. A typically example consists of filtering a particular analysis type to activate aspecific load.

Defining Pop-up Dialogs

This section discusses pop-up dialogs using the ExtDialogSample extension as an example.ExtDialogSample defines a new menu labeled DialogSample with one menu item labeled GetFile-name. ExtDialogSample demonstrates how to open a file dialog and display a message window inthe user interface.

The XML for the ExtDialogSample extension, shown below, is similar to the XML used for theExtToolbarSample extension.

<extension version="1" minorversion="0" name="ExtDialogSample"> <script src="dialogsample.py" /> <interface context="Mechanical"> <images>images</images> <callbacks> <oninit>init</oninit> </callbacks> <toolbar name="DialogSample" caption="DialogSample">

27Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Common Capabilities

Page 36: ANSYS ACT Developers Guide

<entry name="DialogSample1" caption="GetFilename"> <callbacks> <onclick>GUIToolbarOpenFile</onclick> </callbacks> </entry> </toolbar> </interface></extension>

The callback function specified in the XML for the GetFilename menu button is GUIToolbarOpenFile.Here is the Python script from the file dialogsample.py.

clr.AddReference("Ans.UI.Toolkit")clr.AddReference("Ans.UI.Toolkit.Base")from Ansys.UI.Toolkit import *

def init(context): ExtAPI.Log.WriteMessage("Init ExtDialogSample ...")

def GUIToolbarOpenFile(analysis): filters = "txt files (*.txt)|*.txt|All files (*.*)|*.*" dir = "c:\\" res = FileDialog.ShowOpenDialog(ExtAPI.UserInterface.MainWindow, dir, filters, 2, "ExtDialogSample","")

if res[0]==DialogResult.OK: message = str("OPEN selected -> Filename is "+res[1]) else: message = "CANCEL selected -> No file" MessageBox.Show(message)

When GUIToolbarOpenFile is invoked, an instance of a modal file-selection dialog is created bycalling FileDialog.ShowOpenDialog. The class FileDialog is provided by the UI Toolkit. Theuser inputs the necessary information in this dialog. When the user clicks the Open or Cancel buttons,the file-selection dialog closes and this information is returned to GUIToolbarOpenFile. The returnedinformation is then used to create a message-box dialog. The message displayed in the message-boxdialog validates the result returned from the file-selection dialog.

Storing Data in Your Extension

Two mechanisms are available to store data in your extension. These mechanisms are based on the<onload>/<onsave> callbacks or on attributes. These mechanisms are available for any applicationusing ACT.

The <onsave> callback is called each time the target application saves the project. Consequently, thiscallback allows the creation of dedicated files to store data, in addition to the standard ANSYS Workbenchproject.

The <onload> callback is called each time the application loads the project. The process here is similarto the previous <onsave> callback, but is now devoted to reading in additional data.

Attributes represent a very interesting way to store data, as this method does not require the creationof new external files.

Attributes are defined by name and content. The content can be simply defined by a single value suchas an integer, or a double, or with more complex data. The content must be serializable. To accomplishthis, implement the serialization interface provided by .Net. 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 anextension, an ACT load or result, and a property.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.28

Extension Capabilities

Page 37: ANSYS ACT Developers Guide

Attributes are created or edited with the method:

Attributes["attribute_name"] = attribute_value

and the content can be retrieved with the method:

attribute value = Attributes["attribute_name"]

Below is an example of an attribute associated with a property:

prop.Attributes["MyData"] = 2val = prop.Attributes["MyData"]

Below is a similar example for an attribute associated with a load:

load.Attributes["MyData"] = 2val = load.Attributes["MyData"]

Below is a similar example for an attribute associated with an extension:

ExtAPI.ExtensionMgr.CurrentExtension.Attributes["MyData"] = 2v = ExtAPI.ExtensionMgr.CurrentExtension.Attributes["MyData"]

Note that an attribute associated with an extension can be shared between applications using the sameextension. For example, two Mechanical sessions can share data.

The command to store the attribute in a shared repository is as follows:

ExtAPI.ExtensionMgr.CurrentExtension.SetAttributeValueWithSync("MyData", 2.)

In the same way, the command to retrieve the content stored in a shared repository is:

ExtAPI.ExtensionMgr.CurrentExtension.UpdateAttributes()v = ExtAPI.ExtensionMgr.CurrentExtension.Attributes["MyData"]

ACT-Based Properties

ACT has the ability to create customized objects that encapsulate ACT-based properties. This sectiondiscusses how to use ACT to create properties.

The following topics are discussed:Creating Property GroupsParameterizing PropertiesDefining DesignXplorer Properties

Creating Property Groups

This section focuses on the process of creating groups of properties.

The following methods are available:Using PropertyGroup and PropertyTableUsing Templates to Create Property Groups

Using PropertyGroup and PropertyTable

This section focuses on the process of creating groups of properties via PropertyGroup and Prop-ertyTable.

PropertyGroup and PropertyTable are special types of properties that can be used to creategroups of properties with a given caption. In this way, it is possible to manage dependencies between

29Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

ACT-Based Properties

Page 38: ANSYS ACT Developers Guide

properties and to create worksheet views from a property.The PropertyGroup type encapsulates alist of child properties under one group.

The PropertyTable type encapsulates a list of child properties under one table. Each child propertycreates a new column in the table and the user is able to control the line number of this table.

These functionalities are demonstrated into the AdvancedProperties extension.

The first example shows how to create a group of properties with a caption. The group can be collapsedor expanded by the user. The Simple group with caption group is shown below.

Figure 24: Details Pane with Group Definition

This group is created with the following XML code:

<propertygroup name="Group1" caption="Simple group with caption" display="caption"> <property name="Prop1" caption="Prop1" control="text" /> <property name="Prop2" caption="Prop2" control="text" /> <property name="Prop3" caption="Prop3" control="text" /></propertygroup>

The property group has a special attribute, display. In this case, this attribute is set to caption,which means all the children properties are displayed under the caption. If the caption attribute isomitted, then the display attribute is set to hidden and the property group is hidden.

The second example illustrates how to show or hide properties according to the value of another selectedproperty.

As shown in Figure 25: Contextual Content for Groups (p. 31), the visibility of the properties is dependenton the value of the Group Select property as defined above.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.30

Extension Capabilities

Page 39: ANSYS ACT Developers Guide

Figure 25: Contextual Content for Groups

This group is created with the following XML code, which creates dependencies between properties:

<propertygroup name="Group2" caption="Another group" display="caption"> <propertygroup name="Group3" caption="Group Select" display="property" control="select" default="Option 1"> <attributes options="Option 1,Option 2,Option 3" /> <property name="Prop1" caption="Prop For Option 1" visibleon="Option 1" control="text" /> <property name="Prop2" caption="Prop For Option 1 and Option 2" visibleon="Option 1|Option 2" control="text" /> <property name="Prop3" caption="Prop For Option 3" visibleon="Option 3" control="text" /> </propertygroup></propertygroup>

In this case, the attribute display is set to property. The PropertyGroup Group3 defines astandard ACT property which provides additional capabilities for all the children properties.

Each child property can specify an attribute visibleonwhich can take a value or a set of values. Ifthe current value of the parent property fits with the visibleon attribute, then the property is dis-played; otherwise, the property is hidden.

The example below demonstrates how to create properties that open a worksheet each time the userneeds access to the content of the properties. The PropertyTable type is used for such an application.This type of property is of particular interest as it allows you to create a worksheet that exposes a setof properties for your customization.

31Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

ACT-Based Properties

Page 40: ANSYS ACT Developers Guide

In order to facilitate the development, ACT already provides some predefined worksheets. Two differenttypes of worksheets are currently available:

Time-dependent worksheet: The row number of this worksheet is initialized with the number of stepsdefined in the AnalysisSettings object. If the user of the extension adds or removes time stepsin the AnalysisSettings object, the worksheet is automatically updated. Consequently, this typeof worksheet represents an efficient way to manage time-dependent data within an extension.

Figure 26: Time-Dependent Worksheet

This worksheet is created with the following XML code:

<propertytable name="TimeDep" caption="TimeDependent" display="worksheet" control="applycancel" class="Worksheet.TimeFreqTabularData.TFTabularData"> <property name="Step" caption="Step" control="integer" readonly="true" /> <property name="Time" caption="Time" control="float" readonly="true" /> <property name="Temperature" caption="Temperature" unit="Temperature" control="float"></property> <property name="Pressure" caption="Pressure" unit="Pressure" control="float"></property></propertytable>

In this example, the display attribute is set to worksheet. In addition, the class attribute is usedto specify the name of the IronPython class that is used to manage the worksheet. For this given applic-ation, the TFTabularData class is used. This class is defined in the file TimeFreqTabularData.pylocated into the libraries/Mechanical/Worksheet folder, which is part of the standard ACTinstallation.

The properties Step and Time integrate a specific treatment, as they are automatically populated withthe information specified in the AnalysisSettings object. These two properties are optional.

Non-fixed row dimension worksheet: For the second type of worksheet, the array is empty by default.The user can add a new line by clicking on the top left button as illustrated below.

Figure 27: Non-Fixed Row Dimension Worksheet

This worksheet is created with the following XML code:

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.32

Extension Capabilities

Page 41: ANSYS ACT Developers Guide

<propertytable name="Worksheet" caption="Non-Fixed row count" display="worksheet" control="applycancel" class="Worksheet.PropertyGroupEditor.PGEditor"> <propertygroup name="TempOrPres" caption="TempOrPres" display="property" control="select" default="Temperature"> <attributes options="Temperature,Pressure" /> <property name="Temperature" caption="Temperature" unit="Temperature" control="float" visibleon="Temperature"></property> <property name="Pressure" caption="Pressure" unit="Pressure" control="float" visibleon="Pressure"></property> </propertygroup>

<property name="Scoping" caption="Scoping" control="scoping"> <attributes selection_filter="face|edge" /> </property> <property name="FileName" caption="FileName" control="fileopen"> <attributes filters="Command files (*.bat)|*.bat|All files (*.*)|*.*" /> </property></propertytable>

In this example the PGEditor class is used. The PGEditor class is defined in the file PropertyGrou-pEditor.py, available in the /libraries/Mechanical/Worksheet folder.

You can access the content of the worksheet in the same manner as you do any other standard ACTproperty.

Using Templates to Create Property Groups

This section focuses on the process of creating groups of properties via templates.

A template represents a generic method for defining a group of properties with the associated callbackscode. Basically, you can create a template to provide services that can be integrated into any extension.

For example, you can build a template to generate a property that displays all the available coordinatesystems for the current model.

This template is defined in the file controltemplates.xml located in the templates folder. Thecontent of this file is presented below.

<!-- Coordinate System Selection --><controltemplate name="coordinatesystem_selection" version="1"> <property control="select" class="templates.select.SelectCoordinateSystem"></property></controltemplate>

First, a name is given to the template. The class SelectCoordinateSystem associated with thistemplate is defined in the file select.py, located in the /libraries/Mechanical/templatesfolder. A template has to be made of one single property. If several properties need to be defined, thenthey have to be integrated in a group. The template scoping illustrates a template definition withdifferent properties.

In order to link this template to a property, the user just needs to fill the control attribute of theproperty with the name of the template.

Other examples are available in the file /templates/Mechanical/controltemplates.xml.

To be sure, the advanced user will find benefit in using the templates. The templates currently integratedin ACT can be enriched so that the customized environment will enable always more complex custom-ization in a very efficient way.

33Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

ACT-Based Properties

Page 42: ANSYS ACT Developers Guide

Parameterizing Properties

When defining ACT properties in ANSYS Mechanical and ANSYS DesignModeler, it is also possible todefine the property value as either an input or an output parameter (all ACT parameters are inputs,unless you specify otherwise in the definition). Once parameterized, the property is sent to ANSYSWorkbench for inclusion in the Parameter Set, where it behaves and is treated as any other parameter.

You can incorporate parameters in a variety of places in your analysis.

• In ANSYS Mechanical, parameters can be defined for any ACT object, regardless of its location in the tree.

• In ANSYS DesignModeler, parameters can be incorporated into a number of custom ACT-based features,such as renaming selected bodies, specifying geometry generation details like as material, dimensions, etc.

• In a third-party solver implemented by ACT, parameters can be incorporated into the load, analysis settings,and result.

All combinations of ACT-based and standard parameters are supported:

• ACT input(s) and standard output(s)

• ACT input(s) and ACT output(s)

• Standard input(s) and ACT output(s)

Common Property Parameterization Processes

To define a property as a parameter, you must add the tag isparameter to the XML file and set itto true. By default, it will be created as an input parameter. To further specify that the property willbe an output parameter, you must also add the tag readonly and set it to true. The following sectionswill use sample code segments to illustrate the creation of input and output parameters.

When you define a property as a parameter, keep in mind that it is not selected for parameterization(i.e. it is not be parameterized) by default. Defining a property as a parameter only makes parameteriz-ation possible by adding a check box to the user interface. In order to actually parameterize the property,the user must select the check box provided by the ACT tag.

Once a property has been selected for parameterization, it will automatically be sent to the ParameterSet (accessed on the ANSYS Workbench Project Schematic), where it will be displayed in both theOutline of All Parameters and the Table of Design Points. Output parameters are read-only, but thesetwo Parameter Set tables provide the same level of control over the definition of ACT input parametersas is available for standard, non-ACT inputs. For example:

• The user can change the unit of the parameterized input property; the unit proposed will respect the typeof unit specified in the XML file.

• The user can add a design point for the input parameter by clicking in the bottom row of the Table ofDesign Points.

• The user can 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 inthe previous value must be floats, and cannot be strings.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.34

Extension Capabilities

Page 43: ANSYS ACT Developers Guide

When the user has finished setting up the system and has finished working with parameters and designpoint values (there should be at least one input and one output parameter), he can solve the problemby updating the design points from the Parameter Set.

Parameterization in ANSYS Mechanical

The following sections provide examples and methods for integrating ACT parameters into your ANSYSMechanical model.

In ANSYS Mechanical, it is possible to define ACT-based property values as either input parameters oroutput parameters. This section addresses how to implement a parameter on an ACT object in theANSYS Mechanical application—specifically, how to parameterize loads, results, and userobjects. ACTobjects in any of these categories will behave and interact with parameters in exactly the same way.

The following sections provide examples and methods for integrating ACT parameters into your ANSYSMechanical model.

Defining Input Parameters in ANSYS MechanicalDefining Output Parameters in ANSYS Mechanical

Defining Input Parameters in ANSYS Mechanical

To define a property as a parameter, add the tag isparameter to the XML file and set it to true.

For example, the following code segment creates a property named float_unit. The property willbe a pressure and its value will be a float.

<property name="float_unit" caption="float_unit" control="float" unit="Pressure" isparameter="true"/>

Note

Other tags such as default, isload, etc. could be added, as well.

The isparameter tag adds a check box to the user interface, making it possible for the user to selectthe property for parameterization.

Once the property has been selected for parameterization, it will automatically be displayed in bothOutline of All Parameters and the Table of Design Points in the Parameter Set.

35Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

ACT-Based Properties

Page 44: ANSYS ACT Developers Guide

The code sample below is extracted from the XML file of the extension used in the previous example.You can see how the property definition of our float_unit property is incorporated into the file.

<load name="CustomPressure" version="1" caption="CustomPressure" icon="tload" support="false" isload="true" color="#0000FF"> <callbacks> <getsolvecommands order="1">writeNodeId</getsolvecommands> </callbacks> <property name="Geometry" caption="Geometry" control="scoping"> <attributes selection_filter="face"/> </property> <property name="float_unit" caption="float_unit" control="float" unit="Pressure" isparameter="true"/></load>

Defining Output Parameters in ANSYS Mechanical

It is also possible to define an ACT property as an output parameter.

The process for making a property available as a parameter is the same as for any input parameter (byadding the isparameter tag and setting it to true); a check box allowing parameterization of theproperty will become available. To specify that the property will be an output parameter, you must alsoadd the readonly tag to the XML file and set it to true.

For example, the following code segment creates a property named MyOutPutProperty. As in theprevious example, the property will be a pressure and its value will be a float. Because it includes thereadonly tag set to true, however, this property can be parameterized only as an output parameter.

<property name="MyOutPutProperty" caption="MyOutPutProperty" control="float" unit="Pressure" readonly=”true” isparameter="true"/>

Note

Other tags such as default, isload, etc. could be added, as well.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.36

Extension Capabilities

Page 45: ANSYS ACT Developers Guide

Again, the user must select the check box provided by the ACT tag to actually parameterize the property.Once the property has been selected for parameterization, the corresponding output will automaticallybe generated in the Outline of All Parameters table in the Parameter Set.

In addition, by default the minimum and maximum values of an ACT result object are available to becomeoutput parameters. This capability is not managed by the ACT extension, but takes advantage of theMechanical environment.

Parameterization in ANSYS DesignModeler

In ANSYS DesignModeler, it is possible to define ACT-based property values only as input parameters.This section addresses how to implement an input parameter on an ACT object in the ANSYS Design-Modeler application.

As with any other input parameter, to add an input to ANSYS DesignModeler you must added the is-parameter tag to the XML file and set it to true. (You will not be able to add output parameters;the readonly tag is not available for ANSYS DesignModeler).

For example, in an ACT feature that generates a cylinder, you can add length as a parameter. The fol-lowing XML code segment defines this Length parameter.

<geometry name="MyFeatureWithParameters" caption="MyFeatureWithParameters" icon="Construction" version="1"> <callbacks> <ongenerate>generateMyFeature</ongenerate> </callbacks> <property name="Length" caption="Length" control="float" isparameter="true"></property> </geometry>

The resulting check box next to the Length property allows the user to parameterize Length as an inputparameter.

37Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

ACT-Based Properties

Page 46: ANSYS ACT Developers Guide

You could add a static structural analysis based on the previous Geometry template by adding anoutput parameter in the Static Structural analysis. This results in the schematic workflow shown below:

The input parameter defined in ANSYS DesignModeler will be managed in exactly the same way asother any other input parameter. In the Outline of All Parameters table in Parameter Set, the geometryinput parameter will be placed under the Geometry system.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.38

Extension Capabilities

Page 47: ANSYS ACT Developers Guide

Parameterization in a Third-Party Solver

When you have used ACT to deploy a third-party solver, it is possible to define ACT-based propertiesas either input parameters or output parameters. This section addresses how to implement a parameteron an ACT object in an external third-party solver—specifically, under a load, in the analysis settings,and under results.

The definition of parameters for a third-party solver is no different than the process described in earliersections: To parameterize a property, in the property definition you must introduce the isparametertag and set it to true; by default, it will be an input parameter. To define it as an output parameter,you must add the readonly tag and set it to true.

Defining Parameters under a Load in a Third-Party Solver

The process of defining parameters under a load in ANSYS DesignModeler is identical to the processdescribed in Defining Input Parameters in ANSYS Mechanical (p. 35).

Defining Parameters in Analysis Settings in a Third-Party Solver

It is possible to parameterize the Analysis Settings in a third-party external solver; the settings optionsavailable depend on the definition of the third-party solver.

For example, you can opt to parameterize the maximum number of iterations under Analysis Settings:

The following code segment, placed under the solver section of the XML definition file, defines theMax. Iterations parameter.

<solver…

<property name="MaxIter" caption="Max. Iterations" control="integer" isparameter="true" default="10"/></solver>

39Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

ACT-Based Properties

Page 48: ANSYS ACT Developers Guide

Defining Parameters under Results in a Third-Party Solver

The process of defining parameters under Results in ANSYS Mechanical is identical to the process de-scribed in Parameterization in ANSYS Mechanical (p. 35). Results parameters can be either inputs oroutputs, depending on whether the readonly tag is set to true or false.

Defining DesignXplorer Properties

An external sampling or optimization method can expose settings to allow the user to control algorithmoptions and view outputs.

For instance:

• A DOE can expose the editable setting Number of Levels to allow the user to define this limit. The samplingwill be responsible for handling this setting as needed. The DOE can also expose the read-only setting Ac-tual Number of Points to inform the user, after the sampling is completed, of the number of points generated.

• An optimizer can expose the editable setting Maximum Number of Iterations to allow the user to definethis limit. The optimizer will be responsible for handling this setting as needed. The optimizer can also exposethe read-only setting Actual Number of Iterations to inform the user, after the optimization is completed,of the number of iterations actually performed.

ACT provides support for the general definition of properties with attributes and callbacks. Each settingto be exposed to the DX user must be declared and defined in the XML file as a <property> elementunder the <sampling> or <optimizer> element, as shown in Figure 28: Example of a DX PropertyDefinition (p. 40).

Figure 28: Example of a DX Property Definition

<property name="[property internal name (string)]" caption="[property display name (string)]" readonly="[true | false(default)]" default="[default value]" control="[text(default) | select | float | integer | ...]" visible="[true(default) | false]" visibleon="[values(separator '|')]" ... <attributes>mldr</attributes> <callbacks</property>

Optionally, settings can be placed together in groups. Each group must be declared and defined in theXML file as a <propertygroup> element under <sampling> or <optimizer> element.

For a description of common attributes and callbacks, see “property” under the “XML Tags” section ofthe ACT Reference Guide for DesignXplorer. For more information on settings groups, see “propertygroup”under the “XML Tags” section of the ACT Reference Guide for DesignXplorer.

Properties in the DX Interface

When an external method is selected in the DX (via the Design of Experiments Type menu in the DOEworkspace or the Method Name menu in the Optimization workspace), its properties are shown in theProperties view.

For example, in Figure 29: DesignXplorer Properties View for External DOE (p. 41) below, we can seethe Properties view when the external sampling named Full Factorial is selected.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.40

Extension Capabilities

Page 49: ANSYS ACT Developers Guide

Figure 29: DesignXplorer Properties View for External DOE

In Figure 30: DesignXplorer Properties View for External Optimizer (p. 41) below, we can see the Prop-erties view when the external optimizer named Python Optimizer is selected.

Figure 30: DesignXplorer Properties View for External Optimizer

By default, properties are shown under the General category. If a propertygroup is specified, thecorresponding category is created in the property view. The properties under the General and the re-spective Status categories are specific to the external method and are defined in the XML file.

41Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

ACT-Based Properties

Page 50: ANSYS ACT Developers Guide

Note that if the sampling supports the LogFile capability, the Log File property is automaticallydefined under the Status category of the Properties view. Once the sampling is generated optimizationhas been run, the user can view the log file in a dialog box by clicking on the available link.

Additional Attributes for DX Extensions

In the context of sampling and optimization extensions, DX also recognizes the additional attributesmin, max, and advanced for each property. The min and max attributes are used to specify a minimumand/or maximum value for a double or integer property.

In the following sampling example, the minimum value is 1 and the maximum value is 100.

<property name="NumberOfLevels" caption="Number of Levels" control="integer" default="3"> <attributes min="1" max="100"/></property>

In the following optimization example, the minimum value is 2 and the maximum value is 200.

<property name="MyNumberOfSamples" caption="My Number of Samples" control="integer" default="50"> <attributes min="2" max="200"/></property>

The advanced attribute is used to classify the property as an advanced option. Advanced options arevisible for the user only if activated (in the Workbench user interface, open Tools > Options > DesignExploration and select the Show Advanced Options check box). The following example is applicableto either type of DX extension.

<property name="MyRandomNumber" caption="My Random Number provider" control="select" default="Python"> <attributes options="Python,CLibrary" advanced="true"/></property>

Advanced Usage Examples

The following advanced examples illustrate the use of properties in DX extensions.

Managing Dependencies between Properties

The following example demonstrates how to manage the dependency between properties:

• Prop1 is visible when Group3 value is equal to Option 1

• Prop2 is visible when Group3 value is equal to Option 1 or Option 2

• Prop3 is visible when Group3 value is equal to Option 3

<propertygroup name="Group3" caption="Group Select" display="property" control="select" default="Option 1"> <attributes options="Option 1,Option 2,Option 3" /> <property name="Prop1" caption="Prop For Option 1" visibleon="Option 1" control="text" /> <property name="Prop2" caption="Prop For Option 1 and Option 2" visibleon="Option 1|Option 2" control="text" /> <!-- Prop3 is applicable and visible only when Group3 == "Option 3" --> <property name="Prop3" caption="Prop For Option 3" visibleon="Option 3" control="text" /></propertygroup>

Controlling Property Visibility with a Callback

The attributes, such as the visibility attribute, can be modified dynamically by using a callback.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.42

Extension Capabilities

Page 51: ANSYS ACT Developers Guide

DOE Example

The following example shows how to control the visibility of the PropForSingleInput propertywith a callback coded in IronPython:

<property name="PropForSingleInput" caption="My Property for single input parameter" control="text"> <callbacks> <isvisible>isVisibleForSingInput</isvisible> </callbacks></property>

Where isVisibleForSingInput is defined by the following IronPython code:

def isVisibleForSingInput(entity,property): if entity.NumberOfObjectivesDefined <= 1: return True return False

The isVisibleForSinglnputfunction takes two arguments:

• The first argument-named entity, is of type DXUserSampling.

• The second argument-named property is of type SimProperty.

This method returns True when only one input parameter is defined.

Optimization Example

The following example shows how to control the visibility of the PropForSingleObjective propertywith a callback coded in IronPython:

<property name="PropForSingleObjective" caption="My Property for single-objective optimization" control="text"> <callbacks> <isvisible>isVisibleForSOO</isvisible> </callbacks></property>

Where isVisibleForSOO is defined by the following IronPython code:

def isVisibleForSOO(entity,property): if property.Name != PropForSingleObjective return True if entity.NumberOfObjectivesDefined <= 1: return True return False

The isVisibleForSOO function takes two arguments:

• The first argument-named entity, is of type DXUserOptimizer.

• The second argument-named property is of type SimProperty.

This method returns True when only one objective is defined.

Modifying an Attribute with a Callback

The following examples show how you can modify the values property attributes when input parametersare edited by the user.

43Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

ACT-Based Properties

Page 52: ANSYS ACT Developers Guide

DOE Example

This example shows how you can modify the values of the max attribute of the property NumberOf-Levels when input parameters are edited by the user.

Given the partial sampling definition:

<sampling …> <callbacks> <InputParametersEdited>InputParametersEdited</InputParametersEdited> </callbacks> <property name="NumberOfLevels" caption="Number of Levels" control="integer" default="3"/> <attributes min="1"> </property> </sampling>

The InputParametersEdited function is defined by the following IronPython code:

def InputParametersEdited(entity): entity.Properties["NumberOfLevels"].Attributes["max"]=3*entity.NumberOfInputParametersDefined

The InputParametersEdited function is called when input parameters are edited by the user. Itcalculates the new minimum allowed value for the NumberOfLevels property from the currentnumber of input parameters and then sets this value to the max attribute.

Optimization Example

This example shows how you can modify the values of the min attribute of the property MyNumber-OfSamples when input parameters are edited by the user.

Given the partial optimizer definition:

<optimizer …> <callbacks> <InputParametersEdited>InputParametersEdited</InputParametersEdited> </callbacks> <property name="MyNumberOfSamples" caption="My Number of Samples" control="integer" default="50" /></optimizer>

The InputParametersEdited function is defined by the following IronPython code:

def InputParametersEdited(entity): entity.Properties["MyNumberOfSamples"].Attributes["min"]=10*entity.NumberOfInputParametersDefined

The InputParametersEdited function is called when input parameters are edited by the user. Itcalculates the new minimum allowed value for the MyNumberOfSamples property from the currentnumber of input parameters and then sets this value to the min attribute.

Capabilities for ANSYS Mechanical

Adding a Pre-Processing Feature in ANSYS Mechanical

This section discusses customization for the ANSYS Mechanical application only as the targeted applic-ation needs to expose pre-processing features natively.

Thus far the discussion has been focused on extending the user interface by adding toolbars. This sectiondiscusses how to use toolbars to perform meaningful operations such as adding a pre-processing featureto ANSYS Mechanical. The example used in the discussion is defined in the DemoLoad extension. TheDemoLoad extension was written to create a generic load. This example is for demonstration purposesonly.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.44

Extension Capabilities

Page 53: ANSYS ACT Developers Guide

Below are the contents of the DemoLoad.xml file, which adds a load to a project.

As in previous examples, the XML first defines the extension using a version and name attribute. Thepath to the Python script file main.py is specified by the <script> tag. The definition of the toolbarand the buttons is done in the <interface> tag. The callback function named CreateDemoLoadis used to create and add the load to the simulation environment.

<extension version="1" minorversion="0" name="DemoLoad"> <script src="main.py" /> <interface context="Mechanical"> <images>images</images> <toolbar name="Loads" caption="Loads"> <entry name="DemoLoad" icon="tload"> <callbacks> <onclick>CreateDemoLoad</onclick> </callbacks> </entry> </toolbar> </interface>

<simdata context="Mechanical">

<load name="DemoLoad" version="1" caption="DemoLoad" icon="tload" color="#00FFFF">

<callbacks> <getnodalvaluesfordisplay>GetNodalValuesForDisplay_DL</getnodalvaluesfordisplay> <getprecommands>GetPreCommands_DL</getprecommands> <getsolvecommands order="1">GetSolveCommands_DL</getsolvecommands> </callbacks>

<property name="Geometry" caption="Geometry" control="scoping"> <attributes selection_filter="edge" /> </property> <property name="Text" caption="Text" control="text"></property> <property name="SelectStatic" caption="Select (static)" control="select"> <attributes options="Option 1,Option 2,Option 3" /> </property> <property name="SelectDynamic" caption="Select (dynamic)" control="select"> <callbacks> <onactivate>StringOptions_DL</onactivate> </callbacks> </property> <property name="Double" caption="Double" unit="Length" control="float" default="1 [m]"></property>

</load>

</simdata>

</extension>

The definition of the load is encapsulated by the <simdata> begin and end tags. The attributes inthe <load> begin tag provide the name, version, caption, icon, and color that apply to this load. Thecolor attribute is defined in a hexadecimal format. This color is used to contrast the load when it isdisplayed on the model. The load <callbacks> tag encapsulates two callbacks <getsolvecom-mands> and <getnodalvaluesfordisplay>.

• The tag <getnodalvaluesfordisplay> specifies the name of the Python function that is calledwhen the load is displayed in the application.

• The tag <getsolvecommands> specifies the name of the Python function that is called when thesolver input file is generated by the application. Consequently, the related Python function is responsiblefor generating the APDL commands that describe the load within the ANSYS input file. When get-

45Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS Mechanical

Page 54: ANSYS ACT Developers Guide

solvecommands is used, the solver commands are inserted into the solver input file just before theSOLVE command.

ACT provides two additional tags to better control where the specific solver commands are inserted inthe solver input file.

• The tag <getprecommands> inserts the solver commands before the standard loads and boundary con-ditions defined in the application. For the ANSYS solver, the new commands are inserted in the context ofthe /PREP7 preprocessor after the mesh has been written.

• The tag <getpostcommands> inserts the solver commands so they are executed after the solution hasbeen resolved. For the ANSYS solver, the new commands will be inserted in the context of the /POST1postprocessor after the /POST1 command.

Below the callbacks definition, you can define the properties that will be applied to the actual definitionof the load. These properties are displayed in the Details pane of ANSYS Mechanical, where the userprovides the necessary values to complete the load definition. In the Python script we will see how theload's properties can be retrieved and / or modified.

The following figure shows that each property defined above appears in the Details pane with thecorresponding names and types of interface control.

Figure 31: Properties in the Details Pane

Note that the two properties, Select (static) and Select (dynamic), use a select control type. Thefirst property populates the list of options from the XML, while the second one defines an <onactiv-ate> callback. This callback, which is called when the control is activated, populates the available optionsfor the property. This second approach allows a full control on the options to be exposed in the drop-down menu and makes the list of options dependent on the current status of the project. Many differentsituations that can impact the content of the list of options can be addressed, as long as they are im-plemented in the <onactivate> callback.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.46

Extension Capabilities

Page 55: ANSYS ACT Developers Guide

The next property, Double, does not require the definition of one specific callback. Instead, the XMLdefinition introduces a physical quantity dependency with the unit option; this option specifies thatthis property is consistent with a length. In addition, default value of 1 [m] is introduced with the de-fault option. This default value is exposed in the Details pane each time a new load is created.

Here is the Python script file main.py used for the DemoLoad extension.

import osdef init(context): ExtAPI.Log.WriteMessage("Init DemoLoads...")

def CreateDemoLoad(analysis): analysis.CreateLoadObject("DemoLoad")

def StringOptions_DL(load,prop): prop.ClearOptions() prop.AddOption("X") prop.AddOption("Y") prop.AddOption("Z")

def GetPreCommands_DL(load, stream): stream.Write("/COM, **************************************************" + "\n") stream.Write("/COM, Load properties from DemoLoad getprecommands event" + "\n") stream.Write("/COM, Text Property = " + load.Properties["Text"].ValueString + "\n") stream.Write("/COM, SelectDynamic Property = " + load.Properties["SelectDynamic"].ValueString + "\n") stream.Write("/COM, SelectStatic Property = " + load.Properties["SelectStatic"].ValueString + "\n") stream.Write("/COM, Double Property = " + load.Properties["Double"].ValueString + "\n") stream.Write("/COM, **************************************************" + "\n")

def GetSolveCommands_DL(load, stream): stream.Write("/COM, **************************************************" + "\n") stream.Write("/COM, Load properties from DemoLoad getsolvecommands event" + "\n") stream.Write("/COM, Text Property = " + load.Properties["Text"].ValueString + "\n") stream.Write("/COM, SelectDynamic Property = " + load.Properties["SelectDynamic"].ValueString + "\n") stream.Write("/COM, SelectStatic Property = " + load.Properties["SelectStatic"].ValueString + "\n") stream.Write("/COM, Double Property = " + load.Properties["Double"].ValueString + "\n") stream.Write("/COM, **************************************************" + "\n")

def GetNodalValuesForDisplay_DL(load, nodeIds): dval = load.Properties["Double"].Value coordselect = load.Properties["SelectDynamic"].ValueString mesh = load.Analysis.MeshData values = [] for id in nodeIds: node = mesh.NodeById(id) dispval = float(0.0) if coordselect == "X": dispval = node.X * float(dval) elif coordselect == "Y": dispval = node.Y * float(dval) elif coordselect == "Z": dispval = node.Z * float(dval) else: dispval = float(0.0) values.Add(dispval) return values

The functions GetNodalValuesForDisplay_DL and GetSolveCommands_DL are critical to thebehavior and application of the load. GetNodalValuesForDisplay_DL is called each time thegraphics is refreshed. The required input arguments are load and nodeIds, where load is the loadobject for this load, and nodeIds is a list of node identifiers.

In our example, load.Properties["Double"].Value queries for the "Double" property value. nodeIdscontains a list of node numbers on which one value has to be returned by the function. For every nodeof the list, the value of the Double property is assigned in the values array representing the output ofthe function. This output is subsequently treated by the graphics engine of the application so that thevisualization on the FE model is available.

47Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS Mechanical

Page 56: ANSYS ACT Developers Guide

GetSolveCommands is intentionally simplified for this example. The prototype of this function is madeof two input arguments, the load object and the filename in which the new specific solver commandsare written. It is important to note that this output file is only a temporary file, as the content is rewrittenin the final solver input file to ensure that the specific commands related to the customized load aremerged with all the other commands already defined by the standard features of the application.

You can also create a specific set of context menu options. These options use the property Action.

Actions are defined inside the <callbacks> section of the load.

<callbacks>

<ongenerate>generate</ongenerate> <oncleardata>clearData</oncleardata>

<action name="a1" caption="Action 1" icon="update">action1 </action> <action name="a2" caption="Action 2" icon="update">action2 </action>

</callbacks>

The <action> tag takes three attributes:

• A name to identify your action.

• A caption that will be displayed in the context menu.

• A name that refers to the picture that will be displayed for the icon. The image must be stored in the directoryspecified in the XML file.

The content of the tag defines the name of the Python function that is called when the user clicks onthe associated context menu option.

Figure 32: Customized Context Menu Options (p. 49) below shows the result of the declaration. Thereare now two additional context menu items, Action 1 and Action 2.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.48

Extension Capabilities

Page 57: ANSYS ACT Developers Guide

Figure 32: Customized Context Menu Options

As illustrated above, you can also add a Generate context menu option. This option derives from thestandard Generate action provided by Mechanical. For that reason, the declaration of this particularoption differs from the declaration of the options Action1 and Action2. This option is always associatedwith the Clear Generated Data option.

These options allow you to create a load that can mimic a standard Imported Load. The callback asso-ciated with the Generate option replaces the standard function integrated in Mechanical.

The feature is activated when you define the callback <ongenerate> for the load.

The <ongenerate> callback will be called each time the user clicks on the Generate context menuitem, as well as when the user solves, if the state of the load is set to "not solved."

As for the standard Imported Load object, the <ongenerate> callback will be called only if the meshis already generated.

<callbacks>

<ongenerate>generate</ongenerate> <oncleardata>clearData</oncleardata>

<action name="a1" caption="Action 1" icon="update">action1 </action> <action name="a2" caption="Action 2" icon="update">action2 </action>

</callbacks>

The associated Python code looks like:

def generate(load, fct): pct = 0 fct(pct,"Generating data...")

propEx = load.PropertyByName("Expression") exp = propEx.Value if exp=="":

49Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS Mechanical

Page 58: ANSYS ACT Developers Guide

return False try: vexp = compile(exp,'','eval') except: return False

values = SerializableDictionary[int,float]() nodeIds = []

propGeo = load.PropertyByName("Geometry") refIds = propGeo.Value mesh = ExtAPI.DataModel.MeshDataByName("Global") for refId in refIds: meshRegion = mesh.MeshRegionById(refId) nodeIds += meshRegion.NodeIds

nodeIds = list(set(nodeIds))

for i in range(0,nodeIds.Count): id = nodeIds[i] node = mesh.NodeById(id) x = node.X y = node.Y z = node.Z v = 0. try: v = eval(vexp) finally: values.Add(id,v) new_pct = (int)((i*100.)/nodeIds.Count) if new_pct!=pct: pct = new_pct stopped = fct(pct,"Generating data...") if stopped: return False

propEx.SetAttributeValue("Values",values) fct(100,"Generating data...")

return True

def clearData(load): ExtAPI.Log.WriteMessage("ClearData: "+load.Caption) propEx = load.PropertyByName("Expression") propEx.SetAttributeValue("Values",None)

The <ongenerate> callback takes two arguments: the load object and a function to manage a progressbar. This function takes also two arguments: the message to display and the value (between 0 and 100)of the progress bar.

During the process, the generated data is stored using an attribute on the property Expression. Moredetails on how to store data are given in section 5.8.

The <oncleardata> callback takes one argument: the load object. This callback is called each timethe mesh is cleaned or when the user selects on the Clean Generated Data context menu option.

Adding a Post-Processing Feature in ANSYS Mechanical

This section discusses customization for the ANSYS Mechanical application only as the targeted applic-ation needs to expose post-processing features natively.

This section discusses how to add a post-processing feature to ANSYS Mechanical. The example usedin the discussion is defined in the DemoResult extension, which creates a customized result thatcomputes the worst value of the principal stresses for the scoped geometry entities. This example isfor demonstration purposes only.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.50

Extension Capabilities

Page 59: ANSYS ACT Developers Guide

Following are the contents of the DemoResult.xml file, which adds a result to a project. As in previousexamples, the XML begins by defining the extension with a version and name attribute. The path tothe Python script file demoresult.py is specified by the <script></script> tag. The <inter-face> tag defines the toolbar and buttons. The callback function named Create_WPS_Result isused to create and add the result to the simulation environment.

<extension version="1" minorversion="0" name="DemoResult">

<script src="demoresult.py" />

<interface context="Mechanical">

<images>images</images>

<callbacks> <oninit>init</oninit> </callbacks>

<toolbar name="Stress Results" caption="Extension: Worst Principal Stress"> <entry name="Worst Principal Stress" icon="result"> <callbacks> <onclick>Create_WPS_Result</onclick> </callbacks> </entry> </toolbar>

</interface>

<simdata context="Mechanical">

<result name="Worst Principal Stress" version="1" caption="Worst Principal Stress" unit="Stress" icon="result" location="elemnode" type="scalar">

<callbacks> <evaluate>WPS_Eval</evaluate> </callbacks>

<property name="Geometry" caption="Geometry" control="scoping"></property>

</result>

</simdata>

</extension>

The definition of the result is encapsulated by the <simdata> begin and end tags. The attributes inthe <result> begin tag provide the name, version, caption, icon, and unit that apply to this result.The result <callbacks> tag encapsulates the single callback <evaluate> used for the evaluation.

The tag <evaluate> gives the name of the Python function that will be called to compute the resultwhen the application (i.e. presently ANSYS Mechanical) requests an evaluation. The output of thisfunction is sent directly to Mechanical to display the result.

Below the callbacks definition, you can define the properties that are applied to the actual resultdefinition. These properties are displayed in the Details pane of ANSYS Mechanical when the user hasselected the result in the Outline pane.

Figure 33: Properties in the Details Pane (p. 52) shows that each property appears in the Details paneof ANSYS Mechanical with the corresponding names and result values.

51Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS Mechanical

Page 60: ANSYS ACT Developers Guide

Figure 33: Properties in the Details Pane

Below are the contents of the Python script file demoresult.py, the script file used for the DemoRes-ult extension. The functions Create_WPS_Result and WPS_Eval are critical to the behavior andapplication of the result.

• The Create_WPS_Result function creates and adds the result to the simulation environment.

• The WPS_Eval function is called during solution or when the results need to be re-evaluated.

The callback function Create_WPS_Result is used to create the result and add it to the simulationenvironment. This function uses Python dot notation, which allows you to chain objects with methodsthat return objects to each other. In the expression analysis.CreateResultObject("AbsolutePrincipal Stress"), the IAnalysis object analysis is given in argument of the callback. This IAnalysisobject calls the CreateResultObject method. From CreateResultObject, the XML is interpretedand the internal mechanisms are set into motion to add the details and register the callbacks that definethe results framework. For more comprehensive descriptions of the API objects, methods and properties,see the Application Customization Toolkit Reference Guide.

The WPS_Eval function is called when the result needs to be evaluated or re-evaluated, dependingon the state of the simulation environment. The function definition requires the input arguments resultand step and the output argument collector. Result is the result object for this result and stepInfois an IStepInfo object that gives information on the step currently prescribed in the details.

WPS_Eval queries for the component stresses at each node of elements. The stress tensor is used thecompute the three principal stresses (eigenvalues), and then the signed maximum value over thesethree is stored as the final result for each node of element. WPS_Eval also deals with the conversionof units. DemoResults uses a utility library called units, which is imported at the beginning of thedemoresults.py file. With this library, WPS_Eval can derive a conversion factor for the stress unitsthat is consistent with the units used during solution. Note that the result to be returned by the evalu-

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.52

Extension Capabilities

Page 61: ANSYS ACT Developers Guide

ation function must be consistent with the international system of unit. Then the potential useful con-version to the current unit system in the application is done internally by ANSYS Workbench. Wheneverthe result values for Worst Principal Stress are needed for display purposes, ANSYS Mechanical usesdirectly the output of the function WPS_Eval. The two callbacks and their registration to the eventinfrastructure of ANSYS Mechanical make possible the full cycle of result definition, creation, evaluation,and display.

import units

wps_stress = {}eigenvalues = {}

def init(context): ExtAPI.Log.WriteMessage("Init Demoresult Extension...")

def Create_WPS_Result(analysis): ExtAPI.Log.WriteMessage("Launch Create_WPS_Result...") analysis.CreateResultObject("Worst Principal Stress")

# This function evaluates the specific result (i.e. the Absolute principal stress) on each element required by the geometry selection# The input data "step" represents the step on which we have to evaluate the resultdef WPS_Eval(result,stepInfo,collector): global wps_stress analysis = result.Analysis ExtAPI.Log.WriteMessage("Launch evaluation of the WPS result: ") # Reader initialization reader = analysis.GetResultsData() reader.CurrentResultSet = stepInfo.set # Get the stress result from the reader stress = reader.GetResult("S") # Unit sytem management: # First get the unit system that was used during the resolution # Second compute the coefficient to be used so that the final result will be returned in the SI unit system unit_stress = stress.GetComponentInfo('X').Unit conv_stress = units.ConvertUnit(1.,unit_stress,"Pa","Stress")

# Get the selected geometry propGeo = result.Properties["Geometry"] refIds = propGeo.Value.Ids # Get the mesh of the model mesh = analysis.MeshData #Loop on the list of the selected geometrical entities for refId in refIds: # Get mesh information for each geometrical entity meshRegion = mesh.MeshRegionById(refId) elementIds = meshRegion.ElementIds # Loop on the elements related to the current geometrical entity for elementId in elementIds: # Get the stress tensor related to the current element tensor = stress.ElementValue(elementId,"X;Y;Z;XY;XZ;YZ") # Get element information element = mesh.ElementById(elementId) nodeIds = element.CornerNodeIds

values = [] # Loop on the nodes of the current element to compute the Von-Mises stress on the element nodes for i in range(0,nodeIds.Count): local_wps = WPS(tensor[6*i:6*(i+1)])

# Final stress result has to be returned in theSI unit system local_wps = local_wps * conv_stress values.Add(local_wps) collector.SetValues(elementId, values)

# This function computes the absolute principal stress from the stress tensor# The Von-Mises stess is computed based on the three eigenvalues of the stress tensor def WPS(tensor):

53Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS Mechanical

Page 62: ANSYS ACT Developers Guide

# Computation of the eigenvalues eigenvalues = EigenValues(tensor)

# Extraction of the worst principal stress wplocal_stress = eigenvalues[0] if abs(eigenvalues[1])>abs(wplocal_stress): wplocal_stress = eigenvalues[1] if abs(eigenvalues[2])>abs(wplocal_stress): wplocal_stress = eigenvalues[2]

# Return the worst value of the three principal stresses S1, S2, S3 return wplocal_stress

# This function computes the three eigenvalues of one [3*3] symetric tensorEPSILON = 1e-4def EigenValues(tensor): global eigenvalues

eigenvalues = []

a = tensor[0] b = tensor[1] c = tensor[2] d = tensor[3] e = tensor[4] f = tensor[5]

if ((abs(d)>EPSILON) or (abs(e)>EPSILON) or (abs(f)>EPSILON)): # Polynomial reduction A = -(a+b+c) B = a*b+a*c+b*c-d*d-e*e-f*f C = d*d*c+f*f*a+e*e*b-2*d*e*f-a*b*c

p = B-A*A/3 q = C-A*B/3+2*A*A*A/27 if (q<0): R = -sqrt(fabs(p)/3) else: R = sqrt(fabs(p)/3)

phi = acos(q/(2*R*R*R))

S1=-2*R*cos(phi/3)-A/3 S2=-2*R*cos(phi/3+2*3.1415927/3)-A/3 S3=-2*R*cos(phi/3+4*3.1415927/3)-A/3 else: S1 = a S2 = b S3 = c

eigenvalues.Add(S1) eigenvalues.Add(S2) eigenvalues.Add(S3)

return eigenvalues

ACT introduces a new method to facilitate the development of Python functions to evaluate simulationresults. The third output argument collector is internally initialized based on the content of the scopingproperty. When defined, this property contains the list of FE entities on which results are evaluated.This information can be used directly in Python functions without looping over mesh regions. The fol-lowing demonstrates the use of this method in the function WPS_Eval.

import units

wps_stress = {}eigenvalues = {}

def init(context): ExtAPI.Log.WriteMessage("Init Demoresult Extension...")

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.54

Extension Capabilities

Page 63: ANSYS ACT Developers Guide

def Create_WPS_Result(analysis): ExtAPI.Log.WriteMessage("Launch Create_WPS_Result...") analysis.CreateResultObject("Worst Principal Stress")

# This function evaluates the specific result (i.e. the Absolute principal stress) on each element required by the geometry selection# The input data "step" represents the step on which we have to evaluate the resultdef WPS_Eval(result,stepInfo,collector): global wps_stress analysis = result.Analysis ExtAPI.Log.WriteMessage("Launch evaluation of the WPS result: ") # Reader initialization reader = analysis.GetResultsData() reader.CurrentResultSet = stepInfo.Set # Get the stress result from the reader stress = reader.GetResult("S") # Unit sytem management: # First get the unit system that was used during the resolution # Second compute the coefficient to be used so that the final result will be returned in the SI unit system unit_stress = stress.GetComponentInfo('X').Unit conv_stress = units.ConvertUnit(1.,unit_stress,"Pa","Stress")

# Loop on the elements related to the collector.Ids list for elementId in collector.Ids: # Get the stress tensor related to the current element tensor = stress.ElementValue(elementId,"X;Y;Z;XY;XZ;YZ") # Get element information element = mesh.ElementById(elementId) nodeIds = element.CornerNodeIds

values = [] # Loop on the nodes of the current element to compute the Von-Mises stress on the element nodes for i in range(0,nodeIds.Count): local_wps = WPS(tensor[6*i:6*(i+1)])

# Final stress result has to be returned in theSI unit system local_wps = local_wps * conv_stress values.Add(local_wps)

collector.SetValues(elementId, values)

# This function computes the absolute principal stress from the stress tensor# The Von-Mises stess is computed based on the three eigenvalues of the stress tensor def WPS(tensor):

# Computation of the eigenvalues eigenvalues = EigenValues(tensor)

# Extraction of the worst principal stress wplocal_stress = eigenvalues[0] if abs(eigenvalues[1])>abs(wplocal_stress): wplocal_stress = eigenvalues[1] if abs(eigenvalues[2])>abs(wplocal_stress): wplocal_stress = eigenvalues[2]

# Return the worst value of the three principal stresses S1, S2, S3 return wplocal_stress

# This function computes the three eigenvalues of one [3*3] symetric tensorEPSILON = 1e-4def EigenValues(tensor): global eigenvalues

eigenvalues = []

a = tensor[0] b = tensor[1] c = tensor[2] d = tensor[3]

55Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS Mechanical

Page 64: ANSYS ACT Developers Guide

e = tensor[4] f = tensor[5]

if ((abs(d)>EPSILON) or (abs(e)>EPSILON) or (abs(f)>EPSILON)): # Polynomial reduction A = -(a+b+c) B = a*b+a*c+b*c-d*d-e*e-f*f C = d*d*c+f*f*a+e*e*b-2*d*e*f-a*b*c

p = B-A*A/3 q = C-A*B/3+2*A*A*A/27 if (q<0): R = -sqrt(fabs(p)/3) else: R = sqrt(fabs(p)/3)

phi = acos(q/(2*R*R*R))

S1=-2*R*cos(phi/3)-A/3 S2=-2*R*cos(phi/3+2*3.1415927/3)-A/3 S3=-2*R*cos(phi/3+4*3.1415927/3)-A/3 else: S1 = a S2 = b S3 = c

eigenvalues.Add(S1) eigenvalues.Add(S2) eigenvalues.Add(S3)

return eigenvalues

This extension takes advantage of the fact that the collector.Ids property is initialized with the elementnumbers related to the selected geometrical entities. This list can be used to evaluate results for eachelement. The collector.Ids property contains nodes or element numbers depending on the typeof result defined in the XML file of the extension. For results with the location set to node, collector.Idscontains a list of node numbers. For results with the location set to elem or elemnode, collector.Idscontains a list of element numbers.

Creating Results with Imaginary Parts

Creating results for analyses which have complex results requires managing both real and imaginaryvalues. The SetValues() method is used to set values to the real part of the result. A second methodnamed SetImaginaryValues() is also available to set values to the imaginary part of the result.

An example of the creation of a complex result is shown below:

def Evaluate(result,stepInfo,collector):

for id in collectors.Ids: real_value = 1. # Set the real part of the result collector.SetValues(id, real_value)

imaginary_value = 2. # Set the imaginary part of the result collector.SetImaginaryValues(id, imaginary_value)

Obsolete ”OnStartEval” and “GetValue” Callbacks

Both callbacks <onstarteval> and <getvalue> have been replaced by the single callback<evaluate>. The <evaluate> callback simplifies the implementation of an ACT result, which nowrequires only a single Python function. The callbacks <onstarteval> and <getvalue> are still

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.56

Extension Capabilities

Page 65: ANSYS ACT Developers Guide

supported for extensions developed in previous versions of ACT, but the use of the <evaluate>callback is recommended for new extension development.

Connecting to a Third-Party Solver

This section discusses how to add a connection to a third-party solver, or the ability to launch an ex-ternal process from the Mechanical system instead of launching the ANSYS solver. The example usedin this section is defined in the ExtSolver1 extension, which was written to demonstrate the abilityto plug a very simple solver. This solver distributes the values assigned at boundaries inside the structure.This example is for demonstration purposes only.

Third-Party Solver Connection Extension

We will begin by looking at the XML required to add a third-party solver in a project, as defined in theExtSolver1.xml file.

<simdata context="Project|Mechanical">

<solver name="Solver1" version="1" caption="Solver1" icon="result" analysis="Static" physics="Structural">

<callbacks> <onsolve>Solve</onsolve> <getsteps>GetSteps</getsteps> <getreader>GetReader</getreader> </callbacks>

<property name="MaxIter" caption="Max. Iterations" control="integer" default="10" />

</solver>

</simdata>

<simdata context="Mechanical">

<load name="Values" version="1" caption="Values" icon="tload" issupport="false" isload="true" color="#0000FF">

<callbacks> <getsolvecommands>WriteInitialValues</getsolvecommands> <getnodalvaluesfordisplay>NodeValues</getnodalvaluesfordisplay> </callbacks>

<property name="Geometry" control="scoping" /> <property name="Expression" caption="Expression" control="text" />

</load>

</simdata>

As with the loads and results features, the solver definition must be encapsulated within a <simdata>tag. In this example the context attribute is "Project|Mechanical." When "Project" is specified as acontext attribute, the solver appears as a component in the Workbench Project Schematic (see Fig-ure 34: Project Schematic with External Solver System (p. 58)).

The solver definition begins with the tag <solver>. This tag takes some mandatory attributes:

• name: internal name of the solver

• version: version of the solver

• caption: display name of the solver

57Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS Mechanical

Page 66: ANSYS ACT Developers Guide

• analysis: analysis type addressed by the third-party solver. For compatibility reasons, this attribute mustbe set to Static, but this does not prevent you from integrating any type of third-party solver.

• physics: physics type addressed by the third-party solver. Today, this attribute must be set to Structural.This tag as no real impact on what the solver computes.

You must define the callback <onsolve>. This callback is called when the application launches thesolver and thus takes in argument the sol ver object.

You can define a set of properties, which appear in the details view of the analysis. In the example, asimple property is created to define the maximum number of iterations to be performed by the solver.By default the value is set to 10.

Figure 34: Project Schematic with External Solver System (p. 58) shows the new system in the toolbox.Each third-party solver is added into a new category, identified by the caption of the extension; thesystem is named by the caption of the solver.

The system related to the third-party solver is equivalent to one standard system that can be createdwith the ANSYS solver. The components that build this new system remain the same. Then the usercan add in the schematic a new system related to the solver just as he does for any other systems.

Figure 34: Project Schematic with External Solver System

Following is the code for the extension (file main.py). The solver code is located in a separate file,solver.py, which is placed in the same folder as main.py. The third line of the main.py script is"import solver." This Python technique is using separate code for reuse and maintainability. The scriptin solver.py defines the SolverEngine class.

import osimport solver

def CreateValuesLoad(analysis): analysis.CreateLoadObject("Values")

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.58

Extension Capabilities

Page 67: ANSYS ACT Developers Guide

initValues = {}sol = Nonesolbystep = {}values = {}steps = []res = [0.]dScal = [0.]dVec = [0., 0., 0.]

def WriteInitialValues(load,filename): global initValues propEx = load.Properties["Expression"] exp = propEx.Value if exp=="": return None vexp = compile(exp,'','eval') values = [] propGeo = load.Properties["Geometry"] refIds = propGeo.Value.Ids mesh = load.Analysis.MeshData for refId in refIds: meshRegion = mesh.MeshRegionById(refId) nodeIds = meshRegion.NodeIds for nodeId in nodeIds: node = mesh.NodeById(nodeId) x = node.X y = node.Y z = node.Z v = 0. try: v = eval(vexp) v = float(v) finally: initValues.Add(nodeId,v)

def NodeValues(load,nodeIds): propEx = load.Properties["Expression"] exp = propEx.Value if exp=="": return None try: vexp = compile(exp,'','eval') except: return None values = [] mesh = load.Analysis.MeshData for id in nodeIds: node = mesh.NodeById(id) x = node.X y = node.Y z = node.Z v = 0. try: v = eval(vexp) v = float(v) finally: values.Add(v) return values

def Solve(s, fct): global steps global initValues global sol global solbystep global values

solbystep = {} solbystepTmp = {}

f = open("solve.out","w") f.write("SolverEngine version 1.0\n\n\n") try:

59Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS Mechanical

Page 68: ANSYS ACT Developers Guide

maxIter = int(s.Properties["MaxIter"].Value) f.write("Max. iteration : %d\n" % (maxIter))

mesh = s.Analysis.MeshData

numEdges = 0 geo = ExtAPI.DataModel.GeoData nodeIds = [] for asm in geo.Assemblies: for part in asm.Parts: for body in part.Bodies: for edge in body.Edges: numEdges = numEdges + 1 ids = mesh.MeshRegionById(edge.Id).NodeIds nodeIds.extend(ids) steps = [] stepsTmp = [] f.write("Num. edges : %d\n" % (numEdges)) sol = solver.SolverEngine(mesh,initValues,nodeIds) initValues = sol.Run(maxIter,f,stepsTmp,solbystepTmp) nodeIds = mesh.NodeIds sol = solver.SolverEngine(mesh,initValues,nodeIds) values = sol.Run(maxIter,f,steps,solbystep)

initValues = {}

except StandardError, e: f.write("Error:\n"); f.write(e.message+"\n"); f.close() return False

f.close()

return True

def GetSteps(solver): global steps return steps

def Save(folder): global solbystep fm = System.Runtime.Serialization.Formatters.Binary.BinaryFormatter() try: stream = System.IO.StreamWriter(os.path.join(folder,"sol.res"),False) except: return try: fm.Serialize(stream.BaseStream,solbystep) finally: stream.Close()

def Load(folder): global solbystep if folder==None: return fm = System.Runtime.Serialization.Formatters.Binary.BinaryFormatter() try: stream = System.IO.StreamReader(os.path.join(folder,"sol.res")) except: return try: solbystep = fm.Deserialize(stream.BaseStream) finally: stream.Close()

class ExtSolver1Reader(ICustomResultHeader): def __init__(self,infos): self.infos = infos self.step = 1

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.60

Extension Capabilities

Page 69: ANSYS ACT Developers Guide

def GetCurrentStep(self): return self.step

def SetCurrentStep(self,stepInfo): self.step = stepInfo

def GetStepValues(self): global steps return steps

def GetResultNames(self): return ["VALUES"]

def GetResultLocation(self,resultName): return ResultLocationEnum.Node

def GetResultType(self,resultName): return ResultTypeEnum.Scalar

def GetComponentNames(self,resultName): return [""]

def GetComponentUnit(self,resultName,componentName): return "Temperature"

def GetValues(self,resultName,collector): global solbystep if self.step.Set in solbystep: values = solbystep[self.step.Set] for id in collector.Ids: if id in values: collector.SetValues(id, [values[id]])

def GetReader(solver): return ["ExtSolver1Reader"]

The function associated to the <onsolve> callback is Solve. This function creates a file solve.out,which is read interactively by the application and stored in the solution information.

By default, the application launches the resolution directly into the working directory, so it is not neces-sary to set the folder in which the solve.out file must be created.

The callback function must return True or False to specify if the solve has succeeded or failed.

Note that it is not possible to return progress information with the current version.

Post Processing

You can create a result reader to expose results.

To do that, you create a class that implements the ICustomResultReader interface. The followingmethods need to be implemented. For each method, the expected results that must be returned aredescribed.

GetCurrentStep(self)This method must return the current step number.

SetCurrentStep(self,stepInfo)This method is called each time the current step number is changed.

GetStepValues(self)This method must return a lost of double values that represents the time steps or frequencies.

61Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS Mechanical

Page 70: ANSYS ACT Developers Guide

GetResultNames(self)This method must return a list of strings that represents the result names available for the reader.

GetResultLocation(self,resultName)This method must return the location type of the result identified by the name resultName. The possiblevalues are node,element, and elemnode.

GetResultType(self,resultName)This method must return the type of the result identified by the name resultName. The possible valuesare scalar,vector, and tensor.

GetComponentNames(self,resultName)This method must return a list of strings that represents the list of available components available for theresult identified by the name resultName.

GetComponentUnit(self,resultName,componentName)This method must return the unit name related to the result’s component identified by the result nameresultName and the component name componentName.

GetValues(self,resultName,collector)This method must return a list of double values for each component associated to the result identified bythe name resultName.

To specify a dedicated reader, add a <getreader> callback in the solver definition. This callback returnsa list of string, where the first is the name of the reader class and the remainder represents parametersgiven to the constructor of the class when the reader is instanced by ACT. Any result exposed in themethod ResultNames() will be available in Mechanical's Results worksheet.

If the name of the result matches a standard result name (like "U"), Workbench applies the same treatmentfor this result than for a standard one. So, if the result is named "U", Workbench uses this result to drawthe deformed model.

In the Extsolver1 example, the reader declares one single scalar nodal result “VALUES”. No deform-ation is considered.

Load and Save Data

It is possible to use the callbacks <onload> and <onsave> under the <interface> tag to loadand save data associated with the third-party solver. As previously discussed, the proposed extensionuses the <onload> and <onsave> callbacks to save and load the computed results. With the currentextension, the results are still available if the user closes and reopens the Solver1 system.

The <onload> and <onsave> callbacks take in argument the name of the working directory.

Figure 35: Analysis Settings Object Associated to External Solver (p. 63) and Figure 36: Boundary ConditionObject Associated to External Solver (p. 63) show the specific objects that must be integrated in thedefinition tree in order to set up an analysis based on the external solver.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.62

Extension Capabilities

Page 71: ANSYS ACT Developers Guide

Figure 35: Analysis Settings Object Associated to External Solver

Figure 36: Boundary Condition Object Associated to External Solver

63Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS Mechanical

Page 72: ANSYS ACT Developers Guide

Figure 37: Solution Information Associated to External Solver (p. 64)a nd Figure 38: Post-processing As-sociated to External Solver (p. 65) show the two types of output derived from the resolution. Note thatthe solution information is interactively displayed during the resolution.

Figure 37: Solution Information Associated to External Solver

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.64

Extension Capabilities

Page 73: ANSYS ACT Developers Guide

Figure 38: Post-processing Associated to External Solver

Capabilities for ANSYS DesignModeler

This section discusses customization of the ANSYS DesignModeler application. Whereas in the ANSYSMechanical application ACT is used to work with loads and results, in DesignModeler it is instead usedto work with geometries. Once you have used ACT to add custom toolbars and menus to the Design-Modeler user interface, you can use those entities to generate geometries by creating and using aprimitive generator, defining properties, and applying various operations to the resulting geometry.

This example extension, GeometryFeature, shows how to add a geometry to DesignModeler. Thisexample is for demonstration purposes only.

The GeometryFeature extension was written to create a geometry based on an existing part. Aspart of this process, we will draw a circle, define a disc based on the circle, and extrude the disc into acylinder.

We will address the extension’s XML file and Python file separately.

Geometry Definition in the XML File

The XML file for our example is called GeometryFeature.xml and is shown below.

<extension version="1" name="GeometryFeature"> <script src="main.py" /> <interface context="DesignModeler"> <images>images</images> <toolbar name="ACTtoolbar" caption="ACTtoolbar"> <entry name="MyFeature" icon="construction"> <callbacks> <onclick>createMyFeature</onclick>

65Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS DesignModeler

Page 74: ANSYS ACT Developers Guide

</callbacks> </entry> </toolbar> </interface> <simdata context="DesignModeler"> <geometry name="MyFeature" caption="MyFeature" icon="construction" version="1"> <callbacks> <ongenerate>generateMyFeature</ongenerate> <onaftergenerate>afterGenerateMyFeature</onaftergenerate> </callbacks> <property name="Face" caption="Face" control="scoping"> <attibutes selection_filter="face"/> </property> <property name="Length" caption="Length" control="float" unit="Length" default="1.2 [m]"></property> <property name="Minimum Volume" caption="Minimum Volume" control="float" unit="Volume" ><attributes readonlyaftergenerate="true" /> </property> </geometry> </simdata></extension>

As in previous examples, the XML first defines the extension using a version and name attribute. Thepath to the Python script file main.py is specified by the <script> tag. The ACT toolbar is definedin the <interface> tag, which has a context of DesignModeler. The callback function named cre-ateMyFeature is used to create and add the geometry to the DesignModeler environment.

The definition of the geometry is encapsulated by the <simdata> begin and end tags. The attributesin the <geometry> begin tag provide the name, caption, icon, and version that apply to this geometry.The geometry <callbacks> tag encapsulates two callbacks <ongenerate> and <onaftergener-ate>.

• The tag <ongenerate> specifies the name of the Python function that is called when the geometry isgenerated by the application. The application provides the geometry type (type IDesignModelerGeoFea-ture) as the callback argument.

This callback must return a Boolean value to indicate whether the generation has been successful; itreturns true if the generation has succeeded and false if it has failed.

• The tag <onaftergenerate> specifies the name of the Python function that is called after the geometryis generated by the application. The application provides the geometry type (type IDesignModeler-GeoFeature) as the callback argument.

To specify additional details about the geometry, you can include additional tags, such as <canadd>,<onadd>, <oninit>, or <onmigragte> between the <callbacks> begin and end tags.

Below the callbacks definition, you can define the properties that will be applied to the actual definitionof the geometry (in this example, Face and Length). These properties are displayed in the Details Viewpane of ANSYS DesignModeler, where the user provides the necessary values to complete the geometrydefinition. When we review the Python script in a subsequent section, we will see how the geometryproperties can be retrieved and/or modified.

The following figure shows that each property defined above appears in the Details View pane withthe corresponding names and types of interface control.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.66

Extension Capabilities

Page 75: ANSYS ACT Developers Guide

Figure 39: Feature and Corresponding Properties in the Details View Pane

Note that the two geometry properties, Face and Length, use different control types.

• The Face property uses a scoping control type with the attribute of selection_filter set to face.This specifies that the value for this property will be one or more faces. The faces will be defined in themain.py file and then used to generate our geometry.

• The Length property uses a float control type, and does not require the definition of one specific callback.Instead, the XML definition introduces a physical quantity dependency with the unit attribute, whichspecifies that this property is consistent with a length. The default attribute specifies a default valueof 1.2[m]; this default value is exposed in the Details View pane each time a new load is created.

Geometry Definition in the Python File

The Python file for our example is called main.py and is shown below. We will discuss the Pythonfunctions associated with the <ongenerate> and <onaftergenerate> callbacks.

import unitsimport math

def createMyFeature(feature): ExtAPI.CreateFeature("MyFeature")

def vectorProduct(v1, v2): return [v1[1]*v2[2]-v1[2]*v2[1], -v1[0]*v2[2]+v1[2]*v2[0], v1[0]*v2[1]-v1[1]*v2[0]]

def scalarProduct(v1, v2): return v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2]

def norm(v): return math.sqrt(scalarProduct(v,v))

def generateMyFeature(feature,function):

length = feature.Properties["Length"].Value length = units.ConvertUnit(length, ExtAPI.DataModel.CurrentUnitFromQuantityName("Length"), "m") faces = feature.Properties["Face"].Value.Entities bodies = [] builder = ExtAPI.DataModel.GeometryBuilder

67Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS DesignModeler

Page 76: ANSYS ACT Developers Guide

for face in faces: centroid = face.Centroid uv = face.ParamAtPoint(centroid) normal = face.NormalAtParam(uv[0], uv[1]) radius = math.sqrt(face.Area/(math.pi*2))

xdir = [1., 0., 0.] vector = vectorProduct(xdir, normal) if norm(vector)<1.e-12: xdir = [0., 1., 1.] s = scalarProduct(xdir, normal) xdir = [xdir[0]-s*normal[0],xdir[1]-s*normal[1],xdir[2]-s*normal[2]] n = norm(xdir) xdir[0] /= n xdir[1] /= n xdir[2] /= n

arc_generator = builder.Primitives.Wire.CreateArc(radius, centroid, xdir, normal) arc_generated = arc_generator.Generate()

disc_generator = builder.Operations.Tools.WireToSheetBody(arc_generated)

normal[0] *= -1 normal[1] *= -1 normal[2] *= -1 extrude = builder.Operations.CreateExtrudeOperation(normal,length) cylinder_generator = extrude.ApplyTo(disc_generator)[0]

bodies.Add(cylinder_generator)

feature.Bodies = bodies feature.MaterialType = MaterialTypeEnum.Add return True

def afterGenerateMyFeature(feature): edges = [] minimum_volume = System.Double.MaxValue for body in feature.Bodies: body_volume = 0 if str(body.BodyType) == "GeoBodySolid": body_volume = body.Volume if body_volume <= minimum_volume: minimum_volume = body_volume

for edge in body.Edges: edges.Add(edge) else: ExtAPI.Log.WriteMessage("Part: "+body.Name)

feature.Properties["Minimum Volume"].Value = minimum_volume

ExtAPI.SelectionManager.NewSelection(edges) named_selection = ExtAPI.DataModel.FeatureManager.CreateNamedSelection() ExtAPI.SelectionManager.ClearSelection()

Functions Associated with the <ongenerate> Callback

Below, we will describe the Python functions associated with the <ongenerate> callback.

• The function createMyFeature(feature) creates the geometry in the DesignModeler tree. It willbe displayed as My Feature in the Tree Outline.

• The mathematical functions vectorProduct and scalarProduct will be used later in the gener-ateMyFeature function.

The first several functions configure details that will be used later in the creation of the geometry.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.68

Extension Capabilities

Page 77: ANSYS ACT Developers Guide

In our example, the function generateMyFeature is referenced in the GeometryFeature.xmlfile by the <ongenerate> callback. When called, it generates the geometry feature. Within this function,the following details about the geometry are defined:

• The length property, which will be used later to create the primitive. The conversion of the length unitensures that we are working with the expected metric unit.

• The scoped face property, which in this example is three faces.

• The bodies list, where we will add all the geometric features to be created.

• The builder, which serves as the ACT gateway in DesignModeler. We will access all features and operationsfrom here.

• The faces variable, which will be used as the argument to create our circle. Under faces:

– Define the centroid of the scoped face.

– Evaluate the normal to this face.

– Evaluate the radius that will be used for our arc wire.

• Calculate the xdir, which is the principle direction of the arc wire defined below and is required to drawour arc.

• The vectorProduct and scalarProduct objects are used to specify the location of the geometry’sprimitives and operations.

• The next several objects generate an arc wire.

– With the arc_generator object, we use the primitive generator builder.Primitives.Wire.Cre-ateArc. The CreateArc() method uses arguments from faces to draw the circle. This generator canbe used one or more times to build the primitive body.

– With the arc_generated object, we use the Generate() method to generate the primitive body.

– With the disc_generator object, we use the operations generator builder.Opera-tions.Tools.WireToSheetBody to define a disc based on the circle.

• The next several lines extrude the disc into a cylinder.

– With the extrude object, we use the operations generator builder.Operations.CreateExtrude-Operation. The CreateExtrudeOperation specifies that the resulting extrusion will be equal tothe value of the Length property.

– With cylinder_generator object, we use the ApplyTo method to define the geometry to whichthe extrude operation will be applied. The ApplyTo() method returns a list of bodies to which the op-eration will be applied.

• Bodies added to the feature.Bodies list will be added to DesignModeler after the generation. All otherbodies used in the generation process will be lost.

The feature.Bodies list can contain both bodies and parts. We can create a part with the commandbuilder.Operations.Tools.CreatePart(list_of_bodies).

69Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS DesignModeler

Page 78: ANSYS ACT Developers Guide

• The material.Type allows us to enter different properties such as Freeze,Cut, and Add. The imagebelow illustrates the resulting geometry given selection of the different properties.

Figure 40: Effect of different material type properties on the geometry

Functions Associated with the <onaftergenereate> Callback

Below, we will describe the Python function associated with the <onaftergenerate> callback, whichspecifies the name of the IronPython function called when the <ongenerate> callback is complete.The <onaftergenerate> callback:

• Allows you to access and work with the part or bodies created previously by the <ongenerate>callback.

For example, you can use it rename a part or body, suppress it, create a named selection, createa new selection via the Selection Manager, or access one or more of the geometric features ofa body as its area.

• Unlike the <ongenerate> callback, which expects a return value of True or False, does not expecta return value.

• Allows you to define properties for the feature to be created.

In our example, the function afterGenerateMyFeature is referenced in the GeometryFea-ture.xml file by the <ongenerate> callback. It accepts only the feature itself as an argument. Whencalled, it specifies the properties and attributes of the feature and selects edges of the bodies created,as described below:

• The edges list, where we will add all the edges of the bodies to be created for the feature.

• The Minimum Volume property, which in this example will be the volume of the body with the smallestvolume of all the bodies created for the feature. It uses a float control type and uses the unit attributeto specify a value consistent with a volume. Because this property has the special attributereadonlyaftergenerate set to true, the value becomes non-editable after generation of thefeature.

• The edge variable, which will be used to find the edges of all the bodies created for the feature.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.70

Extension Capabilities

Page 79: ANSYS ACT Developers Guide

• The feature.Properties[Minimum Volume”].Value entry sets the Minimum Volumeproperty in DesignModeler to the minimum_volume value.

• The ExtAPI.SelectionManager.NewSelection(edges) command creates a new selectionincluding all the edges previously selected.

• The named_selection = ExtAPI.DataModel.FeatureManager.CreateNamedSelec-tion() command creates a named selection which will be defined by the current selection containingall the edges previously selected.

Figure 41: Feature, Named Selection, and Properties in DesignModeler

Capabilities for ANSYS DesignXplorer

This section discusses how to define functionality for ANSYS DesignXplorer. The ANSYS DesignXplorerapplication is the ANSYS Workbench add-in that offers design exploration and optimization features.

You can create an ACT extension to integrate external functionality with the standard ANSYSDesignXplorer (DX) application. A DOE Extension integrates one or more external sampling methods,while an Optimization Extension integrates one or more external optimization methods.

From a user-interface point of view, the sampling or optimization method, along with specific propertiesto control its behavior, is hosted and exposed in DX as an additional method. Through its API, DXprovides the services required the calculation of points, report progress, and return results. The end-user experience is the same for both built-in and external methods of optimization or sampling.

From a development point of view, a sampling or optimizer is defined as a standard ACT extension thatincludes one or more specific elements for the DesignXplorer context. A required callback, which allowsfor the instantiation of the external method, is a class generally coded in C#, C/C++ or Fortran by theextension developer. The callback class must implement the method interface (ISamplingMethodor IOptimizationMethod) in order for the sampling or optimizer to be recognized as valid and in-teract with DX.

71Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS DesignXplorer

Page 80: ANSYS ACT Developers Guide

DX takes advantage of the ANSYS Workbench platform to allow parametric studies in a generic way forany simulation project. Regardless of the number of solvers and physics or the complexity of theworkflow involved to execute the simulation, DX sees the same simplified representation of the projectand interacts with it only in terms of parameters, design points, and the associated services.

Figure 42: DesignXplorer DOEs in an ANSYS Workbench Project

This generic architecture makes it possible to implement a variety of algorithms without needing toworry about the communication with solvers. Since the external methods are hosted by DX, they alsotake advantage of the ANSYS Workbench platform architecture to work with any kind of simulationproject defined in ANSYS Workbench, with no additional implementation effort.

The Design Exploration Process

The external functionality defined by the extension is responsible for carrying out relevant analysis tasksas defined by the DX user; the external optimizer is responsible for solving the optimization study, andthe external sampling is responsible for generating the DOE. Note that the external functionality is notrequired to support all the features available in DX. On the other hand, since the sampling or optimizeris hosted in the DX environment, it is subject to the environment’s limitations; as such, some of theexternal features may not be available in DX.

The DOE and optimization study are defined as follows:

Optimization StudyDesign of Experiments

VariablesVariables

Optimization domainDOE domain

Parameter relationships

Objectives

Constraints

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.72

Extension Capabilities

Page 81: ANSYS ACT Developers Guide

The Variables are the parameters of the Workbench project. As there are input and output parameters,there are input and output variables for the sampling or optimization. Note that, since the user candisable input parameters, the number of input variables transferred to the external functionality issmaller than or equal to the number of input parameters defined in the Workbench project.

The Domain is the multidimensional space that the sampling or optimizer can explore in order togenerate the DOE or solve the optimization problem. It is defined by the input variables and their rangeof variation or as a list of possible values. There are different types of input variables:

• Double Variable:

– Continuous variable defined by a range of variation, from its lower to its upper bound, where the boundsare real values

– Exposed to the user as a Continuous Input Parameter

• Double List Variable:

– Defined by a list of sorted real values

– Exposed to the user as a Continuous Input Parameter with Manufacturable Values

• Integer List Variable:

– Defined by a list of integer values

– Exposed to the user as a Discrete Input Parameter

The optimization Parameter Relationships define relationships between input variables such as“P1+2*P2 <= 12.5[mm]”. They allow the user to restrict the definition of the optimization domain.

The optimization Objectives are defined on variables (e.g., Minimize P3). The following objective typesare supported:

• Minimize a variable

• Maximize a variable

• Seek Target for a variable, where the target is a user-specified constant value

The optimization Constraints are defined on variables, as well (e.g., P3 <= 80). Both an objective anda constraint can be defined for the same variable. The following constraint types are supported:

• Less Than, where the user defines the lower bound (constant value)

• Greater Than, where the user defines the upper bound (constant value)

• Equal To, where the user defines the target value (constant value)

• Inside Bounds, where the user defines the targeted interval (constant values)

The DX Component

DX exposes several types of systems in Workbench, with each system type corresponding to one of itsparametric features such as Parameters Correlation, Response Surface, Six Sigma Analysis, etc. DXcomponents can be found in the Design Exploration toolbox.

73Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS DesignXplorer

Page 82: ANSYS ACT Developers Guide

The DOE Component

The DOE component appears in two different kinds of DOE systems, the Response Surface system andthe Response Surface Optimization system. It provides a selection of built-in sampling methods. Eachsampling method comes with its own specific standard and advanced properties, capabilities, and lim-itations.

Figure 43: DesignXplorer Systems Containing DOEs in the Design Exploration Toolbox

The Optimization Component

The Optimization component appears in two different kinds of optimization systems, the Direct Op-timization system and the Response Surface Optimization system. It provides a selection of built-inoptimization methods. Each method comes with its own specific standard and advanced properties,capabilities, and limitations.

Figure 44: DesignXplorer Optimization Systems in the Design Exploration Toolbox

• Direct Optimization system:

– The system is composed only of an Optimization component.

– Each point requested by the optimizer is calculated by updating a design point (real solve).

– With this approach:

→ The optimizer manipulates accurate output parameter values (directly returned by the solver).

→ The number of input parameters is not limited. However, the cost is proportional to the number ofpoints.

• Response Surface Optimization system:

– The system is composed of three components (Design of Experiments, Response Surface, and Optim-ization).

– Each point requested by the optimizer is calculated by evaluating the response surface.

– With this approach:

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.74

Extension Capabilities

Page 83: ANSYS ACT Developers Guide

→ The optimizer manipulates approximated output parameter values.

→ The number of input parameters is limited by the ability to generate the response surface. However,the cost is extremely low because the resources needed to evaluate the response surface are negligible.The optimization is performed as a post-processing operation based on the response surface, so severalalternative optimization studies can be performed very quickly on the same surface.

The DX Extension

External DOEs and optimizers can be packaged and installed as Workbench extensions. When the ex-tension is installed and loaded, DX detects the external DOEs or optimizers and exposes them as addi-tional options in the DesignXplorer component. If the user selects one of these custom methods, DXdelegates to the selected external option; it delegates sampling resolution to the external samplingand optimization resolution to the external optimizer. Note that when an external option is used, theWorkbench session is journaled and can be replayed as usual.

The extension is a container for one or more DOEs or optimizers. The DOEs and optimizers themselvesare generally provided as compiled libraries included in the .wbex extension file.

Implementing a DX Extension

A DX extension is comprised of three main parts:

• XML file that declares, defines and configures the extension

• Python scripts that implement callbacks

• ISamplingMethod or IOptimizationMethod implementation, which is the adapter to your existingimplementation. This is typically achieved in C# or IronPython.

This section describes each of these pieces and includes references to several examples of functionalDX extensions.

Implementation Requirements

The implementation of a DX extension requires:

• ANSYS Workbench installation

• ANSYS Customization Suite license

• IronPython, which is provided as part of ANSYS Workbench in the directory <installdir>\common-files\IronPython

• Microsoft Visual Studio 2010 SP1 for C# implementation

• Microsoft Visual Studio 2010 SP1 or equivalent for C/C++ implementation

DX Extension Definition and Configuration

As with any other type of extension, a DX extension is defined and configured by an XML file thatidentifies the extension (version, name, author, description) and provides the following main entrypoints:

75Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS DesignXplorer

Page 84: ANSYS ACT Developers Guide

• Filename of the main Python script (as specified by the <script> element)

• Name of the Python function to invoke when initializing the extension (as specified by the OnInit callback)

In a DX extension, the OnInit callback is the correct place to load the DLL containing the externalsampling. Another callback named OnTerminate is invoked when the extension is unloaded and isthe correct place to perform cleanup operations and unload the DLL.

The specificity of a DX extension is to define external sampling or optimization methods to be used byDX. The definitions are encapsulated in a <simdata> element, where the context attribute is set toDesignXplorer. The main elements used to declare and define the DOEs are shown in Figure 45: De-claration and Definition of an External DOE (p. 76). The main elements used to declare and define theoptimizers are shown in Figure 46: Declaration and Definition of an External Optimizer (p. 77).

Figure 45: Declaration and Definition of an External DOE

In Figure 45: Declaration and Definition of an External DOE (p. 76), the DOE defined is called FullFactorial.The two attributes framed in red are examples of capabilities being defined for this DOE. Here we cansee that for FullFactorial:

• The LogFile attribute is set to true, so the sampling has the capability to use the DX API to generate alog file in the Workbench project.

• The CustomTable attribute is set to false, so the DOE does not have the capability to handle the customtable available in DX.

• All other capabilities are configured per the default values. For a listing of capabilities, see DX ExtensionCapabilities (p. 78).

The callbacks to hook up with DX are framed in blue. Note that the OnCreate callback, which is invokedto obtain an ISamplingMethod instance, is mandatory. All other callbacks are optional.

Finally, all of the properties declared for the DOE in Figure 45: Declaration and Definition of an ExternalDOE (p. 76) are framed in orange. These properties allow the user to control specific settings of the

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.76

Extension Capabilities

Page 85: ANSYS ACT Developers Guide

algorithm, access relevant output information (e.g. number of levels or status), or whatever else theDOE needs to expose as a result of the sampling run.

Figure 46: Declaration and Definition of an External Optimizer

In Figure 46: Declaration and Definition of an External Optimizer (p. 77), the extension is named MyOp-timizer and defines two different external optimizers. The declaration for each optimizer is marked witha green bracket. Each optimizer will be managed by DX as an independent optimization method.

In Figure 46: Declaration and Definition of an External Optimizer (p. 77), the first optimizer defined iscalled MyOptimizer. The two attributes framed in red are examples of capabilities being defined forthis optimizer. Here we can see that for MyOptimizer:

• The SeekObjective attribute is set to false, so the optimizer does not have the capability to handlethe Seek Target objective available in DX.

• The LogFile attribute is set to true, so the optimizer has the capability to use the DX API to generate alog file in the Workbench project.

• All other capabilities are configured per the default values. For a listing of capabilities, see OptimizationExample (p. 78).

77Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS DesignXplorer

Page 86: ANSYS ACT Developers Guide

The callbacks to hook up with DX are framed in blue. Note that the OnCreate callback, which is invokedto obtain an IOptimizationMethod instance, is mandatory. All other callbacks are optional.

Finally, all of the properties declared for the optimizer in Figure 46: Declaration and Definition of anExternal Optimizer (p. 77) are framed in orange. These properties allow the user to control specificsettings of the algorithm, access relevant output information (e.g. number of iterations, final convergencemetrics, status), or whatever else the optimizer needs to expose as a result of the optimization run.

DX Extension Capabilities

A DX extension is designed to solve a specific range of problems, and its implementation is characterizedby complementary features and limitations. To allow DX to determine when a given sampling or optim-ization method is applicable, depending on the current DOE or optimizer definition, it is necessary todeclare the main capabilities of each external method. There are also optional capabilities used by DXto adjust the user interface according to what complementary features are supported by the externalmethod.

For external DOEs, the capabilities are specified in the XML file as attributes of the <sampling> element.For external optimizers, the capabilities are specified in the XML file as attributes of the <optimizer>element.

Main Capabilities

The main capabilities are used to determine if the external sampling or optimization method can beapplied to the problem as it is currently defined. If the external method has the required capabilities,it is available as a menu option in the DX Properties view (applicable external samplings are availablein the Design of Experiments Type menu, and applicable optimizers are available in the Method Namemenu). If an external method is not applicable, it is not listed as a menu option. Each modification tothe DOE or optimization study (e.g. modifying an existing input parameter, enabling or disabling aninput parameter, etc.) triggers an evaluation of the relevant capabilities to reassess whether the externalmethod is applicable and will be made available to the user.

DOE ExampleThe external sampling FullFactorial, defined previously in Figure 45: Declaration and Definition of an Ex-ternal DOE (p. 76), has MaximumNumberOfInputParameters capability equal to 10. As a consequence,as soon as the user defines more than 10 input parameters, FullFactorial is removed from the list ofavailable sampling methods. If the user then changes the DOE study so that the number of input parametersis less than or equal to 10, FullFactorial is immediately restored as an available option.

Note that if the user selects FullFactorial first and defines more than 10 input parameters afterward,the sampling method is retained. Given the incompatibility of the sampling method and the numberof input parameters, however, the state of the DOE will turn to Edit Required and a Quick Helpmessage will be provided to explain why the sampling cannot be launched as currently configured.

Optimization ExampleThe external optimizer MyFirstOptimizer, defined previously in Figure 46: Declaration and Definition ofan External Optimizer (p. 77), does not have the SeekObjective capability. As a consequence, as soonas the user defines a Seek Target objective, MyFirstOptimizer is removed from the list of available optim-ization methods. If the user then changes the optimization study so that the Seek Target objective is nolonger defined, MyFirstOptimizer is immediately restored as an available option.

Note that if the user selects MyFirstOptimizer first and defines the unsupported Seek Target ob-jective afterward, the optimization method is retained. Given the incompatibility of the optimizationmethod and the objective, however, the state of the Optimization will turn to Edit Required and

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.78

Extension Capabilities

Page 87: ANSYS ACT Developers Guide

a Quick Help message will be provided to explain why the optimization cannot be launched ascurrently configured.

The table below notes the main capabilities controlling the availability of external methods.

OptimizerDOE

MaximumNumberOfInputParametersMaximumNumberOfInputParameters

MaximumNumberOfDoubleParametersMaximumNumberOfDoubleParameters

MaximumNumberOfDoubleListParamet-ers

MaximumNumberOfDoubleListParamet-ers

MaximumNumberOfIntegerListPara-meters

MaximumNumberOfIntegerListPara-meters

ParameterRelationship

ObjectiveOnInputParameter

ConstraintOnInputParameter

MinimizeObjective

MaximizeObjective

SeekObjective

LessThanConstraint

GreaterThanConstraint

EqualToConstraint

InsideBoundsConstraint

MinimumNumberOfObjectives

MaximumNumberOfObjectives

MinimumNumberOfConstraints

MaximumNumberOfConstraints

BasedOnResponseSurfaceOnly

BasedOnDirectOptimizationOnly

For a comprehensive list of capabilities, see the "Sampling" and “Optimizer” sections in the ACT ReferenceGuide for DesignXplorer.

Optional Capabilities

The optional capabilities are used to enable or disable specific options or features of DX according tothe level of support provided by the selected external method. After the main capabilities have estab-

79Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS DesignXplorer

Page 88: ANSYS ACT Developers Guide

lished that a method is applicable to a given DOE or optimization study, the optional capabilities de-termine which features will be exposed for that method in the DX user interface.

For example, the LogFile capability is declared for the sampling defined in Figure 45: Declaration andDefinition of an External DOE (p. 76), FullFactorial, and also for the optimizer defined in Figure 46: De-claration and Definition of an External Optimizer (p. 77), MyFirstOptimizer. As a result, the correspondingfeatures to manage and expose the log file are enabled in DX and exposed in the user interface. If thiscapability was not declared or was set to false, DX would adjust its user interface to hide the accessto the log file because it is not supported by this external method.

As additional examples:

• If the selected sampling does not support the Custom Table capability, the Custom Table is not availablein the user interface.

• If the selected optimizer does not support the Maximize objective type, then the objective types availablein the user interface are limited to Minimize and Seek Target.

• If the optimizer does not support importance levels on objectives, the Objective Importance property isnot available in the Property view of the optimization criterion.

For a comprehensive list of capabilities, see the "Sampling" and “Optimizer” sections in the ACT ReferenceGuide for DesignXplorer.

Notes on Method Class Implementation

An implementation of the main interface method class (ISamplingMethod for DOE and IOptimiz-ationMethod for optimization) is mandatory in order for a DX extension to be valid. This methodclass is the core of the extension; it is the object that is delegated the responsibility to generate thesampling or solve the optimization study.

If you start a completely new implementation of the sampling or optimization algorithm, you mightconsider writing a C# class that derives directly from the method class, as provided by the PublicAPIsassembly.

If you start from an existing code, either in C/C++ or FORTRAN code, you should consider implementingyour method class in IronPython as an adapter to your algorithm implementation, wrapping your existingclasses and/or routines.

Both approaches are illustrated by the extension examples listed in DesignXplorer Extension Ex-amples (p. 222).

For full reference documentation of the API, see the “API Description” section in the ACT ReferenceGuide for DesignXplorer.

Notes on Monitoring

Notes on Sampling Monitoring

DX provides user interface elements that allow the user to monitor the progress of a sampling, in additionto the progress and log messages.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.80

Extension Capabilities

Page 89: ANSYS ACT Developers Guide

Notes on Optimization Monitoring

DX provides user interface elements that allow the user to monitor the progress of an optimization. Inaddition to the progress and log messages, the API allows the external optimizer to optionally provideDX with progress data such as history and convergence values.

The history values are values of the input and output variables and show how the optimizer exploresthe parametric space. In the user interface, history values are rendered graphically, as a 2D chart perobjective and/or input parameter, where the X axis represents points or iterations and the Y axis repres-ents the parameter values. For more information, see “Using the History Chart” in the DesignXplorerUser’s Guide.

The X axis can be configured in the XML file to represent points or iterations with the HistoryChartX-AxisType attribute of the optimizer element (byPoint or byIteration).

To provide history values during the execution of IOptimizationMethod.Run(), the optimizationmethod can call IOptimizationServices.PushHistoryPoint(IOptimizationPointpoint) where point contains a value for some or all enabled input and output variables.

The convergence values are independent from the variables. They are the values of one or more con-vergence metrics, specific to your optimizer and showing its convergence during the process. In theuser interface, convergence values are rendered graphically, as a 2D chart with one or several curves.For more information, see “Using the Convergence Criteria Chart” in the DesignXplorer User’s Guide.

To provide convergence values during the execution of IOptimizationMethod.Run(), the optim-ization method can call IOptimizationServices.PushConvergenceData (IConvergen-ceData data)where data contains the values for one or several convergence criteria.

Notes on Results

Notes on Sampling Results

The DOE post-processing is similar for all DOE methods. It is based on results data rendered graphicallyand/or as tables in the user interface.

Once the DOE is generated, DX extracts all results provided by the sampling in order to generate post-processing tables and charts:

• Sample points from the ISamplingMethod.Samples property

Notes on Optimization Results

The optimization post-processing is similar for all optimization methods. It is based on results datarendered graphically and/or as tables in the user interface.

Once the optimization study is solved, DX checks IOptimizationMethod.PostProcessingTypesand extracts all results provided by the optimizer in order to generate post-processing tables and charts:

• Candidate points from the IOptimizationMethod.Candidates property

• Sample points from the IOptimizationMethod.Samples property

• Pareto fronts from the IOptimizationMethod.ParetoFrontIndex property

81Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS DesignXplorer

Page 90: ANSYS ACT Developers Guide

In some cases, DX builds missing results if one of these result types is not supported. For example, ifthe optimization method provides the sample points without the candidate points, DX applies its ownsorting logic to generate the candidate points based on objectives and constraints definitions. If theoptimizer provides the sample points without the Pareto fronts indices, DX builds missing data basedon objectives and constraints definitions.

Capabilities for Custom ACT Workflows in Workbench

With ACT, you can take your custom, lightweight, external applications and processes and integratethem into the ANSYS Workbench workflow. Features exposed by ACT also enable you to performautomation and customization activities, such as creating new systems to facilitate interaction with theWorkbench Project Schematic. The ACT API delivers, in an improved and streamlined offering, function-ality previously available only through the External Connection add-in. You can use ACT to create customtaskgroups and custom tasks.

You can use ACT to create custom taskgroups and custom tasks.

• Taskgroups contain tasks; in Workbench, task groups are exposed as custom systems.

• Tasks are contained in taskgroups; in Workbench, tasks are exposed as custom components.

Once defined and added to the Workbench Toolbox, an ACT-defined taskgroup can be added to theProject Schematic workflow in the same way as an installed system.

Note

At present, the mixing of ACT-defined and installed tasks and taskgroups is not supported;ACT-defined tasks cannot be added to installed taskgroups, and installed tasks cannot beadded to ACT-defined taskgroups.

The figure that follows shows a Workbench Mesh Transfer taskgroup that takes an upstream mesh andpasses it to a downstream Fluent taskgroup. For details, see the Mesh Transfer (p. 234) example.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.82

Extension Capabilities

Page 91: ANSYS ACT Developers Guide

Figure 47: End-to-End Mesh Transfer Between Mesh, Mesher, and Fluent Setup

This section discusses how to create the various files required to define custom ACT workflows inWorkbench, exposing custom taskgroups and tasks as systems and components on the ProjectSchematic.

The following topics are addressed:The Custom Workflow Creation ProcessCreating the Extension Definition XML FileCreating the IronPython Script

The Custom Workflow Creation Process

As with any other type of extension, creating taskgroups and tasks to be exposed in a Workbenchworkflow involves the creation, installation, and loading of the custom workflow extension.

At minimum, you must create the XML extension definition file, the IronPython script, and any supportfiles (such as taskgroup and task images and custom application executables). Then you must installthe extension by placing these files in one of the specified directories:

• %AWP_ROOT162%\Addins\AdvancedAddinPackage\extensions

• %APPDATA%\Ansys\v162\AdvancedAddinPackage\extensions

• Any of the include directories defined in the Additional Extension Folders field on the Extensions pageof the Options dialog.

The IronPython script and support files should be placed in the extension directory, which is at thesame level as the XML file.

83Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for Custom ACT Workflows in Workbench

Page 92: ANSYS ACT Developers Guide

Once you’ve installed your extension, you can load it into Workbench via the Extensions Manager.Upon loading your extensions, the custom taskgroup(s) will be exposed as systems in a new WorkbenchToolbar group, as shown below:

Figure 48: Custom Taskgroups in the Workbench Toolbox

These custom taskgroups can be added to the Project Schematic. When you invoke an Update on acustom task within the taskgroup, the add-in may:

1. Obtain the inputs.

2. Prepare the inputs.

3. Write input file(s).

4. Run the external solver or performs calculations.

5. Read output file(s).

6. Set the parameters or properties to the calculated values.

Creating the Extension Definition XML File

The extension definition XML file contains information to define a workflow within Workbench, includingtaskgroups designed for a particular simulation objective. All analyses performed within Workbenchbegin by referencing a taskgroup (system). This XML file describes the taskgroups, and declares thecontained tasks.

At the extension level, the XML file must specify, at minimum:

• Extension name

• Interface context (must be Project)

• Interface <images> tag (needed to specify taskgroup or task icons)

• Workflow block

At the workflow level, the XML file can specify:

• Workflow context (required; must be Project)

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.84

Extension Capabilities

Page 93: ANSYS ACT Developers Guide

• Tasks (container for individual task definitions)

• Taskgroups (container for taskgroup definitions)

At the task level, the XML file can specify:

• Task name (required)

• Task version (required)

• Callbacks

• Context menus

• Inputs and outputs

• Property groups and properties

• Parameters

• Display text

• Image name

At the taskgroup level, XML file can specify:

• Taskgroup name (required)

• Taskgroup version (required)

• Image name

• Abbreviation

The following is an example of the basic structure of an XML extension definition file:

<extension version="1" name=""> <guid shortid="">69d0095b-e138-4841-a13a-de12238c83f3</guid> <script src="" /> <interface context="Project"> <images>images</images> </interface> <workflow context=”Project”> <tasks> <task name="" caption="" icon="" version="1"> <callbacks> <onupdate></onupdate> <onrefresh></onrefresh> <oninitialize></oninitialize> <onedit></onedit> <onreset></onreset> <onstatus></onstatus> <onreport></onreport> </callbacks> <contextmenus> <entry name=”” caption=”” icon=”” version=”1” priority=”” type=””> <callbacks> <onclick></onclick> </callbacks> </entry> </contextmenus> <propertygroup name=”” caption=””> <property name="" caption="" control="" default="" readonly="" needupdate=””

85Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for Custom ACT Workflows in Workbench

Page 94: ANSYS ACT Developers Guide

visible="" persistent="" parameterizable="" keytype="" valuetype="" elementtype=""/> </propertygroup> <property name="" caption="" control="" default="" readonly="" needupdate=”” visible="" persistent="" parameterizable="" keytype="" valuetype="" elementtype=""/> <parameters> <parameter name=”” caption=”” usage=”” control=”” version=”1”/> </parameters> <inputs> <input/> <input type="" format=""/> </inputs> <outputs> <output type="" format=""/> </outputs> </task> </tasks> <taskgroups> <taskgroup name="" caption="" icon="" category="" abbreviation="" version="1" isparametricgroup=”False”> <includetask name=””/> <includeGroup name=””/> </taskgroup> </taskgroups> </workflow></extension>

Defining a Task

One or more tasks can be defined in the <tasks> node. Individual tasks are defined in a <task> childnode.

In each task definition, you must include the name and version attributes. Child nodes are can beused to specify callbacks, inputs and outputs, properties, parameters, and context menus.

The basic structure of a task definition is shown below:

<tasks> <task name="" caption="" icon="" version="1"> <callbacks> <onupdate></onupdate> <onrefresh></onrefresh> <oninitialize></oninitialize> <onedit></onedit> <onreset></onreset> <onstatus></onstatus> <onreport></onreport> </callbacks> <contextmenus> <entry name=”” caption=”” icon=”” version=”1” priority=”” type=””> <callbacks> <onclick></onclick> </callbacks> </entry> </contextmenus> <propertygroup name=”” caption=””> <property name="" caption="" control="" default="" readonly="" needupdate=”” visible="" persistent="" parameterizable="" keytype="" valuetype="" elementtype=""/> </propertygroup> <property name="" caption="" control="" default="" readonly="" needupdate=”” visible="" persistent="" parameterizable="" keytype="" valuetype="" elementtype=""/> <parameters> <parameter name=”” caption=”” usage=”” control=”” version=”1”/> </parameters> <inputs> <input/> <input type="" format=""/> </inputs> <outputs>

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.86

Extension Capabilities

Page 95: ANSYS ACT Developers Guide

<output type="" format=""/> </outputs> </task> </tasks>

CallbacksCallbacks to IronPython functions are specified in the <callbacks> node. The following callbacks areavailable:<onrefresh>,<oninitialize>,<onupdate>,<onedit>,<onreset>,<onstatus>,and <onreport>.

Definition of the <onedit> callback automatically creates a default Edit context menu for the task.

Context MenusIf you specify the <onedit> callback in your extension definition file, a default Edit context menu optionis automatically created for the task. However, it is possible to define additional GUI operations for eachtask.

Custom GUI operations are specified in the optional <contextmenus> node. At minimum, thecontext menu entry definition must include the name and version attributes. When the optionaltype attribute is defined, it must be set to ContextMenuEntry.

Each entry in the <contextmenus> node must have an <onclick> callback.

The basic structure of the <contextmenus> node is shown below:

<contextmenus> <entry name=”” caption=”” icon=”” version=”1” priority=”” type=””> <callbacks> <onclick></onclick> </callbacks> </entry> </contextmenus>

Inputs and OutputsIn a Workbench workflow, the Project Schematic connections serve as visual representations of data flowbetween tasks. These connections depend on input and output coordination. Workbench can establishconnections only if an upstream (providing) task exposes outputs whose types also match the inputs fora downstream (consuming) task.

Inputs and outputs are defined in the <input> and <output> nodes.

At a minimum, a task must always define an empty input (<input>).

You can use the type attribute to specify the data type expected by the connection.

Certain Workbench types require the use of both the type and format attributes. For example,a Mesh task that consumes a mesh and then passes a mesh to another taskgroup would use theseattributes to specify the mesh type and file format of the input and output files.

This example defines the inputs and outputs for a task within a Fluent meshing workflow. Themeshing-based type values and FluentMesh format values instruct an upstream mesh task tooutput the Fluent mesh file format (.msh).

<task name="Mesher" caption="Mesher" icon="GenericMesh_cell" version="1"> <callbacks> <onupdate>update</onupdate> <onedit>edit</onedit> </callbacks> <inputs> <input format="FluentMesh" type="MeshingMesh" count="1"/>

87Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for Custom ACT Workflows in Workbench

Page 96: ANSYS ACT Developers Guide

<input/> </inputs> <outputs> <output format="FluentMesh" type="SimulationGeneratedMesh"/> </outputs> </task>

For a list of supported transfer types and their corresponding transfer properties, see Ap-pendix B (p. 317).

Property Groups and PropertiesInstead of using parameters to drive your simulation, you can work through the data model, simplifyingdata access by defining custom properties.

Properties can be defined in the optional <propertygroup> node. At minimum, each propertygroup definition must include the name attribute. The caption attribute will be used as the groupcategory name in the Workbench Property view if the child properties are visible.

Individual properties can be defined in the <property> node, which can be either a child to<propertygroup> or a stand-alone definition at the same level. At minimum, each propertydefinition must include the name and control attributes.

The basic structure of a property definition is shown below:

<propertygroup name=”” caption=””> <property name="" caption="" control="" default="" readonly="" needupdate=”” visible="" persistent="" parameterizable="" keytype="" valuetype="" elementtype=""/> </propertygroup> <property name="" caption="" control="" default="" readonly="" needupdate=”” visible="" persistent="" parameterizable="" keytype="" valuetype="" elementtype=""/>

Properties are linked to entity definitions in the referenced IronPython script, which makes use ofthe following commands:

• GetCustomEntity: Gets the property-containing entity.

• GetCustomEntityPropertyValue: Gets the property. This query obtains the entity property valuefor a custom property defined on the task.

• SetCustomPropertyValue: Sets the property. This command sets the entity property value for acustom property defined on the task.

ParametersYou can integrate an external application with the Project Schematic by defining parameters that arecreated dynamically at initialization.

Parameters are defined in the optional <parameters> node. At minimum, each parameter defin-ition must include the following attributes: name, usage, control, and version.

The basic structure of a parameter definition is shown below:

<parameters> <parameter name=”” caption=”” usage=”” control=”” version=”1”/> </parameters>

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.88

Extension Capabilities

Page 97: ANSYS ACT Developers Guide

Defining a Taskgroup

The sole purpose of a taskgroup is to collect tasks. One or more taskgroups can be defined in the<taskgroups> node. Individual taskgroups are defined in a <taskgroup> child node.

At minimum, each taskgroup definition must include the taskgroup name and version attributes. The<includetask> and <includeGroup> child nodes are to specify one or more tasks or nestedtaskgroups to be included.

If you define a caption, it overrides the task-level caption. Otherwise, the taskgroup-level caption isused.

The basic structure of a taskgroup definition is shown below:

<taskgroups> <taskgroup name="" caption="" icon="" category="" abbreviation="" version="1" isparametricgroup=”False”> <includetask name=””/> <includeGroup name=””/> </taskgroup> </taskgroups>

Note

At present, the mixing of ACT-defined and installed tasks and taskgroups is not supported;ACT-defined tasks cannot be added to installed taskgroups, and installed tasks cannot beadded to ACT-defined taskgroups. Also, nested taskgroups within a taskgroup are not recog-nized by Workbench at 16.2.

Creating the IronPython Script

The IronPython script defines the actions to be executed during a callback invocation. Python scriptsexecute within the Workbench Python interpreter; as a result, scripts have full access to the scriptableWorkbench API (Using Journals and Scripts in the Workbench User's Guide).

For example, the script is used to create update instructions for producing and consuming data. If anytask produces or consumes data, you must supply an Update routine that processes input and outputtypes as declared by the workflow definition. For a table of supported task inputs and outputs, see theAppendix A (p. 265).

Upstream Data Consumption (Input)

Typically, tasks need to implement complex source handling logic, connection tracking routines, and arefresh procedure in order to consume data. ACT abstracts these complexities by automatically performingthese actions during refresh. It obtains upstream data and stores it in a dictionary accessible by theuser during the task Update. The task can obtain this data by calling Convenience APIs (p. 90).

Data Generation (Output)

Tasks that produce output data (for example, declare output types in the taskgroup definition file) mustensure that their custom Update routine assigns output data.

The extension definition XML file prepares empty data objects representing task outputs; the user mustonly set the correct transfer properties that downstream consumers will interrogate. Refer to Ap-pendix B (p. 317) to determine which properties you must set.

89Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for Custom ACT Workflows in Workbench

Page 98: ANSYS ACT Developers Guide

For example, a material transfer to a downstream Engineering Data task must set the DataReferenceTransferFile property on a MatML31 data object to the file reference of a registered matml-formatted XML file, all completed during the Update routine.

Convenience APIs

Convenience APIs are IronPython queries that provide simple access to task-stored input and outputdata. The available convenience APIs are:

GetInputDataByTypeReturns a List<object> containing upstream data for a given type. For example:

upstreamData = container.GetInputDataByType(InputType="MeshingMesh")meshFileRef = NoneupstreamDataCount = upstreamData.Countif upstreamDataCount > 0: meshFileRef = upstreamData[0]

GetOutputDataReturns a Dictionary<string, List<DataReference>> holding the task's output types. Forexample:

outputRefs = container.GetOutputData()meshOutputSet = outputRefs["SimulationGeneratedMesh"]meshOutput = meshOutputSet[0]meshOutput.TransferFile = meshFileRef

GetCustomEntityObtains the custom data entity from a container based on the entity's name and type. If the name andtype are not specified, the default ACT object is returned. This object contains the properties defined bythe workflow task from the <propertygroup> and <property> blocks.

entity = ACT.GetCustomEntity(container)

GetCustomEntityPropertyValueThis query returns the value of a property defined on a custom data entity.

inputValue = ACT.GetCustomEntityPropertyValue(entity, "Input")

SetCustomEntityPropertyValueThis command handles the setting of a custom entity's property value.

ACT.SetCustomEntityPropertyValue(entity, "Output", outputValue)

Capabilities for ANSYS AIM

This section discusses customization of the ANSYS AIM application. By using ACT in ANSYS AIM, youcan add a custom load for a structural analysis (similar to the functionality available in ANSYS Mechan-ical) and create a full fluidic system encapsulating all available boundary conditions.

Adding a Pre-Processing Feature in ANSYS AIM Structural

This section discusses customization of the ANSYS AIM application for the native exposure of a pre-processing feature--specifically, how to add a custom load to a structural analysis. The example usedin the discussion is defined in the CustomPressure extension, which was written to create a custompressure as a load. This example is for demonstration purposes only.

We will address the extensions's XML and Python file separately.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.90

Extension Capabilities

Page 99: ANSYS ACT Developers Guide

Custom Load Definition in the XML File

Below are the contents of the CustomPressure.xml file, which adds the custom pressure load toour project.

<extension version="1" name="CustomPressure"> <guid shortid="CustomPressure">314bd00a-2f64-4b62-8196-bab9206c2c6b</guid> <script src="main.py" />

<simdata context="Study"> <load name="CustomPressure" version="1" caption="CustomPressure" icon="tload" issupport="false" isload="true" color="#0000FF" >

<callbacks> <getsolvecommands order="1">writeNodeId</getsolvecommands> </callbacks>

<property name="Geometry" caption="Geometry" control="scoping"> <attributes selection_filter="face" /> </property> <property name="Expression" caption="Expression" datatype="double" control="float" unit="Pressure" isparameter="true"></property>

</load> </simdata></extension>

As in previous examples, the XML file first defines the extension using a version and name attribute.The path to the Python script file main.py is specified by the <script> tag.

The definition of the load is encapsulated by the <simdata> begin and end tags. The context attributefor <simdata> has been set to Study , which makes the extension compatible with AIM. The attributesin the <load> begin tag provide the name, version, caption, icon, support status, and color that applyto this load. The color attribute is defined in a hexadecimal format. This color is used to contrast theload when it is displayed on the model. The <callbacks> tag encapsulates the callback <getsolve-commands>. This tag specifies the name of the Python function that is called when the solver inputfile is generated by the application. Consequently, the related Python function is responsible for gener-ating the commands that describe the load within the ANSYS input file.

Below the callbacks definition, you can define the properties that will be applied to the actual definitionof the load. These properties are displayed in the specific ACT object created by the extension, wherethe user provides the necessary values to complete the load definition.

Note that neither property requires the definition of a callback.

• The first property,Geometry, uses a scoping control type, and has the selection_filter attributeset to face. This property allows you to select the face of the geometry to which the custom pressure willbe applied.

• The second property,Expression, uses a float control type, which provides the property with accessto AIM expressions functionality. Consequently, you can enter an expression into the Expression propertyfield and expect a float. Setting datatype to double introduces a physical quantity dependency with theunit option, which is set to Pressure; this combination specifies that this property is consistent with apressure. Finally, setting isparameter to true specifies that this expression can be parameterized.

Custom Load Definition in the Python File

Here is the Python script file main.py used for the CustomPressure extension.

91Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS AIM

Page 100: ANSYS ACT Developers Guide

def writeNodeId(load, stream): ExtAPI.Log.WriteMessage("writeNodeId...") stream.WriteLine("/com, GetSolveCommands")

property_expression = load.PropertyByName("Expression") expression = property_expression.Value ExtAPI.Log.WriteMessage(expression.ToString()) if expression=="": return None

property_geometry = load.PropertyByName("Geometry") refIds = property_geometry.Value.Ids ExtAPI.Log.WriteMessage(refIds.ToString()) mesh = ExtAPI.DataModel.MeshDataByName("Mesh 1") for refId in refIds: meshRegion = mesh.MeshRegionById(refId) ExtAPI.Log.WriteMessage(meshRegion.ToString()) nodeIds = meshRegion.NodeIds for nodeId in nodeIds: node = mesh.NodeById(nodeId)

stream.WriteLine("F,"+nodeId.ToString()+", FX,"+expression.ToString()+"\n")

The main.py Python file defines the writeNodeId function, which writes the value of the Expressionproperty on the geometry nodes scoped for the load.

The following figure shows that the CustomPressure ACT load we’ve created is now made availableto be added as a boundary condition in AIM.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.92

Extension Capabilities

Page 101: ANSYS ACT Developers Guide

Figure 49: CustomPressure Load Available as a Boundary Condition in AIM

The following figure shows the status of the load once all the properties are defined.

Figure 50: CustomPressure Load with Properties Defined

93Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS AIM

Page 102: ANSYS ACT Developers Guide

Creating a Custom Object to Merge Existing AFD Features (Process Compres-sion)

By using ACT extensions in AIM, you have the ability to create a complete fluidic system encapsulatingexisting boundary conditions. This section discusses the customization of the ANSYS AIM applicationto expose a fluids system with access to all available boundary conditions.

You can have one load per boundary condition, and have access to all fluid boundary conditions (i.e.inlet, outlet, wall, etc.). The boundary conditions will appear as scoping properties. In some instances,you can also add an inlet velocity and an outlet pressure to standard boundary conditions.

Fluids extensions developed in AIM are very similar in construction to other extensions developed inAIM or Workbench. As with other extensions, each AFD extension developed in AIM will have an XMLfile and an IronPython script.

• The XML file will have both a section containing an element to define buttons and toolbars, and a sectioncontaining callbacks and properties to define the load.

• The Python script will define functions invoked by the events and callbacks in the XML file to implementthe behavior of the extension.

As an example, we will use an extension called AFDLoad . This example is for demonstration purposesonly. We will address the extensions's XML and Python file separately.

Fluidic System Definition in the XML File

Below are the contents of the AFDLoad.xml file, which is used to create a fluidic system with full accessto available boundary conditions.

<extension version="1" name="AFDLoad">

<script src="main.py" />

<interface context="Study">

<images>images</images>

</interface>

<simdata context="Study">

<load name="InOut" version="1" caption="InOut" icon="support" issupport="true" color="#0000FF">

<callbacks> <getsolvecommands>getcmds</getsolvecommands> </callbacks>

<property name="Inlet" caption="Inlet" control="scoping" /> <property name="Outlet" caption="Outlet" control="scoping" /> <property name="InletVelocity" caption="Inlet Velocity" control="float" unit="Velocity" default="1 [m s^-1]"/> <property name="OutletPressure" caption="Outlet Pressure" control="float" unit="Pressure" default="0 [Pa]"/>

</load>

</simdata>

</extension>

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.94

Extension Capabilities

Page 103: ANSYS ACT Developers Guide

The XML file has the standard ACT construction, with the version and name attributes defining theextension, the <script> tag specifying Python main.py script file, and the interface tag definingthe context as Study.

As in the AIM preprocessing example, the definition of the load is encapsulated by the <simdata>begin and end tags, the <simdata> context attribute has been set to Study, and the attributes inthe <load> begin tag provide the name, version, caption, icon, support status, and color that applyto the load that will contain the boundary condition. (In this example, our load name and caption areboth InOut.) As before, the <callbacks> tag encapsulates the callback <getsolvecommands>,which creates the boundary conditions for the load.

Below the callbacks section, the load properties to be used for the boundary conditions are defined:Inlet, Outlet, Inlet Velocity, Velocity, Outlet Pressure, and Pressure. The controltype,unit, and default tags function as described in previous examples. These properties are dis-played in the specific ACT object created by the where the user provides the necessary values to completethe load definition.

Fluidic System Definition in the IronPython File

Here is the Python script file main.py used for the AFDLoad extension.

Note

In future releases, the IronPython commands used to define fluid dynamics featuresmay be modified to ensure consistency with AIM Journaling and Scripting functionality.For the information on whether a given command has been modified or deprecated,refer to the ACT Reference Guide.

import clrclr.AddReference("Ansys.Study.Proxies.Customization")from Ansys.Study.Proxies.Customization.Analysis import AFDObject

def getcmds(load,stream):

velocity = load.Properties["InletVelocity"] pressure = load.Properties["OutletPressure"]

faces = [] faces += load.Properties["Inlet"].Value.Ids faces += load.Properties["Outlet"].Value.Ids geo = load.Analysis.GeoData wallFaces = [] for part in geo.Assemblies[0].Parts: for body in part.Bodies: for face in body.Faces: if not faces.Contains(face.Id) and not wallFaces.Contains(face.Id): wallFaces.Add(face.Id)

boundary = AFDObject.CreateBoundary() boundary.SetProperty("BoundaryType","Inlet") boundary.SetProperty("Location",load.Properties["Inlet"].Value.Ids) boundary.SetProperty("Flow.Option","Velocity") boundary.SetProperty("Flow.Velocity.Magnitude",velocity.Value.ToString()+' ['+velocity.UnitString+']') boundary.Send(stream) boundary = AFDObject.CreateBoundary() boundary.SetProperty("BoundaryType","Outlet") boundary.SetProperty("Location",load.Properties["Outlet"].Value.Ids) boundary.SetProperty("Flow.Option","Pressure") boundary.SetProperty("Flow.Pressure.GaugeStaticPressure",pressure.Value.ToString()+' ['+pressure.UnitString+']')

95Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS AIM

Page 104: ANSYS ACT Developers Guide

boundary.Send(stream) boundary = AFDObject.CreateBoundary() boundary.SetProperty("BoundaryType","Wall") boundary.SetProperty("Location",wallFaces) boundary.Send(stream)

The function getcmds is defined in the main.py Python file for the AFDLoad extension. This functionwrites commands to the solver input file. The required input arguments are load and stream, whereload is the load object and stream refers to the solver input file. In our example, the functiongetcmds is referenced in the AFDLoad.xml file by the <getsolvecommands> callback. Whencalled, it creates the boundaries for the AFD object, defines boundary properties, and specifies theface(s) to which the boundary will be applied. Within this function:

• The CreateBoundary() method is applied to AFDObject to create a boundary. (This AFD object wasimported by the import command at the top of the Python file.)

boundary = AFDObject.CreateBoundary()

• In the faces section, we can specify:

– The faces to be used in the inlet and outlet properties).

– The faces belonging to the wall (i.e. all the faces not already used for the inlet and outlet properties).

• With boundary.SetProperty, we specify the boundary type (such as inlet, outlet, wall, etc.). It can alsobe applied to the boundary object to add a property. As part of the argument, you must specify both thetype of property to be added and the value to be assigned to it.

For example, the code segment below specifies the creation of an inlet boundary.

boundary.SetProperty("BoundaryType","Inlet")

• With boundary.SetProperty, we can also specify the location (faces, bodies, etc.) to which theboundary will be applied. To do so, we can use the scoping properties previously defined in the extension.The location property expects a list of identifiers.

boundary.SetProperty("Location",load.Properties["Inlet"].Value.Ids)

• To the property that just created, we can add an option representing a velocity (for an inlet) or a pressure(for an outlet).

boundary.SetProperty("Flow.Option","Velocity")

• To the option just added, we add a float value. (This float value could come from a property defined in theXML file.) We also have the ability to specify a unit.

boundary.SetProperty("Flow.Velocity.Magnitude",velocity.Value.ToString()+' ['+velocity.UnitString+']')

• Finally, we write the command generated by creation of the boundary.

boundary.Send(stream)

The following figure shows that the InOut ACT load we’ve created is now made available to be addedas a fluids boundary condition in AIM. This load includes all the properties defined in the extension.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.96

Extension Capabilities

Page 105: ANSYS ACT Developers Guide

Figure 51: InOut Load Available as a Fluids Boundary Condition in AIM

The following figure shows the status of the load once all the properties are defined.

Figure 52: InOut Load with Properties Defined

97Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Capabilities for ANSYS AIM

Page 106: ANSYS ACT Developers Guide

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.98

Page 107: ANSYS ACT Developers Guide

Custom Guided Processes

ANSYS ACT allows you to automate the simulation process with the creation of custom guided processes.A guided process developed with ACT is part of a specific extension; in addition to accessing the func-tionality defined in that extension, it can also leverage the API scripting capabilities available with AIMand Workbench-based ANSYS products.

A guided process is exposed in Workbench or in a target application (at 16.2, DesignModeler or Mech-anical) as a “wizard.” A wizard walks non-expert end users step-by-step through a simulation.

A guided process is exposed in AIM as a ‘“custom template.” A custom template automatically sets upa simulation process by creating a workflow within AIM.

Both methods enable users to benefit from ANSYS simulation capabilities while minimizing interactionswith the standard application interface.

Types of Guided Processes

You can create ACT guided processes to be executed in either ANSYS Workbench or ANSYS AIM. Thefollowing types of guided processes are available:

Workbench Wizards

A Workbench wizard can be created to be executed on the Workbench Project tab or across a combin-ation of the Project tab and target applications such as Mechanical or DesignModeler.

Project WizardA Workbench Project wizard is executed in the ANSYS Workbench Project tab. It can incorporate any data-integrated application with Workbench journaling and scripting capabilities, such as ANSYS DesignXploreror ANSYS Fluent, into the simulation workflow.

Mixed WizardA mixed wizard is executed across the ANSYS Workbench Project tab and one or more supported targetapplications with Workbench journaling and scripting capabilities. A mixed process provides nativeworkflow guidance in both the Project tab and the target application.

Target Application Wizards

A target application guided process wizard is executed wholly in the specified ANSYS target application(at 16.2, Mechanical or DesignModeler). It utilizes the functionality provided by the target applicationand provides simulation guidance within the application’s workflow.

AIM Custom Templates

An AIM custom template is based on AIM journaling and scripting capabilities. It sets up a simulationproject by creating a workflow within ANSYS AIM, enabling you to define a custom data panel withcustom properties to drive your simulation.

99Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 108: ANSYS ACT Developers Guide

At present, guided processes in AIM are limited to a single step. Functionality for creating multi-stepguided processes is under development and will be available in future releases of ANSYS AIM.

Note

For examples of all the different types of guided processes, see Custom Guided Process Ex-amples (p. 240).

Creating Guided Processes

To create any type of guided process, you must have an ACT license. Although you can execute a guidedprocess without an ACT license, the creation of the guided process requires the specification of an ex-tension—the creation of which, in turn, requires an ACT license.

To start creating guided processes, you can download templates from the ANSYS ACT ApplicationStore on the ANSYS Customer Portal.

Parts of a Guided Process

ACT-based guided processes are include the following files:

• Required XML extension definition file and referenced IronPython script

These files are the same as required for a standard ACT extension and use the same XML and IronPy-thon syntax. In fact, to create a guided process, you can simply begin with an existing extension andmodify it. For details on syntax, see the ANSYS ACT Developer's Guide and the ANSYS ACT ReferenceGuide.

• Optional custom help files

HTML files containing text, images, charts, or other control types can be used to provide instructionsor details for the guided process.

The XML Extension Definition File

To create a guided process, you must define it in the XML extension definition file. The existing require-ments of a standard XML extension file apply. One or more guided processes can be added to the XMLextension file by integrating a <wizard> block for each guided process.

Within the <wizard> block, the definition of the guided process requires, at minimum:

Guided process attributes:

• name

• version

• context

Step definitions:

• Step attributes:

– name

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.100

Custom Guided Processes

Page 109: ANSYS ACT Developers Guide

– caption

– version

– context

• Callbacks

• Properties

Example: XML Extension File for a Project Wizard

To illustrate the definition of a guided process, we will use the XML extension file for a WorkbenchProject wizard. Within the extension WizardDemos, we will define the guided process Project Wizard.

Note

Syntax differences for other kinds guided processes (other wizard types or custom templates)will be noted.

Below is our XML extension file, WizardDemos.xml.

<extension version="2" minorversion="1" name="WizardDemos"> <guid>6D33EFFC-C521-4859-8273-BA320044B6B8</guid> <author>ANSYS Inc.</author> <description>Simple extension to test wizards in different contexts.</description>

<script src="main.py" />

<interface context="Project"> <images>images</images> </interface>

<wizard name="ProjectWizard" version="1" context="Project" icon="wizard_icon"> <description>Simple wizard for demonstration in the Workbench Project page.</description>

<step name="Geometry" caption="Geometry" version="1" context="Project" CustomContentFile="help/geometry.html"> <description>Create a geometry component.</description>

<callbacks> <onupdate>CreateGeometry</update> <onreset>DeleteGeometry</reset> </callbacks>

<propertygroup display="caption" name="definition" caption="Basic properties" > <property name="filename" caption="Geometry file name" control="fileopen" /> <property name="myint" caption="Integer value" control="integer" /> <property name="mytext" caption="Text value" control="text" /> <property name="myquantity" caption="Quantity value" control="float" unit="Pressure" /> <property name="myreadonly" caption="Readonly value" control="text" readonly="true" default="My value" /> <propertygroup display="property" name="myselect" caption="List of choice" control="select" default="Option1"> <attributes options="Option1,Option2" /> <property name="option1" caption="Option1 value" control="text" visibleon="Option1" /> <property name="option2first" caption="Option2 first value" control="float" unit="Pressure" visibleon="Option2" /> <property name="option2seond" caption="Option2 second value" control="float" unit="Length" visibleon="Option2" /> </propertygroup> </propertygroup>

</step>

101Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Creating Guided Processes

Page 110: ANSYS ACT Developers Guide

<step name="Mechanical" caption="Mechanical" enabled="true" version="1" context="Project" CustomContentFile="help/mechanical.html"> <description>Create a mechanical component.</description>

<callbacks> <onupdate>CreateMechanical</update> <onreset>DeleteMechanical</reset> </callbacks>

<property name="name" caption="System name" control="text" /> <propertytable name="table" caption="TabularData" display="worksheet" control="applycancel" class="Worksheet.PropertyGroupEditor.PGEditor"> <property name="Temperature" caption="Temperature" unit="Temperature" control="float"></property> <property name="Pressure" caption="Pressure" unit="Pressure" control="float"></property> </propertytable>

</step>

<step name="Fluent" caption="Fluent" version="1" context="Project" CustomContentFile="help/fluent.html"> <description>Create a fluent component.</description>

<callbacks> <onupdate>CreateFluent</update> </callbacks>

<property name="name" caption="System name" control="text" /> <property name="dialog" caption="Dialog" control="text"> <callbacks> <onvalidate>ValidateDialog</onvalidate> </callbacks> </property> <property name="dialog2" caption="DialogProgress" control="text"> <callbacks> <onvalidate>ValidateDialogProgress</onvalidate> </callbacks> </property>

</step>

<step name="ReportView" caption="ReportView" version="1" context="Project" layout="ReportView@WizardDemos"> <description>Simple example to demonstrate how report can be displayed.</description>

<callbacks> <onrefresh>RefreshReport</refresh> </callbacks>

</step>

<step name="CustomStep" caption="CustomStep" enabled="true" version="1" context="Project" layout="MyLayout@WizardDemos"> <description>Create a mechanical component.</description>

<callbacks> <onrefresh>RefreshMechanical</refresh> </callbacks>

<property name="name" caption="System name" control="text" />

</step>

</wizard>

</extension>

Extension definition:The standard extension definition is the same. The name, version, and IronPython script reference areunchanged. In our wizard example, the interface context is set to Project because the extension willbe run on the Workbench Project tab.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.102

Custom Guided Processes

Page 111: ANSYS ACT Developers Guide

Guided process definition:The required name,version, and context attributes are defined. In our wizard example, the contextis set to Project because the guided process will be executed from the Workbench Project tab.

The optional icon and description attributes are also defined. Icon files are stored in the imagesfolder in the extension directory.

Child nodes define the guided process steps.

Note

• For a mixed wizard, the <wizard> context would still be set to Project because theguided process will be launched from the Project tab. Each step in a mixed guided processwould have its context set to the application in which the step will be executed—eitherDesignModeler or Mechanical.

• For an AIM custom template, the <wizard> context is always set to Study. The namevalue is the name of the newly created system that appears under Simulation ProcessTemplates.

Step definitions:For each step, the required name,caption, and version attributes are defined. In our wizard example,note that the optional context is set to Project for all the steps; the steps involve creation of a geometryand two systems in the Project Schematic, so the steps are executed on the Workbench Project tab.

Note

For each step in a mixed guided process, the context would be set to the applicationin which the step will be executed—either DesignModeler or Mechanical.

Optional attributes are defined for various steps. For example, the HelpFile attribute indicatesthe file containing custom help content to be shown in the UI.

Child nodes define callbacks and properties.

Callback definitions:Callbacks execute an action that has been defined in the IronPython script for the guided process. Eachcallback receives the current step as a method argument.

• The required <onupdate> callback is invoked when you click the Next button for a Workbench wizard.In our wizard example, it executes the actions CreateGeometry,CreateMechanical, and Create-Fluent.

• The <onrefresh> callback is invoked when the next step is initialized. It initiates changes to the inter-face, so you can use this callback to change the appearance of the guided process, initialize a value tobe used in the current step, instantiate variables, access data of an existing project, etc. In our wizardexample, the <onrefresh> callback executes the RefreshReport and RefreshMechanicalactions.

103Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Creating Guided Processes

Page 112: ANSYS ACT Developers Guide

• The <onreset> callback resets the state of the step. In our example, it executes the DeleteGeometryand DeleteMechanical actions.

Note

For an AIM custom template, only the <onupdate>, <onrefresh>, and <onreset>callbacks are supported.

• The <onupdate> callback is invoked when you click the Create Simulation Processbutton. Typically, it is used to insert the content of an existing journal into the guidedprocess to create a workflow and establish boundary conditions, mesh, and solveroptions.

• The <onreset> callback is used to reset situations where the guided process has notbeen completed correctly; it allows you to go back to the process properties andmodify them.

Property definitions:Properties, property groups, and property visibility controls are defined with the same syntax as for astandard extension property.

The required name , caption , and control attributes are defined for all the properties. Thecontrol attribute specifies the control type for the property. The standard select, float, in-teger, scoping, text, and fileopen property types are supported. Advanced types such asapplycancel and custom are also supported.

Optional attributes are also defined for various properties.

• The unit attribute specifies the units for the property value.

• The readonly attribute specifies whether the property value is editable.

• The default attribute specifies the default property value.

• The visibleon attribute controls the visibility of the property. In our example, it is used tocontrol the display of conditional options in a property group.

The <propertygroup> node is used to create groupings of properties. In our example:

• For the first property group, no control is defined, so the group is a list of individual propertiesinside the <propertygroup> tags.

• The second property group is embedded within the first.

– In our example, the control attribute set to select , which provides a drop-down list.

– The attributes options tag defines the available options.

– The visibleon attribute defines the properties in the group are defined as conditional basedon selection from the drop-down.

• The <onvalidate> property callback is used to validate the value entered for a property.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.104

Custom Guided Processes

Page 113: ANSYS ACT Developers Guide

The <propertytable> node is used to create a table for the entry of property values in tabularformat. The Temperature and Pressure properties nested inside the <propertytable> tagscreate columns for data entry.

The IronPython Script

The IronPython script is referenced by the XML extension definition file. It defines the functions thatwill be used by the extension and also the actions that will be performed during each step of the guidedprocess.

ANSYS journaling and scripting commands can be used inside the callbacks. You can write the commandsmanually or edit commands obtained from a session journal file (either from the temporary journalstored in your %TEMP% folder or from a journal generated by using the Record Journal menu option).

Example: IronPython Script for a Project Wizard

To illustrate how the IronPython script is used in a guided process, we will continue with the exampleused in the previous section, the Workbench Project wizard called Project Wizard.

Note

Syntax differences for other kinds guided processes (other wizard types or custom templates)will be noted.

Below is the main.py script referenced by our XML extension file.

geoSystem = NonedsSystem = NonefluentSystem = None

def CreateGeometry(step): global geoSystem template1 = GetTemplate(TemplateName="Geometry") geoSystem = template1.CreateSystem() geometry1 = geoSystem.GetContainer(ComponentName="Geometry") geometry1.SetFile(FilePath=step.Properties["definition/filename"].Value)

def DeleteGeometry(step): global geoSystem geoSystem.Delete()

def RefreshMechanical(step): tree = step.UserInterface.GetPanel("Tree") root = tree.CreateTreeNode("Root") node1 = tree.CreateTreeNode("Node1") node2 = tree.CreateTreeNode("Node2") node3 = tree.CreateTreeNode("Node3") root.Values.Add(node1) root.Values.Add(node2) node2.Values.Add(node1) node2.Values.Add(node3) root.Values.Add(node3) tree.SetTreeRoot(root)

def CreateMechanical(step): global dsSystem, geoSystem template2 = GetTemplate( TemplateName="Static Structural", Solver="ANSYS") geometryComponent1 = geoSystem.GetComponent(Name="Geometry") dsSystem = template2.CreateSystem( ComponentsToShare=[geometryComponent1],

105Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Creating Guided Processes

Page 114: ANSYS ACT Developers Guide

Position="Right", RelativeTo=geoSystem) if step.Properties["name"].Value=="error": raise UserErrorMessageException("Invalid system name. Please try again.") dsSystem.DisplayText = step.Properties["name"].Value

def DeleteMechanical(step): global dsSystem dsSystem.Delete()

def CreateFluent(step): global dsSystem, fluentSystem template3 = GetTemplate(TemplateName="Fluid Flow") geometryComponent2 = dsSystem.GetComponent(Name="Geometry") solutionComponent1 = dsSystem.GetComponent(Name="Solution") componentTemplate1 = GetComponentTemplate(Name="CFDPostTemplate") fluentSystem = template3.CreateSystem( ComponentsToShare=[geometryComponent2], DataTransferFrom=[Set(FromComponent=solutionComponent1, TransferName=None, ToComponentTemplate=componentTemplate1)], Position="Right", RelativeTo=dsSystem) if step.Properties["name"].Value=="error": raise Exception("Invalid system name. Please try again.") fluentSystem.DisplayText = step.Properties["name"].Value

def cbDialog(sender, args): sender.Container.HideDialog(sender)

def ValidateDialog(step, prop): dialog = step.UserInterface.GetPanel("ErrorMessage") dialog.SetMessage("My own error message") dialog.SetCallback(cbDialog) dialog.Refresh() step.UserInterface.Container.ShowDialog(dialog)

def worker(step): progress = step.UserInterface.GetPanel("Progress") stopped = progress.UpdateProgress("Start progress...", 0, True) step.UserInterface.Container.ShowDialog(progress) for i in range(100): System.Threading.Thread.Sleep(100) stopped = progress.UpdateProgress("Start progress...", i+1, True) if stopped: break step.UserInterface.Container.HideDialog(progress)

def ValidateDialogProgress(step, prop): thread = System.Threading.Thread(System.Threading.ParameterizedThreadStart(worker)) thread.Start(step)

def ValidatePropActivate(step, prop): if prop.Value=="Yes": step.NextStep.Enabled = True else: step.NextStep.Enabled = False steps = step.UserInterface.GetPanel("Steps") steps.UpdateData() steps.Refresh()

def RefreshReport(step): report = step.UserInterface.GetPanel("Report") report.SetFilename(System.IO.Path.Combine(ExtAPI.Extension.InstallDir,"help","report.html")) report.Refresh() pass

This script defines all the actions executed by the callbacks in the XML file. Each step defined in theXML file may include multiple actions. In our example XML extension file:

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.106

Custom Guided Processes

Page 115: ANSYS ACT Developers Guide

• Step 1 (Geometry): The <onupdate> callback executes the CreateGeometry action and the <on-reset> callback executes the DeleteGeometry action. These create a geometry on the ProjectSchematic and delete it.

• Step 2 (Mechanical): The <onupdate> callback executes the CreateMechanical action and the<onreset> callback executes the DeleteMechanical action.

• Step 3 (Fluent): The <onupdate> callback executes the CreateFluent action.

Actions executed by callbacks within property definitions are also defined.

Note

For a mixed wizard, the definition of the first step executed in the Project tab also specifiesthe applications and component names from which subsequent steps will be executed. Forinstance, in the excerpted code sample below, we can see that multiple actions are defined;these will be called by the steps in the process definition file.

…def action1(step):

template1 = GetTemplate( TemplateName="Static Structural", Solver="ANSYS") system1 = template1.CreateSystem() geometry1 = system1.GetContainer(ComponentName="Geometry") geometry1.SetFile(FilePath=step.Properties["filename"].Value)

nextStep = step.NextStep if nextStep!=None: nextStep.SystemName = system1.Name nextStep.ComponentName = "Geometry"

thirdStep = step.Wizard.Steps["Step3"] if thirdStep!=None: thirdStep.SystemName = system1.Name thirdStep.ComponentName = "Model"…

The Custom Help Files

You can use custom HTML help files to provide instructions or details about each step in a guidedprocess. The files can contain any valid HTML5 syntax and supported media to display your help content.For wizards, help files can be stored in any folder inside the extension directory. For custom templates,help files are stored in the help folder in the extension directory.

When the guided process is executed, the file contents will be displayed in the Help panel (at thebottom of the wizard interface or to the left of the custom template interface).

Wizard Help

You can implement one HTML file for the wizard and one additional HTML file for each defined step.To implement help files in your wizard, specify the HTML file for a step by using the HelpFile attributein the XML step definition.

In Step 1 (the geometry step) of our Project wizard example, the HelpFile attribute is set tohelp/geometry.html.

<step name="Geometry" caption="Geometry" version="1" context="Project" HelpFile="help/geometry.html"> <description>Create a geometry component.</description>

107Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Creating Guided Processes

Page 116: ANSYS ACT Developers Guide

<callbacks> <update>CreateGeometry</update> <reset>DeleteGeometry</reset> </callbacks>...

The geometry.html file contains both text and a reference to the image geometry.png, alongwith the necessary display information to display the file contents in the Help panel at the bottom ofthe guided process UI.

Custom Template Help

You can implement one HTML file for the custom template and one additional HTML file for each definedproperty.

Note

In order to use custom help in an AIM custom template, the user of the extension must havewrite access to the following directory:

%AWP_ROOT162%\commonfiles\help\ACSHelpServer\docu_aim_html\custom

To implement help files in your custom template:

1. Create a help folder in your extension directory.

2. Create one HTML help file for your template and one for each of its defined properties, naming the files asfollows:

• Template: <templatename>.html

• Property:<templatename_propertyname>.html

When the extension is loaded to AIM, the folder will be copied into the %AWP_ROOT162%\common-files\help\ACSHelpServer\docu_aim_html\custom directory for display in the help panel.

Installing and Loading Guided Processes

Once you've created a guided process, the installation and loading process is the same as for any otherextension.

Installing Scripted Extensions

To install a guided process to disk, save the extension and associated files in one of the following loca-tions:

• %AWP_ROOT162%\Addins\AdvancedAddinPackage\extensions

• %APPDATA%\Ansys\v162\AdvancedAddinPackage\extensions

• Any of the include directories defined in the Additional Extension Folders field on the Extensionspage of the Options dialog.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.108

Custom Guided Processes

Page 117: ANSYS ACT Developers Guide

Installing Binary Extensions

Guided processes can also be created and installed as binary extensions (.wbex). To install a binaryguided process select Extensions > Install Extension and browse to the extension file.

Loading

Your guided processes will not be visible until you have loaded them to your project or Study. To loada guided process:

1. In the main menu, select Extensions > Manage Extensions.

2. In the Extensions Manager, select the guided processes you want to load.

3. Click OK.

In Workbench or a target application, an Open Wizard button will be added to the toolbar.

In AIM, an icon for each loaded custom template will be added under Simulation Process Templates.

Using Guided Processes

This section discusses accessing and executing an installed and loaded guided process.

The following topics are addressed:Using a Workbench or Target Application WizardUsing an AIM Custom TemplateViewing the Guided Process Log File

Using a Workbench or Target Application Wizard

Launching a Wizard

To launch a Workbench or target application wizard:

1. Click the Open Wizard toolbar button.

• For a Workbench Project wizard or mixed wizard, the button is in the Project Schematic toolbar.

• For a DesignModeler or Mechanical wizard, the button is in a toolbar inside the application.

The Wizard Start Page will open, showing a list of all loaded wizards, including an icon, name,description, and version for each wizard.

109Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Using Guided Processes

Page 118: ANSYS ACT Developers Guide

2. Click the wizard you want to run.

The wizard interface will open, showing the first step of the wizard.

The Wizard Interface

The default interface for a Workbench-based wizard (i.e. either Project or mixed) is divided into fourpanels, as shown below:

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.110

Custom Guided Processes

Page 119: ANSYS ACT Developers Guide

Top: Shows general information about the wizard and a logo of your choice.

Left: Shows a list of the steps in the wizard, with the current step highlighted.

Right: Shows the data-entry and data-display fields for the selected step.

Bottom: Shows the custom help for the selected step.

Note

The overall content and function of the wizard interface within the Mechanical or Design-Modeler application will be the same as in Workbench. However, the display of the interfacemay vary slightly according to the application.

Entering Data in a Wizard

For each step of the wizard, enter your data in the fields provided. Entered values will be validated asspecified in the extension.

When all the required values have been entered and pass validation, the Next button will become en-abled. When you click this button, your data is submitted and the action defined in the step is executed.There may be a progress bar for the step’s execution, and a message confirming the completion of the

111Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Using Guided Processes

Page 120: ANSYS ACT Developers Guide

step execution will be displayed. You can also verify completion of the step by reviewing the Projecttab.

Once you are past the first step, the Back button is enabled. When you click this button, the wizardreturns to the previous step, but the data generated for that step is lost.

To enter tabular data:

1. Click the Edit button.

2. Click the Add icon to add a table row.

3. Enter values into the cells.

4. When finished entering data, click the green check box icon to save or the red "X" icon to cancel

Exiting a Wizard or Project

To exit a wizard, click the Exit Wizard button in the lower left corner of the interface. This will returnyou to the Wizard Start Page. If you exit the wizard midway through, the changes to the project areretained and can be saved, but the wizard itself is not. You cannot resume the wizard where you leftoff when using Exit Wizard.

To exit the project with a wizard still in process, save the project and exit as usual. Upon reopening theproject, the wizard will still be in the state it was last saved in, so you can resume it where you left off.

Using an AIM Custom Template

To launch an AIM custom template:

1. Expand Simulation Process Templates.

The section will contain a custom template for each loaded guided process. (In the image below,a custom template called Cooling Jacket has been added.)

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.112

Custom Guided Processes

Page 121: ANSYS ACT Developers Guide

2. Click the custom template you want to run.

On the Study panel, the first part of the workflow defined by the custom template is displayedas a custom data panel.

Entering Data in a Custom Template

The single step of an AIM custom template creates a custom simulation workflow in AIM. Enter yourdata into the initial custom data panel.

1. Enter values into the initial custom data panel, as shown below.

113Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Using Guided Processes

Page 122: ANSYS ACT Developers Guide

2. Click the Create Simulation Process button.

Entered values will be validated at this time as specified in the extension. When all the requiredvalues pass validation, the new simulation process will be created.

Below, you can see that four tasks have been added to the newly created simulation process.

3. Now, with your custom workflow in place, you can work through the simulation as usual.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.114

Custom Guided Processes

Page 123: ANSYS ACT Developers Guide

Accessing Custom Help

Custom help can be defined for the step and properties in your custom template. If help is available,you can access it by expanding the Help panel to the right of the AIM interface, as shown below.

Note

When moving to a different property, you must click the data panel Help icon in order refreshthe Help panel content.

Viewing the Guided Process Log File

You can open the extension log file at any time, and can leave the window open while you are runningyour guided process. To view the log file, go to the main menu and select Extensions > View Log File.You can move or resize the log file window as needed.

115Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Using Guided Processes

Page 124: ANSYS ACT Developers Guide

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.116

Page 125: ANSYS ACT Developers Guide

APIs Description

ACT supports application customization with a set of interfaces for each supported application. Thischapter details aspects of the APIs delivered by ACT. The high-level member interfaces of the APIs exposethe properties and methods that allow access to the applications underlying data.

The extensions that are loaded by the Workbench Extension Manager are each configured and initializedto support Python scripting. For each extension, a global variable ExtAPI gives access to theDataModel property. This property returns an IDataModel object, which has properties that returnall of the high-level interfaces available for customizations. The complete list of member interfaces isgiven in the Application Customization Toolkit Reference Guide.

APIs for ANSYS Mechanical

This section describes some of the APIs provided by ACT for the customization of the ANSYS Mechanicalapplication. These APIs provide access to all the objects in the Mechanical tree (Project, Model, andAnalysis), allowing you to manipulate the objects and their properties.

Using the APIs, you can both create new objects and modify existing ones.

Note

When you create a new object, Mechanical initializes the object's property values in theDetails window to the same default values used when you add an object via standard mouse-click operations. Some properties, such as scoping or the mass of a point mass, may be invaliduntil you enter a value.

117Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 126: ANSYS ACT Developers Guide

For more information on ANSYS Mechanical APIs and their properties, refer to the Application Custom-ization Toolkit Reference Guide.

Directly Accessing an Object

You can get to an object by programmatically navigating the Mechanical tree.

The root node of the tree is ExtAPI.DataModel.Project. Each tree node has children that youcan access by calling Children property; this returns all of the child nodes in the project.

You can also call nested properties, such as Model , Geometry , Mesh , or Analyses, in order toaccess all of the instances of a given object or tree level.

Connection = ExtAPI.DataModel.Project.Model.Children[3]

Mesh = ExtAPI.DataModel.Project.Model.Mesh

Handling Property Types

This section provides examples of how to handle the various property types used within the Mechanicalapplication.

Quantity: A unit-based value typically related to a physical quantity.

Example:

my_object.ElementSize = Quantity("0.1 [m]")

Numerical Value (float and integer): A property, such as Relevance or Rate, expecting a numericalvalue (a number for which a unit is not specified).

Example:

my_object.TetraGrowthRate = 2

Boolean: A property expecting a True or False value.

Example:

my_object.WriteICEMCFDFiles = True

Geometry Scoping: A property whose value is one or more geometric entities. In these cases, you must:

1. Create selection information and specify the Ids of the entities you want to manipulate.

2. Assign this list of Ids to the Location / SourceGeometry properties.

Example:

my_selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)my_selection.Ids= [28,25]

My_object.Location = my_selection

API Examples: Model Object

This section addresses the programming calls that query for properties of Geometry, Mesh, andConnections properties within the Model object of the ANSYS Mechanical tree.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.118

APIs Description

Page 127: ANSYS ACT Developers Guide

The following examples all share the same four general steps:

1. Obtain the tree item under which the object will be created.

2. Create the object.

3. Create the selection information on which the object will be based.

4. Specify property values for the object.

Geometry: Point Mass

This example shows how to use ACT API to customize the Geometry object in the ANSYS Mechanicaltree. Specifically, it illustrates how to add a point mass on a face of the geometry and activate the pinballregion.

geometry = ExtAPI.DataModel.Project.Model.Children[0]

point_mass = geometry.AddPointMass()

my_selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities) my_selection.Ids = [22] point_mass.Location = my_selection point_mass.Mass = Quantity("12 [kg]") point_mass.MassMomentOfInertiaX = Quantity("1.1 [kg m m]")point_mass.MassMomentOfInertiaY = Quantity("1.2 [kg m m]")point_mass.MassMomentOfInertiaZ = Quantity("1.3 [kg m m]")point_mass.Behavior = LoadBehavior.Coupledpoint_mass.PinballRegion = Quantity("0.2 [m]")

It results in the creation of the point mass and activation of the pinball region in ANSYS Mechanical, asshown below:

Mesh: Mesh Control

This example shows how to use ACT API to customize the Mesh object in the ANSYS Mechanical tree.Specifically, it illustrates how to create a meshing control that applies the Patch Independent algorithmto the mesh.

mesh = ExtAPI.DataModel.Project.Model.Mesh

mesh_method = mesh.AddAutomaticMethod()

my_selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)

119Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

APIs for ANSYS Mechanical

Page 128: ANSYS ACT Developers Guide

my_selection.Ids = [16]mesh_method.Location = my_selectionmesh_method.Method = MethodType.AllTriAllTetmesh_method.Algorithm = MeshMethodAlgorithm.PatchIndependentmesh_method.MaximumElementSize = Quantity("0.05 [m]")mesh_method.FeatureAngle = Quantity("12.000000000000002 [degree]")mesh_method.MeshBasedDefeaturing = Truemesh_method.DefeaturingTolerance = Quantity("0.0001 [m]")mesh_method.MinimumSizeLimit = Quantity("0.001 [m]")mesh_method.NumberOfCellsAcrossGap = 1mesh_method.CurvatureNormalAngle = Quantity("36 [degree]")mesh_method.SmoothTransition = Truemesh_method.TetraGrowthRate = 1

It results in the creation of a Patch Independent meshing control in ANSYS Mechanical, as shown below:

Connections: Frictionless Contact and Beam

This example shows how to use the ACT API to customize the Connections object in the ANSYS Mech-anical tree. Specifically, it illustrates how to add a frictionless contact and a beam connection.

connection = ExtAPI.DataModel.Project.Model.Connectionscontact_region = connection.Children[0].Children[0]contact_region.ContactType = ContactType.Frictionless

beam = connection.AddBeam()beam.Radius = Quantity("0.005 [m]")reference_scoping = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)reference_scoping.Ids = [110]beam.ReferenceLocation = reference_scopingbeam.ReferenceBehavior = LoadBehavior.Deformablebeam.ReferencePinballRegion = Quantity("0.001 [m]")mobile_scoping = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)mobile_scoping.Ids = [38]beam.MobileLocation = mobile_scopingbeam.MobileZCoordinate = Quantity("6.5E-03 [m]")beam.MobilePinballRegion = Quantity("0.001 [m]")

It results in the creation of a frictionless contact and beam connection in ANSYS Mechanical, as shownbelow:

Analysis: Load Magnitude

This example shows how to use the ACT API to customize an Analysis object in the ANSYS Mechanicaltree, adding the magnitude of a load. Specifically, it illustrates how to customize a Static Structuralanalysis, specifying the external and internal pressure exerted on a pipe and then applying a force toa section of the pipe.

static_structural = ExtAPI.DataModel.Project.Model.Analyses[0]analysis_settings = static_structural.AnalysisSettings.NumberOfSteps = 4

bolt = static_structural.AddBoltPretension()bolt_scoping = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)bolt_scoping.Ids = [200]bolt.Location = bolt_scopingbolt.DefineBy = BoltLoadDefineBy.Loadbolt.Preload = Quantity("15 [N]")

support = static_structural.AddFixedSupport()support_scoping = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)support_scoping.Ids = [104]support.Location = support_scoping

pressure = static_structural.AddPressure()pressure_scoping = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)pressure_scoping.Ids = [220]pressure.Location = pressure_scoping

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.120

APIs Description

Page 129: ANSYS ACT Developers Guide

pressure.Magnitude.Output.Formula = '10*time'

pressure = static_structural.AddPressure()pressure_scoping = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)pressure_scoping.Ids = [221]pressure.Location = pressure_scopingpressure.Magnitude.Output.DiscreteValues=[Quantity('6 [Pa]')]

force = static_structural.AddForce()force_scoping = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)force_scoping.Ids = [219]force.Location = force_scopingforce.Magnitude.Output.DiscreteValues=[Quantity('11.3 [N]'), Quantity('12.85 [N]')]

In our example, we apply the internal and external pressures to the pipe:

pressure.Magnitude.Output.Formula = '10*time'

pressure.Magnitude.Output.DiscreteValues=[Quantity('6 [Pa]')]

Then we use tabular data to apply a vector force to the pipe:

Note

If you use a constant ramped from t=0s to define the force, the first value cannot be"0" .

force.Magnitude.Output.DiscreteValues=[Quantity('11.3 [N]'), Quantity('12.85 [N]')]

Script execution results in the creation of a Magnitude property for the applied Force, with time as aninput variable and a single output variable:

Although initially we used tabular data to define the Magnitude property, we can also use a constantvalue or a time- or space-dependent formula. Below is an example of how to use a constant value todefine the property:

force.Magnitude.Output.DiscreteValues=[Quantity('10 [N]')]

121Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

APIs for ANSYS Mechanical

Page 130: ANSYS ACT Developers Guide

We can also opt to define the Magnitude property with global coordinates, instead of a vector, by usingthe following commands:

force.DefineBy = LoadDefineBy.Componentsforce.ZComponent.Output.DiscreteValues = [Quantity('0 [N]'),Quantity('-9 [N]')]

Result: Total Deformation Maximum

This example shows how to use the ACT API to customize the Result object in the ANSYS Mechanicaltree. Specifically, it illustrates how to add a Total Deformation result to a Static Structural analysis andthen solve for the minimum and maximum total deformation.

solution = ExtAPI.DataModel.Project.Model.Analyses[0].Solutiontotal_deformation = solution.AddTotalDeformation()analysis = ExtAPI.DataModel.Project.Model.Analyses[0]analysis.Solve(True)minimum_deformation = total_deformation.Minimummaximum_deformation = total_deformation.Maximum

It results in a solved analysis indicating the values for the Minimum and Maximum properties for theTotal Deformation result, as shown below:

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.122

APIs Description

Page 131: ANSYS ACT Developers Guide

API Examples: TraverseExtension

The examples in this section address programming calls that query geometry, mesh, simulation andresults properties. Each of the code samples are taken from the TraverseExtension extension.

Traversing the Geometry

The API for geometry data is organized to match the underlying hierarchical data model. The API offersa variety of property queries through which the connectivity of the geometry entities can be determined.For instance, it is possible to query for the faces upon which an Edge is defined by using the facesproperty exposed by the edge interface. Refer to the Application Customization Toolkit Reference Guidefor a comprehensive list of these interfaces and their properties.

Shown below is the basic hierarchy of the geometry.

- Geometry - Assembly - Part - Body - Shell - Face - Edge - Vertex

The Python script function traversegeometry() demonstrates how an extension could traversethe geometry data. In this example, an object of type IGeoData is obtained from the Analysis objectusing the GeoData property. This GeoData object is then used to query for a list of IGeoAssemblyobjects by calling the Assembly property. For each of the IGeoAssembly objects in the returnedlist, the Parts property is called and a list of IGeoPart objects is returned. This pattern is repeatedthrough the hierarchy of the geometry down to the vertices of each edge.

123Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

APIs for ANSYS Mechanical

Page 132: ANSYS ACT Developers Guide

Below is the content of the traversegeometry() function.

def traversegeometry(analysis): now = datetime.datetime.now() outFile = analysis.WorkingDir + "SolutionDetails.log" f = open(outFile,'a') f.write("*.*.*.*.*.*.*.*\n") f.write(str(now)+"\n") # --- IGeometry Interface # +++ Properties and Methods # +++ Assemblies # +++ CellFromRefId # +++ SelectedRefIds geometry = analysis.GeoData assemblies = geometry.Assemblies assemblies_count = assemblies.Count # --- IGeoAssembly Interface # +++ Properties and Methods # +++ Name # +++ Parts for assembly in assemblies: assembly_name = assembly.Name parts = assembly.Parts parts_count = parts.Count # --- IGeoPart Interface # +++ Properties and Methods # +++ Name # +++ Bodies for part in parts: part_name = part.Name bodies = part.Bodies bodies_count = bodies.Count # --- IGeoBody Interface # +++ Properties and Methods # +++ Name # +++ Vertices # +++ Edges # +++ Faces # +++ Shells # +++ Material for body in bodies: faces = body.Faces faces_count = faces.Count # --- IGeoFace Interface # +++ Properties and Methods # +++ Body # +++ Shell # +++ Vertices # +++ Edges # +++ Loops # +++ Area # +++ SurfaceType # +++ PointAtParam # +++ PointsAtParams for face in faces: edges = face.Edges edges_count = edges.Count # --- IGeoEdge Interface # +++ Properties and Methods # +++ Faces # +++ Vertices # +++ StartVertex # +++ EndVertex # +++ Length # +++ CurveType # +++ Extents # +++ IsParamReversed # +++ ParamAtPoint # +++ PointAtParam # +++ PointsAtParams for edge in edges: vertices = edge.Vertices

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.124

APIs Description

Page 133: ANSYS ACT Developers Guide

vertices_count = vertices.Count # --- IGeoVertex Interface # +++ Properties and Methods # +++ Edges # +++ Faces # +++ Bodies # +++ X # +++ Y # +++ Z for vertex in vertices: xcoord = vertex.X ycoord = vertex.Y zcoord = vertex.Z try: f.write(" Vertex: "+vertex.ToString()+", X = "+xcoord.ToString()+", Y = "+ycoord.ToString()+", Z = "+zcoord.ToString()+"\n") except: continue f.close() return

Traversing the Mesh

The Mesh API offers a variety of property queries through which the connectivity of the mesh entitiescan be determined. For comprehensive information on the Mesh API interfaces and properties, see theApplication Customization Toolkit Reference Guide.

The following Python script function traversemesh() demonstrates how an extension could traversethe mesh data. In the example shown below, an object of type IMeshData is obtained from theIAnalysis object using the MeshData property. This mesh object is then used to query for a list ofelement IDs with the Elements property. For each of the element IDs in the returned list, the Elementmethod is called and the corresponding IElement object is returned. This pattern is repeated for allthe nodes for each element. Finally, the coordinates of the nodes are queried. Comments are includedin the example below to clarify script functionality.

Below is the content of the traversemesh() function.

def traversemesh(analysis): now = datetime.datetime.now() outFile = analysis.WorkingDir + "SolutionDetails.log" f = open(outFile,'a') f.write("*.*.*.*.*.*.*.*\n") f.write(str(now)+"\n") # --- IMesh Interface # +++ Properties and Methods # +++ MeshRegion # +++ Node # +++ Element # +++ Nodes # +++ Elements # +++ NumNodes # +++ NumElements mesh = analysis.MeshData elementids = mesh.ElementIds # --- IElement Interface # +++ Properties and Methods # +++ Id # +++ Type # +++ Nodes for elementid in elementids: element = mesh.ElementById(elementid) nodeids = element.NodeIds # --- INode Interface # +++ Properties and Methods # +++ Id # +++ X # +++ Y

125Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

APIs for ANSYS Mechanical

Page 134: ANSYS ACT Developers Guide

# +++ Z # +++ Elements for nodeid in nodeids: node = mesh.NodeById(nodeid) nodex = node.X nodey = node.Y nodez = node.Z try: f.write(" Element: "+elementid.ToString()+" Node: "+nodeid.ToString()+", X = "+nodex.ToString()+", Y = "+nodey.ToString()+", Z = "+nodez.ToString()+"\n") except: continue f.close() return

The Python script function elementcounter() demonstrates another example of how an extensioncould access the mesh data. In this example, only the elements of user-selected geometry entities areconsidered. First, the script obtains the IGeoData and IMeshData objects. Then the CurrentSe-lection.Ids property queries the IDs of the selected geometry entities using the ISelectionMgrobject. If no IDs are returned, a MessageBox displays the message "Nothing Selected." Otherwise, theGeoEntityById and MeshRegionById methods obtain the IGeoEntity and IMeshRegionobjects corresponding to each selected entity. These two objects are used inside the try-except blockto query for the type of entity selected and the number of elements in each entity's mesh. The Typeproperty of the IGeoEntity interface and the NumElements property of the IMeshRegion interfaceare used here and the results are displayed in a MessageBox.

def elementcounter(analysis): geometry = analysis.GeoData mesh = analysis.MeshData selectedids = ExtAPI.SelectionMgr.CurrentSelection.Ids if selectedids.Count == 0: MessageBox.Show("Nothing Selected!") else: for selectedid in selectedids: entity = geometry.GeoEntityById(selectedid) meshregion = mesh.MeshRegionById(selectedid) try: numelem = meshregion.ElementCount MessageBox.Show("Entity of type: "+entity.Type.ToString()+ " contains "+numelem.ToString()+ " elements.") except: MessageBox.Show("The mesh is empty!") return return

Traversing Results

The Python function minmaxresults() computes the minimum and maximum component valuesof the nodal displacement and the SXX stress component. It begins by instantiating a result reader usingthe analysis.ResultsData method. Results are retrieved relative to the finite element model andqueried using either the elementID (elemental result) or the nodeID (nodal result). The displacementresult "U" is a nodal result, whereas the stress result "S" is a result on nodes of the elements. The dis-placement result stores a set of component values for each node, where the component names are X,Y and Z.

The script minmaxresults first iterates over the nodeIDs to compute the minimum and maximumvalues. Then, the script iterates over the elementIDs and the nodes of each element to compute theminimum and maximum values. Note that the second loop over the nodes is filtered to the primarynodes of the elements, since stress results are available only on these primary nodes. Finally, the resultsare written to the output file.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.126

APIs Description

Page 135: ANSYS ACT Developers Guide

Below are the contents of the minmaxresults() function.

def minmaxresults(analysis): now = datetime.datetime.now() outFile = analysis.WorkingDir + "SolutionDetails.log" f = open(outFile,'a') f.write("*.*.*.*.*.*.*.*\n") f.write(str(now)+"\n") # # Get the element ids # meshObj = analysis.MeshData elementids = meshObj.ElementIds nodeids = meshObj.NodeIds # # Get the results reader # reader = analysis.GetResultsData() reader.CurrentResultSet = int(1) # # Get the displacement result object disp = reader.GetResult("U")

num = 0 for nodeid in nodeids: # # Get the component displacements (X Y Z) for this node # dispvals = disp.GetNodeValues(nodeid) # # Determine if the component diplacement (X Y Z) is min or max # if num == 0: maxdispx = dispvals[0] mindispx = dispvals[0] maxdispy = dispvals[1] mindispy = dispvals[1] maxdispz = dispvals[2] mindispz = dispvals[2]

num += 1

if dispvals[0] > maxdispx: maxdispx = dispvals[0] if dispvals[1] > maxdispy: maxdispy = dispvals[1] if dispvals[2] > maxdispz: maxdispz = dispvals[2] if dispvals[0] < mindispx: mindispx = dispvals[0] if dispvals[1] < mindispy: mindispy = dispvals[1] if dispvals[2] < mindispz: mindispz = dispvals[2]

# Get the stress result object stress = reader.GetResult("S") # Select the component to retrieve stress.SelectComponents(["X"])

num = 0 for elementid in elementids: element = meshObj.ElementById(elementid) # # Get the SXX stress component # stressval = stress.GetElementValues(elementid) # # Get the primary node ids for this element # nodeids = element.CornerNodeIds for i in range(nodeids.Count):

127Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

APIs for ANSYS Mechanical

Page 136: ANSYS ACT Developers Guide

# # Get the SXX stress component at node "nodeid" # SXX = stressval[i] # # Determine if the SXX stress component is min or max # if num == 0: maxsxx = SXX minsxx = SXX if SXX > maxsxx: maxsxx = SXX if SXX < minsxx: minsxx = SXX num += 1 # # Write the results to the output # f.write("Max U,X:Y:Z = "+maxdispx.ToString()+" : "+maxdispy.ToString()+" : "+maxdispz.ToString()+"\n") f.write("Min U,X:Y:Z = "+mindispx.ToString()+" : "+mindispy.ToString()+" : "+mindispz.ToString()+"\n") f.write("Max SXX = "+maxsxx.ToString()+"\n") f.write("Min SXX = "+minsxx.ToString()+"\n") f.close()

User Interface and Toolbars

The UserInterface API provides methods to control the ACT-based GUI of Mechanical. The API isavailable using the following entry point:

ExtAPI.UserInterface

This API allows access to toolbars and provides the ability to hide or gray-out ACT-based features. Notethat it cannot be used to create new items (e.g., toolbars); it only provides access to existing UI elements.

ExtAPI.UserInterface.Toolbars is a collection of toolbar objects. Each object has fields to accessName/Caption/Visibility/Child Entries. Each child has the following properties: Caption,Enabled, Entries, EntryType, Name, and Visible.

The boolean fields Visible and Enabled can be set to "show" or "hide" so that the user can controlthe availability of the buttons depending on the current context.

APIs for ANSYS Design Modeler

The following sections describe some of the APIs provided by ACT for the customization of ANSYSDesignModeler's interface and functionality. Once these customizations are in place, they can be usedto create and manipulate geometries. You can use them to first define and generate primitives andbodies, and then to apply various operations, tools, or automated processes to the resulting geometries.

The examples provided in this chapter address working with a selected graphic, creating different typesof primitives, and applying different operations. The code for creating primitive bodies or applying op-erations must be integrated into the <ongenerate> callback.

For more comprehensive information on the DesignModeler API interfaces and their properties, referto the Application Customization Toolkit Reference Guide.

Using the Selection Manager in DesignModeler

The DesignModeler Selection Manager API allows you to work with graphical selections. It providesservice to get information from and to modify, clear, or retrieve the current selection. Additionally, itenables you to create new selections or add entities to the new selection.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.128

APIs Description

Page 137: ANSYS ACT Developers Guide

Working with the Current Selection

The following Selection Manager commands allow you to perform different actions on the currentlyselected graphic.

To access the Selection Manager:

selection_manager = ExtAPI.SelectionManager

To clear the current selection:

selection_manager.ClearSelection()

To retrieve the current selection:

selection = selection_manager.CurrentSelection

This command returns an ISelectionInfo object that describes the selected entities.

To retrieve entities:

selection.Entities

Creating a New Selection and Adding Entities

The Selection Manager enables you to create new selections and add entities to the current selection.Both of these tasks can be accomplished by either creating a new ISelectionInfo object or bydirectly using a list of entities.

To create a new selection using a new ISelectionInfo object:

face = ExtAPI.DataModel.GeoData.Bodies[0].Faces[0]selection = selection_manager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)selection.Entities = [face]selection_manager.NewSelection(selection)

To create a new selection using a list of entities:

face = ExtAPI.DataModel.GeoData.Bodies[0].Faces[0]selection_manager.NewSelection([face])

To add entities to the current selection using a new ISelectionInfo object:

face = ExtAPI.DataModel.GeoData.Bodies[0].Faces[0]selection = selection_manager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)selection.Entities = [face]selection_manager.AddSelection (selection)

To add entities to the current selection using a list of entities:

face = ExtAPI.DataModel.GeoData.Bodies[0].Faces[0]selection_manager.AddSelection([face])

Creating Primitives

The DesignModeler Primitives API provides you with the ability to create different types of primitivebodies: sheet bodies, wire bodies, and solid bodies. For each primitive body type, multiple shape optionsare available.

129Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

APIs for ANSYS Design Modeler

Page 138: ANSYS ACT Developers Guide

Figure 53: Primitive body type and shape options

The <primitives> variable ExtAPI.DataModel.GeometryBuilder.Primitives is thegateway for designing a new geometric body. The code must be integrated into the <ongenerate>callback.

The Python script function ongenerate() can be used to create a primitive body. The API providesa variety of queries that allow you to specify properties such as body type, dimensions, shape, pointcoordinates, and material.

Creating a Sheet Body

When creating a sheet body, you have the option of defining it in the shape of a cone, cylinder, polygon,or sphere. Below is an example of the ongenerate() function when used to define a sheet bodycylinder.

def Ongenerate(feature,function): width = 0.015 height = 0.3 sheetBodies = [] primitive = ExtAPI.DataModel.GeometryBuilder.Primitives cylinder = primitive.Sheet.CreateCylinder([0.,0.,0.],[0.,0.,height],width) cylinder_generated = cylinder.Generate() sheetBodies.Add(cylinder_generated)

feature.Bodies = sheetBodies feature.MaterialType = MaterialTypeEnum.Freeze

return True

In this example:

• The width and height variables are used to define the width and the height of the cylinder.

• The sheetBodies variable specifies the type of primitive to be created.

• The primitive variable uses the global variable ExtAPI to access the data model and define the geometrybuilder, which serves as entry point for ACT into DesignModeler.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.130

APIs Description

Page 139: ANSYS ACT Developers Guide

• The CreateCylinder () method is used to generate the new body, specifying that it is defined by thefollowing arguments:

– Coordinates of the center point of the cylinder’s base

– Coordinates of the center point of the upper face (which will define the direction of the cylinder)

– Value of the radius

(This is a float. The integer value << 3 >>, for instance, will be refused, while a value of << 3. >>will be accepted.)

• With the cylinder_generated object, we use the Generate () method to generate the cylinder, asshown below.

Figure 54: Generation of sheet body cylinder primitive

• With the lines sheetBodies.Add(cylinder_generated) and feature.Bodies = sheetBodies,we add the sheet body cylinder to the feature.bodies list so it will be added to DesignModeler aftergeneration. Bodies not added to this list will not be retained.

• With the MaterialType line, we specify a material property of Freeze.

Creating a Wire Body

When creating a wire body, you have the option of defining it in the shape of an arc, curve, ellipse, orpolyline. Below is an example of the ongenerate() function when used to define a wire body polyline.

def Ongenerate(feature,function): points_list = [0.,0.,0., 1.,0.,0., 1.,1.,0., 1.,1.,1.]

wireBodies = []

primitive = ExtAPI.DataModel.GeometryBuilder.Primitives polyline = primitive.Wire.CreatePolyline(points_list) polyline_generated = polyline.Generate() wireBodies.Add(polyline_generated)

feature.Bodies = wireBodies feature.MaterialType = MaterialTypeEnum.Add

return True

131Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

APIs for ANSYS Design Modeler

Page 140: ANSYS ACT Developers Guide

In this example:

• The points_list () method is defined for later use in the creation of the polyline body. For arguments,it expects as a list of coordinate points (defined by three float values per point).

• The primitive variable uses the global variable ExtAPI to access the data model and define the geometrybuilder, which serves as entry point for ACT into DesignModeler.

• The CreatePolyline () method is applied to the object Wire to generate the new body. As arguments,this method is expecting the coordinate points defined by the points_list method above.

• With the polyline_generated object, we use the Generate () method to generate the polyline, asshown below.

Figure 55: Generation of wire body polyline primitive

• The new body is added to the feature.bodies list, as described in Creating a Sheet Body (p. 130).

• With the MaterialType line, we specify a material property of Add.

Creating a Solid Body

When creating a solid body, you have the option of defining it in the shape of a box, cone, cylinder, orsphere. Below is an example of the ongenerate() function when used to define a solid body box.

def Ongenerate(feature,function): point1 = [0.,0.,0.] point2 = [1.,2.,2.] solidBodies = []

primitive = ExtAPI.DataModel.GeometryBuilder.Primitives box1 = primitive.Solid.CreateBox(point1, point2) box1_generated = box1.Generate() solidBodies.Add(box1_generated)

feature.Bodies = solidBodies feature.MaterialType = MaterialTypeEnum.Freeze

return True

In this example:

• The point1 () and point2 () methods are defined for later use in the creation of the solid body. Forarguments, they each expect as a list of coordinate points (defined by three float values per point).

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.132

APIs Description

Page 141: ANSYS ACT Developers Guide

• The primitive variable uses the global variable ExtAPI to access the data model and define the geometrybuilder, which serves as entry point for ACT into DesignModeler.

• The CreateBox () method is applied to the object Solid to generate the new body. For arguments,this method is expecting the coordinate points defined by the point1 and point2 methods above.

• With the box1_generated object, we use the Generate () method to generate the box, as shownbelow.

Figure 56: Generation of solid body box primitive

• The new body is added to the feature.bodies list, as described in Creating a Sheet Body (p. 130).

• With the MaterialType line, we specify a material property of Freeze.

Applying Operations

The DesignModeler Operations API enables you to perform different operations on a geometric body.Available operations can be divided into two different categories: Primary and Boolean Operationsand Tools Operations.

Figure 57: Operation types and options

133Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

APIs for ANSYS Design Modeler

Page 142: ANSYS ACT Developers Guide

The operation variable ExtAPI.DataModel.GeometryBuilder.Operations is the gatewayfor performing operations. The code must be integrated into the <ongenerate> callback.

The Python script function ongenerate() can be used to perform various types of operations on ageometry feature. The API provides primary and Boolean operations that allow you to specify propertiessuch as body type, dimensions, shape, point coordinates, and material. It also offers a number of toolsthat can be used to manipulate your geometry, including actions such as copying or deleting a bodyor using transform operations to create a body based on another body or topological components.

Applying the Extrude Operation

When using the Extrude operation, you must first create the geometry to which the extrusion will beapplied. You can create any of the sheet primitive shapes listed in Creating Primitives (p. 129). Once thegeometry has been created, you can define and apply the Extrude operation to it.

Below is an example of the ongenerate() function when used to create a polygon sheet body and performan Extrude operation.

def Ongenerate(feature,function): length = 0.3 bodies = []

builder = ExtAPI.DataModel.GeometryBuilder polygon=builder.Primitives.Sheet.CreatePolygon([0.,0.,3*length,0.,0.,2.*length,length,0.,2.*length]) polygon_generated = polygon.Generate() extrude = builder.Operations.CreateExtrudeOperation([0.,1.,0.],length/2.) bodies.Add(extrude.ApplyTo(polygon_generated)[0])

feature.Bodies = bodies feature.MaterialType = MaterialTypeEnum.Add

return True

In this example:

• The first part of the function creates a polygon sheet body, using a process similar to the one used to createa cylinder in Creating a Sheet Body (p. 130).

• With the Extrude operation, we use the operations generator builder.Operations.CreateEx-trudeOperation. The CreateExtrudeOperation method specifies that the operation is defined bythe following arguments:

– Vector coordinates (which will define the direction of the extrusion)

– Length of the extrusion

Note

In our example, the same Length variable is used for both the sheet body and theextrusion definition. We also could have used a different variable for each.

• The ApplyTo method specifies the geometry to which the extrude operation will be applied. The Ap-plyTo() method returns a list of bodies to which the operation will be applied.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.134

APIs Description

Page 143: ANSYS ACT Developers Guide

• With the lines bodies.Add(extrude.ApplyTo(polygon_generated)[0]) and feature.Bodies= bodies, we add the extruded sheet body polygon to the feature.bodies list so it will be added toDesignModeler after generation. Bodies not added to this list will not be retained.

Figure 58: Application of the Extrude operation to a sheet body polygon

Applying the Transform Edges to Wire Tool

When using the Transform Edges to Wire operation tool, you must first create a geometry thathas some edges. You can create any of the sheet body or solid body shapes listed in Creating Primit-ives (p. 129). Once the primitive has been created, you can obtain a wire body from its edges by definingand applying the Transform Edges to Wire tool.

Below is an example of the ongenerate() function when used to create a polygon sheet body applythe Transform Edges to Wire tool to it.

def Ongenerate(feature,function): length = 0.3 bodies = []

builder = ExtAPI.DataModel.GeometryBuilder polygon = builder.Primitives.Sheet.CreatePolygon([0.,0.,2.*length,0.,0.,1.*length,length,0.,0.7]) polygon_generated = polygon.Generate() body = builder.Operations.Tools.EdgesToWireBody(polygon_generated.Edges); bodies.Add(body)

feature.Bodies = bodies feature.MaterialType = MaterialTypeEnum.Add

return True

In this example:

• The first part of the function creates a polygon sheet body, using a process similar to the one used to createa cylinder in Creating a Sheet Body (p. 130).

• With the body function, we use the operations generator builder.Operations.Tools.EdgesToWire-Body. The EdgesToWireBody method specifies that the operation tool will transform the edges of thesheet body polygon into a wire body.

Note

In our example, the same Length variable is used for multiple faces of the sheet body.We also could have used a different variable for each face.

135Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

APIs for ANSYS Design Modeler

Page 144: ANSYS ACT Developers Guide

• The new wire body is added to the feature.bodies list, as described in Applying the Extrude Opera-tion (p. 134).

Figure 59: Application of the Edges to Wire Body tool to a sheet body polygon

APIs for ANSYS DesignXplorer

The APIs provided by ACT to customize the ANSYS DesignXplorer application are addressed in the fol-lowing sections.

DOE APIs

This section discusses the APIs provided by ACT to customize DesignXplorer DOE functionality.

DOE Architecture

The object PSMtrxGenerator is responsible for the execution of the DOE. Regardless of whether thesampling is built-in or external, it executes the same process via the sampling API.

The main elements of the API, shown below in Figure 60: DesignXplorer's Sampling Architecture (p. 137),are as follows:

• ISamplingMethod : the main interface between DX and the external sampling, which is required to im-plement it

• IServices: the interface for the external sampling to access DX services, such as the calculation of oneor more points

• DXPoint: the class that describes and stores the point data, such as variable values, calculation state, etc.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.136

APIs Description

Page 145: ANSYS ACT Developers Guide

Figure 60: DesignXplorer's Sampling Architecture

For more details about the API, see the "API Description" section in the ACT Reference Guide forDesignXplorer.

The Sampling Process

The PSMtrxGenerator object drives the sampling process as illustrated by the sequence diagram inFigure 61: DesignXplorer's Sampling Process (p. 138).

First, it retrieves an instance of the sampling through the callback declared in the extension. It providesthe Services object and transfers the complete sampling definition: all variables, parameter andsettings.

Note that the PSMtrxGenerator object retrieves an instance of the sampling each time the samplingprocess is started (by invoking the OnCreate callback) and released on completion (by invoking theOnRelease callback).

After a final CanRun check, the sampling's Run method is invoked. From this point in the sequence,the external sampling is driving: triggering the calculation of points as needed and also pushing progressmessages and log messages, depending on its capabilities.

137Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

APIs for ANSYS DesignXplorer

Page 146: ANSYS ACT Developers Guide

Figure 61: DesignXplorer's Sampling Process

Optimization APIs

This section discusses the APIs provided by ACT to customize DesignXplorer optimization functionality.

Optimization Architecture

The object OptimizationEngineMgr is responsible for the execution of the optimization. Regardlessof whether the optimizer is built-in or external, it executes the same process via the optimization API.The main elements of the API, shown below in Figure 62: DesignXplorer's Optimization Architec-ture (p. 139), are as follows:

• IOptimizationMethod: the main interface between DX and the external optimizer, which is requiredto implement it

• IOptimizationServices: the interface for the external optimizer to access DX services, such as thecalculation of one or more points

• DXOptimizationPoint: the class that describes and stores the points data, such as variable values, cal-culation state, etc.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.138

APIs Description

Page 147: ANSYS ACT Developers Guide

Figure 62: DesignXplorer's Optimization Architecture

For more details about the API, see the "API Description" section in the ACT Reference Guide forDesignXplorer.

The Optimization Process

The OptimizationEngineMgr object drives the optimization process as illustrated by the sequencediagram in Figure 63: DesignXplorer's Optimization Process (p. 140).

First, it retrieves an instance of the optimizer through the callback declared in the extension. It providesthe Services object and transfers the complete optimization study definition: all variables, parameterrelationships, objectives, constraints, and settings.

Note that the OptimizationEngineMgr object retrieves an instance of the optimizer each time theoptimization process is started (by invoking the OnCreate callback) and released on completion (byinvoking the OnRelease callback).

After a final CanRun check, the optimizer's Run method is invoked. From this point in the sequence,the external optimizer is driving: triggering the calculation of points as needed and also pushing progressmessages, history points, convergence values, and log messages, depending on its capabilities.

139Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

APIs for ANSYS DesignXplorer

Page 148: ANSYS ACT Developers Guide

Figure 63: DesignXplorer's Optimization Process

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.140

APIs Description

Page 149: ANSYS ACT Developers Guide

Associated Libraries

This chapter describes the libraries installed with the ACT. These libraries include a set of Python functionsthat can be used to develop extensions more efficiently.

The commands related to the examples provided below can be interactively tested using the ACTConsoleextension from the application. The ACTConsole extension is installed with ACT and you can refer toACT Console Extension (p. 202) for more detailed information.

The following sections describe a subset of the available libraries. You can access other libraries fromthe ANSYS installation directory and consult the source code for a reference on their use. Libraries canbe found in the following directories:

%ANSYSversion_DIR%\..\Addins\AdvancedAddinPackage\libraries\Mechanical%ANSYSversion_DIR%\..\Addins\AdvancedAddinPackage\libraries\Project

Query to Material Properties

Description

This library allows you to access to all material properties defined in Engineering Data. The material isdefined for each body and can be retrieved using the geometry API.

Location

libraries/Mechanical/materials.pylibraries/Project/materials.py

Usageimport materials

FunctionsGetListMaterialProperties(mat)

This function returns a list of property names for the material mat given in argument.

GetMaterialPropertyByName(mat, name)

This function returns the material property name for the material mat.

InterpolateData(vx, vy, vin)

This function computes a linear interpolation vout = f(vin) with f defined by vy = f(vx).

• vx represents a list of values for the input variable.

• vy represents a list of values for the property that depends on the input variable defined by vx.

141Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 150: ANSYS ACT Developers Guide

• vin is the value on which the function has to evaluate the property.

Example

This command:

import materials

mat = ExtAPI.DataModel.GeoData.Assemblies[0].Parts[0].Bodies[0].Material

materials.GetListMaterialProperties(mat)

returns the following result:

['Compressive Ultimate Strength', 'Compressive Yield Strength', 'Density', 'Tensile Yield Strength', 'Tensile Ultimate Strength', 'Coefficient of Thermal Expansion', 'Specific Heat', 'Thermal Conductivity', 'Alternating Stress', 'Strain-Life Parameters', 'Resistivity', 'Elasticity', 'Relative Permeability']

This command:

prop = materials.GetMaterialPropertyByName(mat,"Elasticity")

prop

returns the following result:

{"Poisson's Ratio": ['', 0.29999999999999999, 0.29999999999999999, 0.29999999999999999], 'Bulk Modulus': ['Pa', 166666666666.667, 175000000000.0, 183333333333.333], 'Temperature': ['C', 10.0, 100.0, 1000.0], "Young's Modulus": ['Pa', 200000000000.0, 210000000000.0, 220000000000.0], 'Shear Modulus': ['Pa', 76923076923.0769, 80769230769.2308, 84615384615.3846]}

This command:

val = materials.InterpolateData(prop["Temperature"][1:],prop["Young's Modulus"][1:],10.)

val

val = materials.InterpolateData(prop["Temperature"][1:],prop["Young's Modulus"][1:],20.)

val

returns the following result:

200000000000.0

201111111111.0

Units Conversion

Description

This library implements a set of functions to manipulate the unit dependent quantities within an exten-sion. This library is of particular interest each time quantities have to remain consistent with the currentunit system activated in the application.

Location

libraries/Mechanical/units.pylibraries/Project/units.py

Usageimport units

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.142

Associated Libraries

Page 151: ANSYS ACT Developers Guide

FunctionConvertUnit(value,fromUnit,toUnit[,quantityName])

This function converts the value from the unit fromUnit to the unit toUnit. The user can specifythe quantity name to avoid conflict during conversion. This quantity name is not mandatory.

Example

This command:

import unitsunits.ConvertUnit(1,"m","mm")

returns the following result:

1000.0

FunctionConvertUserAngleUnitToDegrees(api, value)

This function converts the angle value to the unit degrees. If the current activated unit is already de-grees, then the value remains unchanged.

Example

This command:

import unitsunits.ConvertUserAngleUnitToDegrees(api,3.14)

returns

180. if the angle unit is set to radius when the command is called

3.14 if the angle unit is set to degrees when the command is called

FunctionConvertToSolverConsistentUnit(api, value, quantityName, analysis)

This function converts the valueof the quantity quantityName from the currently activated unit inthe application to the corresponding consistent unit used by the solver for the resolution of the analysisanalysis.

Example

This command:

import unitsunits.ConvertToSolverConsistentUnit(api,1.,”pressure”,”Static Structural”)

returns

10. if the unit system is set to Metric(mm,dat,N,s,mV,mA) when the command is called

FunctionConvertToUserUnit(api, value, fromUnit, quantityName)

143Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Units Conversion

Page 152: ANSYS ACT Developers Guide

This function converts the value of the quantity quantityName from the unit fromUnit to thecurrently activated unit system in the application.

Example

This command:

import unitsunits.ConvertToUserUnit(api,1.,”m”,”length”)

returns

1000. if the current activated unit is millimeter when the command is called

FunctionConvertUnitToSolverConsistentUnit(api, value, fromUnit, quantityName, analysis)

This function converts the valueof the quantity quantityName from the unit fromUnit to theconsistent unit that is used by the solver for the resolution of the analysis analysis.

Example

This command:

import unitsunits.ConvertUnitToSolverConsistentUnit(api,1.,”m”,”length”,”Static Structural”)

returns

1000. if the consistent unit is millimeter when the command is called

FunctionGetMeshToUserConversionFactor(api)

This function returns the scale factor to be applied to convert a length from the unit associated to themesh and the currently activated unit in the application.

Example

This command:

import unitsunits.GetMeshToUserConversionFactor(api)

returns

1000. if the unit associated to the mesh is meter and if the current activated unit in the application is millimeter.

MAPDL Helpers

Description

This library implements some helpers to write APDL command blocks or to execute ANSYS MechanicalAPDL programs.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.144

Associated Libraries

Page 153: ANSYS ACT Developers Guide

Location

libraries/Mechanical/ansys.pylibraries/Project/ansys.py

Usageimport ansys

FunctionscreateNodeComponent(refIds,groupName,mesh,stream,fromGeoIds=True)

This function writes the APDL command block (CMBLOCK) for the creation of a node component relatedto the geometry entities identified by refIds into the stream stream. “refIds” refer to geometric IDsif “fromGeoIds” is true and the node IDs are retrieved from geometric entities using the associativitybetween the geometry and mesh. If “fromGeoIds” is false, then “refIds” refer directly to the node IDs tobe 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 componentrelated to the geometry entities identified by “refIds” into the stream “stream”. “refIds” refer to geometricIDs if “fromGeoIds” is true and the element IDs are retrieved from geometric entities using the associ-ativity between the geometry and the mesh. If “fromGeoIds” is false, the “refIds” refer directly to theelement IDs to be written in the component.

RunANSYS(api,args,[runDir[,exelocation]])

This function calls the ANSYS Mechanical APDL program with the command line initialized by args.The user can specify the folder from which he wants to execute the program with runDir. The locationof the executable is also managed with exelocation.

api parameter must be ExtAPI.

Exampleimport ansysansys.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 Projectpage.

Location

libaries/Mechanical/wbjn.pylibraries/Project/wbjn.py

Usage

import wbjn

145Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Journaling Helper

Page 154: ANSYS ACT Developers Guide

FunctionsExecuteCommand(api,cmd,**args)

This function executes a journal command specified by cmd You can get a result object by using thefunction returnValue(obj) in your journal command. All arguments must implement the serializationinterface provided by .Net. The object sent to the function returnValue(obj) must also implementthe serialization interface. This interface is already implemented for many standard types of data (integer,double, list…). Please note that the standard Python dictionary does not implement this interface bydefault. If a dictionary is required, use the SerializableDictionary class provided by ACT.

api parameter must be ExtAPI.

ExecuteFile(api,file,**args)

The same as above but executes a journal file specified by file.

Examples

This command:

import wbjn

wbjn.ExecuteCommand(ExtAPI,"returnValue(a+b)",a=2,b=3)

returns the following result:

5

This command:

import wbjn

wbjn.ExecuteCommand(ExtAPI,"returnValue(a+GetAllSystems()[0].DisplayText+b)",a="My first system is: ",b=" !")

returns the following result:

My first system is: Static Structural !

This command:

import wbjn

dict = SerializableDictionary[str,int]()

dict.Add("e1",1)

dict.Add("e2",2)

wbjn.ExecuteCommand(ExtAPI,'returnValue(d["e1"]+d["e2"])', d=dict)

returns the following result:

3

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.146

Associated Libraries

Page 155: ANSYS ACT Developers Guide

XML Extension Definition

ACT supports application customization using a combination of Python and XML formatted specificationdata. The XML file aims at describing the content of the extension.

This chapter focuses on the details of the XML tags and its relation to the application to be customized.

The HTML version of the ACT Reference Guide available from the ANSYS Customer Portal provides inform-ation similar to that presented in this chapter. The ACT Reference Guide allows interactive navigationthrough the different elements of the extension XML file.

The extension XML file contains an <extension> XML element, which provides the information neededfor initialization and for the extension configuration. The XML file is comprised of the following mainparts:

• The <guid> element specifies a unique identifier for the extension.

• The <script> element specifies the Python script that defines the functions called by the extension.

• The <interface> element specifies the customization to be done at the GUI level.

• The <workflow> element defines a custom ACT workflow.

• The <simdata> element specifies the custom features to be integrated in the application.

Note

The content of the XML file is case-sensitive.

<extension> Element

This represents the "root" element, or base tag, that all other tags/elements fall under.

The <extension> element contains the <guid>, <script>, <interface>, <workflow>, and<simdata> elements.

<extension version="[version number]" minorversion="[minor version number]" name="[extension name]"> <author>author name</author> <description>description of the extension</description> <assembly src="[source file name (string)]" namespace="[namespace (string)]"/></extension>

Mandatory attributesversion="[version number (integer)]" name="[extension name (string)]"

147Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 156: ANSYS ACT Developers Guide

Optional attributesminorversion="[minor version number (integer)]"

<GUID> Element

The GUID element allows a unique identification for the extension.

<extension version="[version id (integer)]" name="[extension name (string)]"

<guid shortid="[name (string)]">GUID</guid> </extension>

Mandatory attributes

GUID

Optional attribute

shortid="[name]"

The GUID must remain the same along the evolutions of the extension, independently of the extensionversion or name. It is used to uniquely identify an extension. The shortId attribute is needed forcompatibility with old projects. The shortId attribute provides backwards compatibility for extensionswhich were developed before the GUID element was available.

<script> Element

<extension version="[version id (integer)]" name="[extension name (string)]" <script src="[python file name (string)]"></script></extension>

You can either insert the IronPython script directly into the XML file, or use the src attribute to specifythe path to the script.

Additional paths can be specified by adding new <script> elements.

<script src="[Path]\filename.py" />

If the src attribute is defined, then the tag content is ignored.

Optional attribute

src="[file name.py]"

By default, ACT looks for IronPython scripts in the same directory as the extension. If the scripts are notlocated in that directory, you can specify the path the scripts in addition to the file name.

For example:

<script src="my_path\main.py" />

<interface> Element

The <interface> element and its child elements define GUI elements, including custom toolbars.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.148

XML Extension Definition

Page 157: ANSYS ACT Developers Guide

<extension version="[version id (integer)]" name="[extension name (string)]" <interface context="[Project | Mechanical]"> ... </interface>

The interface element information pertains specifically to the GUI. The available elements underthe <interface> tag are presented in the next sections.

Optional attribute

context="[context name]”

The context specifies the application for which the interface element applies. At the moment, thesupported contexts are Project, Mechanical, DesignModeler and DesignXplorer.

If no context is specified, then the interface element applies to all the available applications for ACT.

<images> Element

<interface context="[Project | Mechanical]">

<images>[folder]</images> ... </interface>

The appropriate folder in which the images to be integrated by the extension have been stored.

By default, ACT looks for images in the same directory as the extension. If images for the extensionhave been stored in a subdirectory of the main extension directory called images, the following defin-ition is appropriate. This is the most common situation:

<images>images</images>

<callbacks> Element

This section applies to the ANSYS Mechanical application only.

<interface context="[Project | Mechanical | ASim]">

<!-- Interface level callbacks --> <callbacks> <oninit>[function(context)]</oninit> <onterminate>[function(context)]</onterminate> <onload>[function(currentFolder)]</onload> <onsave>[function(currentFolder)]</onsave> <resume>[function(binary reader)]</resume> <save>[function(binary writer)]</save> <onbeforesolve>[function(analysis)]</onbeforesolve> <onaftersolve>[function(analysis)]</onaftersolve> <isanalysisvalid>[function(analysis,firstCheck)] </isanalysisvalid> <ondraw2d>[function()]</ondraw2d> <getprecommands> [function(analysis,stream)]</getprecommands> <getsolvecommands timedependent="[true | false(default)]"> [function(analysis,stream)]</getsolvecommands> <getpostcommands>[function(analysis,stream)] </getpostcommands> <onactiveobjectchange>[function(analysis)]</onactiveobjectchange> <onpoststarted>[function(analysis)]</onpoststarted> <onpostfinished>[function(analysis)]</onpostfinished> </callbacks> ... </interface>

149Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 158: ANSYS ACT Developers Guide

The callbacks element and its children specify the Python functions that are invoked based on systemand user-generated events. The callbacks children are described below:

<oninit>[function name(application context)] </oninit>

The oninit element specifies the name of the IronPython function called when the GUI is initialized.The declaration of the called function must be:

def function_name(context):

The context argument contains the name of the application as defined by the context attribute ofthe <interface> element.

<onterminate>[function name(application context)]</onterminate>

The onterminate element specifies the name of the IronPython function called when the applicationcontext is stopped. The declaration of the called function must be:

def function_name(context):

The context argument contains the name of the application as defined by the context attribute ofthe <interface> element.

<onload>[function name(Folder)]</onload>

The onload element specifies the name of the IronPython function called when the project is openedby the application. The declaration of the called function must be:

def function_name(folder):

The input argument folder defines the folder path of the project.

<onsave>[function name(Folder)]</onsave>

The onsave element specifies the name of the IronPython function called when the project is savedby the application. The declaration of the called function must be:

def function_name(folder):

The input argument folder defines the folder path of the project.

<resume>[function(binary reader)]</resume>

The resume element specifies the name of the IronPython function called when the project is openedby the application. The declaration of the called function must be:

def function_name(binary_reader):

The input argument binary_reader defines the reader to be used to get data previously stored bythe resume element. in this case, data are retrieved directly from the standard database of the application(see the save element description below).

<save>[function(binary writer)]</save>

The save element specifies the name of the IronPython function called when the project is saved bythe application. The declaration of the called function must be:

def function_name(binary_writer):

The input argument binary_writer defines the writer to be used to store data. In this case, dataare stored in the standard database of the current application. No new external files are created to storethe specific data related to the extension.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.150

XML Extension Definition

Page 159: ANSYS ACT Developers Guide

<onbeforesolve>[function name(analysis)] </onbeforesolve>

The onbeforesolve element specifies the name of the IronPython function called when the solve of ananalysis starts. The declaration of the called function must be:

def function_name(analysis):

The input argument analysis defines the current analysis. If the solve request invokes the resolutionof multiple analysis then this callback will be called for each analysis.

<onaftersolve>[function name(analysis)]</onaftersolve>

The onaftersolve element specifies the name of the IronPython function called when the solve ofan analysis is complete. The declaration of the called function must be:

def function_name(analysis):

The input argument analysis defines the current analysis.

<isanalysisvalid>[function name(analysis,firstCheck)] </isanalysisvalid>

The isanalysisvalid element specifies the name of the IronPython function called when Mechan-ical retrieves the status of the analysis. The declaration of the called function must be:

def function_name(analysis,firstCheck):

The input argument analysis defines the current analysis to check.

The input argument firstCheck indicates if Mechanical calls this function before or after the standardvalidation. Mechanical will call this function with firstCheck set to True before the standard checkand will call a second time this function with firstCheck set to False after.

This function must return an integer value equal to -1, 0 or 1.

-1 indicates you do not want to check anything here, 0 means that the analysis definition is not yetvalid, and 1 means that the analysis is ready to be solved. If the returned value is not equal to -1 andfirstCheck is equal to True, then the standard check performed by Mechanical is skipped.

<ondraw2d>[function name()] </ondraw2d>

The ondraw2d element specifies the name of the IronPython function called each time the graphicsview of Mechanical is refreshed. This function can be used to draw 2D objects such as labels associatedwith a node. The declaration of the called function must be:

def function_name():

<getprecommands> [function(analysis,stream)]</getprecommands>

The getprecommands element specifies the name of the IronPython function called when Mechanicalwrites the solver input file. This function allows you to add input solver commands in the stream. Thecommands added to this stream are located just after the mesh definition.

<getsolvecommands>[function(analysis,stream)]</getsolvecommands>

The getsolvecommands element specifies the name of the IronPython function called when Mech-anical writes the first load step in the solver input file. Like the getprecommands element, this functionallows you to add input solver commands in the stream. The commands added to the stream are locatedjust after the definition of the first load step.

<getpostcommands> [function(analysis,stream)]</getpostcommands>

151Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 160: ANSYS ACT Developers Guide

The getpostcommands element specifies the name of the IronPython function called when Mechan-ical writes the solver input file. Like the getprecommands element, this function allows you to addinput solver commands in the stream. The commands added to the stream are located just after thefirst occurrence of the solve command.

<onactiveobjectchange>[function(object,location)]</onactiveobjectchange>

The onactiveobjectchange element specifies the name of the IronPython function called whenthe active object has been changed.

<onpoststarted>[function name(analysis)]</onpoststarted>

The onpoststarted element specifies the name of the IronPython function called when the post-processing of an analysis starts. The declaration of the called function must be:

def function_name(analysis):

The input argument analysis defines the current analysis.

<onpostfinished>[function name(analysis)]</onpostfinished>

The onpostfinished element specifies the name of the IronPython function called when the post-processing of an analysis is complete. The declaration of the called function must be:

def function_name(analysis):

The input argument analysis defines the current analysis.

<toolbar> Element

<extension version="[version id (integer)]"

name="[extension name (string)]"

<!-- Toolbar definition -->

<toolbar name="[toolbar internal name (string)]" caption="[toolbar display name (string)]">

<!--Toolbar button definition -->

<entry name="[toolbar button internal name (string)]" caption="[caption name (string)]" icon="[name of an image located in images folders (string)]" userobject="[object name (string)]">

<callbacks>

<!-- Declaration of callback for toolbar button activation -->

<onclick>[function()]</onclick>

</callbacks>

</entry>

...

</toolbar>

</extension>

The toolbar element supports two attribute nodes: name and caption. They are described below inthe following sections.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.152

XML Extension Definition

Page 161: ANSYS ACT Developers Guide

Mandatory attributes

The value of the name attribute specifies the name used by the applicationto reference this toolbar.

name

The value of the caption attribute specifies the name displayed in theGUI for toolbar.

caption

Child Elements

The toolbar element supports one or more entry child elements. Each entry element spawns thecreation of a toolbar button. An entry element supports an onclick callback, which specifies thename of the IronPython function called when the user clicks on the button. The entry element for atoolbar button is defined as follows:

<toolbar name="[toolbar internal name (string)]" caption="[toolbar display name (string)]">

<!--Toolbar button definition -->

<entry name="[toolbar button internal name (string)]" caption="[caption name (string)]" icon="[name of an image located in images folders (string)]" userobject="[object name (string)]">

<callbacks>

<!-- Declaration of callback for toolbar button activation -->

<onclick>[function()]</onclick>

</callbacks>

</entry>

...

</toolbar>

Mandatory attribute

The name attribute specifies the name used by the context application toreference this toolbar button.

name

Optional attributes

The value of the caption attribute specifies the caption to be displayed when themouse is hovered over this toolbar button.

caption

The value of the icon attribute specifies the file name of the icon displayed inthe GUI for this toolbar button, without the file extension. (An icon is a 16x16 pixel

icon

image in BMP, JPG, or GIF format.) This file has to be stored in one of the folderspreviously defined in the <images> elements.

The name of the object to be connected with the entry.userobject

When the userobject attribute is used, the onclick callback is ignored. Depending on the natureof the object (load, result, general), the button associated with the entry will be activated or deactivated

153Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 162: ANSYS ACT Developers Guide

depending on the current active object in the tree of the application. For example, a load object willnot be available from the toolbar when the current active object in the tree is a result object under thesolution folder in Mechanical. This process allows context dependent behavior in the ACT toolbar.

You can create an entry inside another entry to define a drop-down menu.

<workflow> Element

The workflow element defines a custom ACT workflow.

<workflow context="Project"> <tasks> <task> </task> </tasks> <taskgroups> <taskgroup> </taskgroup> </taskgroups> </workflow>

Mandatory attributes

context

Specifies the context to which the custom workflow applies. Acceptable values: Project.

<tasks> Element

The tasks element is the top-level entry containing all task definitions.

<tasks> <task name="" caption="" icon="" version="1"> ... </task> </tasks>

<task> Element

The task element defines a single task within a workflow. A task captures one application, process, orlogic step.

<task name="" caption="" icon="" version="1"> <callbacks> </callbacks> <contextmenus> </contextmenus> <propertygroup name="" caption=""> </propertygroup> <property/> <parameters> </parameters> <inputs> </inputs> <outputs> </outputs> </task>

Mandatory attributes

name

Specifies the task name. Acceptable values: any valid string.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.154

XML Extension Definition

Page 163: ANSYS ACT Developers Guide

version

Specifies the task's version number.

Optional attributes

caption

Specifies the task display text. If not supplied, name will be used. Acceptable values: any valid string.

icon

Specifies the image displayed with the task. In the Workbench Project Schematic, this is the icon dis-played on the left of a cell block. Acceptable values: a filename of a 16x16 pixel image of the .pngformat.

<callbacks> Element

The callbacks element specifies the functions defined by the user's Python code. The callbacks aredescribed below:

<callbacks> <onupdate></onupdate> <onrefresh></onrefresh> <oninitialize></oninitialize> <onedit></onedit> <onreset></onreset> <onstatus></onstatus> <onreport></onreport> </callbacks>

onupdate

Called when the user updates the task.

onrefresh

Called when the user refreshes the task.

oninitialize

Called when the task is created.

onedit

Called when the user edits the task. By declaring this callback, ACT will automatically expose a defaultEdit context menu for this task.

onreset

Called when the user resets the task.

onstatus

Called when the application (e.g. Workbench) asks the task for its current state.

onreport

Called when the user generates a project report. This allows the task to access the report object andadd its own task-specific reporting content.

155Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 164: ANSYS ACT Developers Guide

<contextsmenus> Element

The contextmenus element specifies the user-defined context menus to expose on this task. Notethat you can receive an Edit context menu for free by supplying a Python method for the <onedit>callback.

<contextmenus> <entry name="" caption="" icon="" version="1" priority="" type=""> <callbacks> <onclick></onclick> </callbacks> </entry> </contextmenus>

<entry> Element

The entry element specifies the context menu entry.

Mandatory attributes

name

Specifies the entry name. Acceptable values: any valid string.

version

Specifies the context menu version number. Acceptable values: an integer string.

Optional attributes

caption

Specifies the entry display name. If not supplied, name will be used. Acceptable values: any valid string.

icon

Specifies the icon associated with the context menu entry. Acceptable values: a filename of a 16x16pixel image of the .png format.

priority

Specifies the context menu priority. Indicates where the entry should be placed when other entries arespecified for the same menu. Lower numbers appear at the top of the menu. You can specify groupsby using decimals to indicate {group}.{order}. Acceptable values: a float string.

type

Specifies the entry type. Acceptable values: ContextMenuEntry .

<callbacks> Element

The callbacks element specifies the callbacks defined on the context menu entry.

onclick

Called when the user invokes the context menu entry.

<propertygroup> Element

The propertygroup element specifies a group of properties. In the Workbench Project Schematic,this exposes a new group in the property view to better organize multiple properties.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.156

XML Extension Definition

Page 165: ANSYS ACT Developers Guide

<propertygroup name="" caption=""> <property name="" caption="" control="" default="" readonly="" needupdate="" visible="" persistent="" parameterizable="" keytype="" valuetype="" elementtype=""/> </propertygroup>

Mandatory attributes

name

Specifies the property group name. Acceptable values: any valid string.

Optional attributes

caption

Specifies the property group display name. If not supplied, name will be used. Acceptable values: anyvalid string.

<property> Element

The property element defines a piece of data to be stored within a task.

<property name="" caption="" control="" default="" readonly="" needupdate="" visible="" persistent="" parameterizable="" keytype="" valuetype="" elementtype=""/>

Mandatory attributes

name

Specifies the property name. Acceptable values: any valid string.

control

Specifies the property control type. Acceptable values: string, double, integer, datareference,boolean, object, quantity, option, list, dictionary, datacontainerreference.

version

Specifies the property version number. Acceptable values: any valid string.

Optional attributes

caption

Specifies the property display text. If not supplied, name will be used. Acceptable values: any validstring.

default

Specifies the property default value (the initial value). Acceptable values: any valid type-based string.

readonly

Indicates whether the property is an outuput (not editable by the user). Acceptable values: true orfalse.

needupdate

Indicates if the property is an input and forcing a state change if the property value is modified. Accept-able values: true or false.

visible

Indicates if the property should be user-visible in the application. Acceptable values: true or false.

157Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 166: ANSYS ACT Developers Guide

persistent

Indicates whether the property value should be saved with the project. Use this attribute if you wantto keep data on your task (e.g. display to the user) but not store it in the project file. Acceptable values:true or false.

parameterizable

Indicates whether the property should be a candidate for parameterization. In Workbench, a true valuewill result in a check box displayed to the right of the property to allow users to promote the propertyas a Workbench parameter. Acceptable values: true or false.

keytype

The key type of a key-value pair for a property whose control attribute is set to dictionary. Acceptablevalues: see control. (Nested collections are not supported at 16.2)

valuetype

The value type of a key-value pair for a property whose control attribute is set to dictionary. Acceptablevalues: see control. (Nested collections are not supported at 16.2)

elementtype

The element type of a key-value pair for a property whose control attribute is set to dictionary. Ac-ceptable values: see control. (Nested collections are not supported at 16.2)

<parameters> Element

The parameters element defines the parameters to be exposed by this task.

<parameters> <parameter name="" caption="" usage="" control="" version="1"/> </parameters>

<parameter> Element

The parameter element specifies the parameter value for this task. In Workbench, a parameter will beautomatically created for this entry. This will not be associated with a displayed data property.

Mandatory attributes

name

Specifies the parameter name. Acceptable values: any valid string.

usage

Specifies whether the parameter is an input or output. Acceptable values: input or output.

control

Specifies the parameter data type.Acceptable values: Acceptable values: Double, Float, Long,Quantity.

Optional attributes

caption

Specifies the parameter display text. If not supplied, name will be used. Acceptable values: any validstring.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.158

XML Extension Definition

Page 167: ANSYS ACT Developers Guide

version

Specifies the parameter version number. Acceptable values: any valid integer string.

<inputs> Element

The inputs element defines the task inputs for consuming upstream connections.

<inputs> <input/> <input type="" format=""/> </inputs>

<input> Element

The input element defines an input for this task.

Optional attributes

type

Specifies the data type string representing the data desired for input to this task. Acceptable values:any valid string.

format

Specifies the format of data desired for input to this task. More specific than type (and always specifiedwith a corresponding type), this value provides an additional specification for formatting the requestedinput data type. In Workbench, for example, you could specify a type as MeshingMesh and the formatas FluentMesh. The former indicates you want to consume a mesh. The latter provides the additionaldetail that the mesh should be in the .msh fluent format. Acceptable values: any valid string.

<outputs> Element

The outputs element defines the task outputs for providing downstream connections.

<outputs> <output type="" format=""/> </outputs>

<output> Element

Optional attributes

type

Specifies the data type string representing the data exposed and generated by this task. Acceptablevalues: any valid string.

format

Specifies the format of data generated by this task. More commonly used on an input specification thanan output. Acceptable values: Any valid string.

<taskgroups> Element

The taskgroups element is the top-level entry containing the groups of tasks defined in this workflow.

<taskgroups> <taskgroup name="" caption="" icon="" category="" abbreviation="" version="1" isparametricgroup="False"> <includetask name=""/>

159Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 168: ANSYS ACT Developers Guide

<includeGroup name=""/> </taskgroup> </taskgroups>

<taskgroup> Element

The taskgroup element defines a collection of tasks and taskgroups into one single unit.

Mandatory attributes

name

Specifies the taskgroup name. Acceptable values: any valid string.

version

Specifies the taskgroup version. Acceptable values: any valid string.

Optional attributes

caption

Specifies the taskgroup display text. If not supplied, name will be used. Acceptable values: any validstring.

icon

Specifies the icon associated with the taskgroup. Acceptable values: a filename of a 16x16 pixel imageof the .png format.

category

Specifies the taskgroup category. Use this value to group taskgroups into a general division. In Work-bench, this defines the toolbox group into which your taskgroup will appear. Acceptable values: anyvalid string.

abbreviation

Specifies the taskgroup abbreviation. In Workbench, this value determines the unique taskgroup directoryinto which taskgroup information can be stored. Acceptable values: any valid string.

isparametricgroup

Indicates whether the taskgroup works only on parameters. In Workbench, this value determineswhether or not the group will appear below the Parameter Set bar. Acceptable values: true or false.

<includetask>

The includetask element specifies the task to include in the taskgroup.

Mandatory attributes

name

Specifies the task name. Acceptable values: any valid string.

<includegroup>

The includegroup element specifies the group to include in the taskgroup.

Mandatory attributes

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.160

XML Extension Definition

Page 169: ANSYS ACT Developers Guide

name

Specifies the taskgroup name. Acceptable values: any valid string.

<simdata> Element

The <simdata> element information pertains specifically to the simulation environment. Three childelements are used for integrating custom loads, custom results and third party solvers into the application.These three main features are nested as child elements within the <simdata> element.

<extension version="[version id (integer)]"

name="[extension name (string)]"

<simdata context="[Project | Mechanical | DesignXplorer]">

<load> ... </load>

<object> ... </object>

<result> ... </result>

<solver> ... </solver>

</simdata>

</extension>

Optional attribute

context="[context name]”

The context specifies the application to which the interface element applies.

If no context is specified, then the interface element applies to all the available applications forthe ACT.

<load> Element

The <load> element and its children allow you to configure the properties of a custom load and specifythe IronPython functions that are invoked based on system and user-generated events. The <load>element supports eight attribute nodes. These are name, version, caption, icon, issupport,isload, color and solveorder. These are defined inside the load element as described below:

<simdata context="[Project | Mechanical]">

<load name="[load internal name]"

version="[version identifier of the load]"

caption="[load display name]"

icon="[name of an icon file]"

issupport="[true | false]"

isload="[true | false]"

color="[#xxxxxx]"

contextual="[true(default) | false]"

161Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 170: ANSYS ACT Developers Guide

class="[class name]"

unit="[Default unit name]"

...

</load>

</simdata>

The element has two child elements: the callbacks element and the property element. These twoelements and their children are presented in the next two sections.

Mandatory attributes

The value of the name attribute specifies the name used by the applicationto reference this load.

name

The value of the version attribute allows the load author to attach aversion number to this load.

version

The value of the caption attribute specifies the name displayed in theGUI for this load.

caption

The value of the icon attribute specifies the file name of the icondisplayed in the GUI for this toolbar button, without the file extension.

icon

(An icon is a 16x16 pixel image in BMP, JPG, or GIF format.) This file hasto be stored in one of the folders previously defined in the <images>elements.

Optional attributes

The value of the issupport attribute specifies that this load has to beinterpreted as a boundary condition.

issupport

The value of the isload attribute specifies that this load has to beinterpreted as a load.

isload

The value of the color attribute specifies the color to be used whenscoped geometry is displayed. Color is defined by a six-digit hexadecimal

color

number. This number consists of three two-digit numbers correspondingto red, green and blue (RGB) values.

#XXxxxx = red

#xxXXxx = green

#xxxxXX = blue

If true, the load can be added directly from the Insert context menu onthe load object.

contextual

Class name to be linked with the load.class

Default unit to be used for contour display (if needed).unit

<callbacks> Element

<load name="[load internal name (string)]"

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.162

XML Extension Definition

Page 171: ANSYS ACT Developers Guide

version="[version identifier of the load (integer)]"

caption="[load display name (string)]"

icon="[name of an image located in images folders (string)]"

issupport="[true | false]"

isload="[true | false]"

color="[#xxxxxx]" >

<callbacks>

<onmigrate>[function(newLoad,oldLoad)]</onmigrate>

<onshow>[function(load)]</onshow>

<onhide>[function(load)]</onhide>

<oninit>[function(load)]</oninit>

<onadd>[function(load)]</onadd>

<onremove>[function(load)]</onremove>

<onsuppress>[function(load)]</onsuppress>

<onunsuppress>[function(load)]</onunsuppress>

<getcommands>[function(load,solverdata,stream)]</getcommands>

<getprecommands order="[(integer)]">[function(load,stream)]</getprecommands>

<getsolvecommands order="[(integer)]" timedependent="[true | false(default)]> [function(load [,step],stream)]</getsolvecommands>

<getpostcommands order="[(integer)]">[function(load,stream)] </getpostcommands>

<getnodalvaluesfordisplay>[values=function(load,nodeIds)]</getnodalvaluesfordisplay>

<canadd>[function(analysis,loadName)]</canadd>

<onduplicate>[function(load)]</onduplicate>

<canduplicate>[function(load,parent object)]</canduplicate>

<canremove>[function(load)]</canremove>

<action name="[(string)]" caption="[(string)]" icon="[(string)]"> [function(load)]</action>

<ongenerate>[function(load,fct)]</ongenerate>

<onaftergenerate>[function(load)]</onaftergenerate>

<oncleardata>[function(load)]</oncleardata>

<isvalid>[function(load)]</isvalid>

</callbacks>

</load>

The <callbacks> element and its children enable you to specify the Python functions that are invokedbased on system and user-generated events related to the load behavior. The callbacks children aredescribed below:

<onmigrate>[function(new_load,old_load)] </onmigrate>

163Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 172: ANSYS ACT Developers Guide

The onmigrate element specifies the name of the IronPython function called when Mechanical loadsthe ACT customized load. This function allows you to maintain the extension from one version numberto another. The function is called if the current version of the load is greater than the last saved version.

<onshow>[function(load)]</onshow>

The onshow element specifies the name of the IronPython function called when the load is selectedin the tree. This function is used to display customized graphical information associated with this load.

<onhide>[function(load)]</onhide>

The onhide element specifies the name of the IronPython function called when the load switchesfrom a visible status to a hidden status. This event is called when the ACT object is unselected.

<oninit>[function(load)]</oninit>

The oninit element specifies the name of the IronPython function called when the load is created.

<onadd>[function(load)]</onadd>

The onadd element specifies the name of the IronPython function called when the load is added. Thisevent is called when the ACT object is added to the project.

<onremove>[function(load)]</onremove>

The onremove element specifies the name of the IronPython function called when the load is deleted.This event is called when the ACT object is deleted from the project.

<onsuppress>[function(load)]</onsuppress>

The onsuppress element specifies the name of the IronPython function called when the load switchesfrom an active state to a suppressed state. This event is called when the ACT object is suppressed.

<onunsuppress>[function(load)]</onunsuppress>

The onunsuppress element specifies the name of the IronPython function called when the loadswitches from a suppressed state to an active state. This event is called when the ACT object is unsup-pressed.

<getcommands location = [string] order = [integer]>[function(load,solverdata,stream)]</getcommands>

The getcommands element specifies the name of the IronPython function called when Mechanicalwrites the solver input file.

The callback named getcommands replaces the three callbacks getprecommands, getsolvecom-mands, and getpostcommands when the ANSYS solver is used.

When another solver other than the ANSYS solver is used, the getcommands callback is unavailable.In such a case, the getprecommands, getsolvecommands, and getpostcommands callbacksmust be used.

The solverdata structure is associated to the getcommands callback. The solverdata structureprovides access to a set of data from the current model at the IronPython level. The solverdatastructure is useful when the solver commands to be generated by the extension need to add entitiesin the model such as nodes or elements. Through the solverdata structure, ACT provides an efficientmethod to manage the newly created IDs of these entities with the existing IDs previously generatedby the solver. Without the solverdata structure, the APDL command *GET must be used extensivelyto determine the maximum ID before creating new entities.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.164

XML Extension Definition

Page 173: ANSYS ACT Developers Guide

<getprecommands order = [integer]> [function(load,stream)]</getprecommands>

The getprecommands element specifies the name of the IronPython function called when Mechanicalwrites the solver input file. This function allows you to add input solver commands in the stream. Thecommands added to the stream are located just after the definition of the mesh. The order attributeindicates the priority given to the generation of the solver commands in comparison to the other ACTloads. Low order gives a high priority to the commands to be written. For command blocks with a sameorder, the priority is given to the first object as defined in the tree of the application. By default, anorder equal to one is used.

The commands added to the stream are located at the location specified in the location attribute.

Possible values for the location attribute are:

preCommands are written at the end of the pre-treatment section (before entering into the /SOLU module).

preloadCommands are written before the first standard load definition.

solveCommands are before the solve command and after all the standard loads have been defined.

postCommands are written after the solve command.

The attribute order is used to define the priority of the command generation when the function iscalled several times for one given location.

The second argument solverdata refers to the object that contains the model for the current analysis.

The solverdata type is ISolverData and contains the following fields:

MaxElementIdCurrent maximum element ID on the model.

MaxNodeIdCurrent maximum node ID on the model.

MaxElementTypeCurrent maximum element type ID on the model.

CurrentStepCurrent step number.

The methods available with the properties of solverdata are:

GetNewElementIdGenerate a new element ID and increment the MaxElementId property by one.

GetNewNodeIdGenerate a new node ID and increment the MaxNodeId property by one.

GetNewElementTypeGenerate a new element type ID and increment the MaxElementType property by one.

165Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 174: ANSYS ACT Developers Guide

GetCoordinateSystemSolverIdGet the corresponding coordinate system solver ID for a given ID defining a coordinate system object inthe application.

GetMaterialSolverIdGet the corresponding material solver ID for a given body ID.

GetRemotePointNodeIdGet the corresponding node ID for a given remote point.

GetContactIdGet the solver contact ID.

GetContactTargetIdGet the target ID for a given contact.

GetSolveTypeGet the type of solve in the case of multiple solves in one analysis.

To add elements to the solver input file, call the method GetNewElementId in order to get a newvalue element ID and update the internal solver IDs. If the solver writes additional elements after theACT commands, these elements will have the expected IDs.

The third argument stream refers to the solver input file.

<getsolvecommands order = [integer] timedependent = “true”>[function(load,step,stream)] </getsolvecommands>

or

<getsolvecommands order = [integer] timedependent = “false”>[function(load,stream)] </getsolvecommands>

The getsolvecommands element specifies the name of the IronPython function called when Mech-anical writes the solver input file. The commands added to the stream are located just after the definitionof the standard loads for the step number step if the attribute timedependent is set to True or justafter the first step if timedependent is set to False. Please refer to the getprecommands callbackfor information on the order attribute.

Note

The argument step is expected only when the attribute timedependent is set to true.

<getpostcommands order = [integer]> [function(load,stream)]</getpostcom-mands>

The getpostcommands element specifies the name of the IronPython function called when Mechan-ical writes the solver input file. Commands added to the stream are located just after the solve command.

Please refer to the getprecommands callback for information on the order attribute.

<getnodalvaluesfordisplay> [values=function(load,nodeIds)] </getnodalval-uesfordisplay>

The getnodalvaluesfordisplay element specifies the name of the IronPython function calledprior to the display of the load. The user specifies the active load and an array of node ids. The functionmust return an array containing one value per node. This output array needs to be consistent in terms

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.166

XML Extension Definition

Page 175: ANSYS ACT Developers Guide

of sequential storage with the input nodeIds. The ith value of the output will refer to the ith nodenumber from nodeIds. These values are displayed in Mechanical on the model (for example, a spatialdependent thermal load).

<canadd>[function(analysis,loadName)]</canadd>

The canadd element specifies the name of the IronPython function called when Mechanical checksthe availability of the load for the current analysis. The function takes two arguments: the current ana-lysis and the name of the load to be checked. This function must return True or False.

<onduplicate>[function(load)]</onduplicate>

The onduplicate element specifies the name of the IronPython function called when Mechanicalduplicates the load object.

<canduplicate>[function(load,parent_object)]</canduplicate>

The canduplicate element specifies the name of the IronPython function called when Mechanicalchecks if the load object can be duplicated depending on the current selected parent object in thetree.

<canremove>[function(load)]</canremove>

The canremove element specifies the name of the IronPython function called when Mechanical checksif the load object can be removed.

<action name="[(string)]" caption="[(string)]" icon="[(string)]"function(load)/action>

The action element specifies a new context menu option that will be available on the load object. Thename attribute defines the name of the action, the caption attribute defines the text displayed on thecontext menu, and the icon attribute defines the name of the image to display on the context menu.

<ongenerate>state=[function(load,fct)]</ongenerate>

The ongenerate element specifies the name of the IronPython function called when the load mustbe evaluated. The function takes two arguments: the load object and a function to manage the progressbar. This function must return True or False: True if the evaluation ended correctly, False otherwise.

<onaftergenerate>[function(load)]</onaftergenerate>

The onaftergenerate element specifies the name of the IronPython function called when thegenerate callback is complete.

<oncleardata>[function(load)]</oncleardata>

The oncleardata element specifies the name of the IronPython function called when the load needto be cleared. The function takes one argument: the load object. This function is called each time themesh is cleaned and when the user clicks on the Clear Generated Data context menu option.

<isvalid>[function(load)]</isvalid>

The isvalid element specifies the name of the IronPython function called when Mechanical checksthe validity of the load object.

<property> Element

The property element and its children define the properties required for this load. Through thisdefinition, these properties appear in the details view of the application's Details pane.

167Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 176: ANSYS ACT Developers Guide

<load name="[load internal name (string)]"

version="[version identifier of the load (integer)]"

caption="[load display name (string)]"

icon="[name of an image located in images folders (string)]"

issupport="[true | false]"

isload="[true | false]"

color="[#xxxxxx]" >

<property name="[property internal name (string)]"

caption="[property display name (string)]"

unit="[string]"

readonly="[true | false(default)]"

default="[default value]"

control="[text(default) | select | float | integer | custom | applycancel | [template name (string)]]"

visible="[true(default) | false]"

visibleon="[values (separator '|')]"

class="[class name]"

needupdate="[true(default) | false]">

</property>

</load>

Mandatory attributes

The value of the name attribute specifies the name usedby the context application to reference this property.

name

The value of the caption attribute specifies the namedisplayed in the GUI for this property.

caption

Optional attributes

The value of the unit attribute specifies the physical quantity to whichthe result refers (for example, Length or Mass. See the ANSYS WorkbenchUser's Guide for details).

unit

The value of the readonly attribute specifies that this property isread-only. The supported values for this attribute are [true | false].

readonly

The value of the default attribute specifies the default value to use forthis property on initialization.

default

This option indicates whether the property is visible in the detail viewwindow. The visible option can be used to show or hide a propertydepending on another property value.

visible

The value of the control attribute specifies the type of UI control touse in the details view for this property.

control

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.168

XML Extension Definition

Page 177: ANSYS ACT Developers Guide

• The text control activates a text area in which the user defines input data.

• The select control activates a drop-down menu that contains a list ofavailable definitions.

• The applycancelcontrol activates an Apply/Cancel button based on oneuser-defined selection. This control is the most generic control type that canbe used with callbacks to integrate a variety of scenarios.

• The template name: All pre-defined templates can be used as control type.The following templates are available: scoping, component_selection,geometry_selection, fileopen, entity_selection andcoordinatesystem_selection. Look at the file controltemplates.xmlin folder templates for more details on each template.

The attribute is valid only if the property is a child of a propertygroup..

visibleon

To define all the callbacks related to a property, you can create a class inPython where each defined function matches the name of a callback. Inthis case the class attribute must contain the name of this class.

class

If this attribute is equal to true, each time the user change the value ofthe property, solution will be invalidated. If this attribute is equal to false,any change will not impact the status of the solution.

needupdate

<callbacks> Element

<property name="[property internal name (string)]"

caption="[property display name (string)]"

datatype="[string | int | double | string[] | int[] | double[] | undef]"

unit="[string]"

readonly="[true | false(default)]"

default="[default value]"

control="[scoping | text(default) | select | tabular | custom | applycancel | file]">

<callbacks class="[class name that implement a sub set of callbacks]">

<onmigrate>[function(new property,old property)]</onmigrate>

<onactivate>[function(load,property)]</onactivate>

<onvalidate>[function(load,property)]</onvalidate>

<isvalid>[isvalid=function(load,property)]</isvalid>

<isvisible>[isvalid=function(load,property)] </isvisible>

<onapply>[function(load,property)]</onapply>

<oncancel>[function(load,property)]</oncancel>

<string2value>[value=function(load,property,string)] </string2value>

<value2string>[string=function(load,property,value)] </value2string>

169Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 178: ANSYS ACT Developers Guide

<getvalue>[value=function(load,property,value)]</getvalue>

<oninit>[function(load,property)]</oninit>

<onshow>[function(load,property)]</onshow>

<onhide>[function(load,property)]</onhide>

<onadd>[function(load,property)]</onadd>

<onduplicate>[function(load,property)]</onduplicate>

<onremove>[function(load,property)]</onremove>

<setvalue>[function(load,property)]<setvalue>

</callbacks>

</property>

The <callbacks> element and its children provide the means to specify the Python functions thatare invoked based on system and user-generated events related to load properties behavior. The callbackschildren are described below:

<onmigrate>[function(new_prop,old_prop)] </onactivate>

The onmigrate element specifies the name of the IronPython function called when Mechanical loadsthe ACT customized load. This function allows you to maintain the properties related to the load fromone version number to another one. The function is called if the current version of the load is greaterthan the last saved version. The new_prop argument contains the definition of the property as definedin the XML file and old_prop contains the definition of the load previously saved in the project. Withthis function, you can convert legacy data read from the project file to the new property initialized bythe updated XML file.

<onactivate>[function(load,property)]</onactivate>

The onactivate element specifies the name of the IronPython function called when the user selectsa load property in the details view. This callback is typically used to fill the options of a property whenthe type select (ie. combo box) is used. The load and property are given as arguments.

<onvalidate>[function(load,property)]</onvalidate>

The onvalidate element specifies the name of the IronPython function called when you change thevalue of a load property in the Details view. This callback is typically used to validate the new value.The load and property are given as arguments.

<isvalid>[isvalid=function(load,property)] </isvalid>

The isvalid element specifies the name of the IronPython function called when Mechanical queriesthe validity of the property.

<isvisible>[isvisible=function(load,property)] </isvisible>

The isvisible element specifies the name of the IronPython function called when Mechanical checksif the property is visible or not. This function must return True or False.

<onapply>[function(load,property)]</onapply>

The onapply element specifies the name of the IronPython function called when the user selects theApply button in the load property control from the details view. The load and property are givenas arguments.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.170

XML Extension Definition

Page 179: ANSYS ACT Developers Guide

<oncancel>[function(load,property)]</oncancel>

The oncancel element specifies the name of the IronPython function called when the user selectsthe Cancel button in the load property control from the Details view. The load and property aregiven as arguments.

<string2value> [value=function(load,property,string)] </string2value>

The string2value element specifies the name of the IronPython function called when Mechanicalconverts the string representation of a numeric value to a double. This function returns a double.

<value2string> [string=function(load,property,value)] </value2string>

The value2string element specifies the name of the IronPython function called when Mechanicalconverts the numeric value to a string representation. This function returns a string.

<getvalue>[function(load,property,value)] </getvalue>

The getvalue element specifies the name of the IronPython function called each time the value ofthe property is accessed. The load and property and the internal value of the property are given asarguments.

<oninit>[function(load,property)]</oninit>

The oninit element specifies the name of the IronPython function called when the property is initialized.

<onshow>[function(load,property)]</onshow>

The onshow element specifies the name of the IronPython function called when the property is shownin the targeted application.

<onhide>[function(load,property)]</onhide>

The onhide element specifies the name of the IronPython function called when the property is hiddenin the targeted application.

<onadd>[function(load,property)]</onadd>

The onadd element specifies the name of the IronPython function called when the property is addedin the targeted application.

<onduplicate>[function(load,property)]</onduplicate>

The onduplicate element specifies the name of the IronPython function called when the propertyis duplicated.

<onremove>[function(load,property)]</onremove>

The onremove element specifies the name of the IronPython function called when the property is re-moved.

<setvalue>[function(load,property,value)]</setvalue>

The setvalue element specifies the name of the IronPython function called when the property is setto the given value defined by the value argument.

<propertygroup> Element

A propertygroup has one more attribute than a standard property. This optional attribute is describedbelow.

171Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 180: ANSYS ACT Developers Guide

Optional attribute

This attribute defines how the propertygroup must be displayed:display

• none: the propertygroup itself is not displayed. Only its content (ie. thechild properties) is displayed. This option is used to better organize the XMLcode.

• caption: it's the default value. The propertygroup is displayed as acaption and all its content is displayed under the caption.

• property: the propertygroup is displayed as a standard property.

• worksheet: the propertygroup is displayed as a standard property butits content is displayed in a worksheet.

The callbacks associated to a propertygroup are the same as those associated to a standard property.

<propertytable> Element

A propertytable has one more attribute than a propertygroup. This optional attribute is describedbelow.

Optional attribute

This attribute indicates if an empty table is valid.allowempty

The value must be true or false (default).

The callbacks associated to a propertytable are the same as those associated to a standard property.

<result Element>

The <result> element and its children allows the user to configure the properties of a custom resultand to specify the IronPython functions that are invoked based on system and user-generated events.

<simdata context="[Project | Mechanical | ASim]">

<result name="[result internal name (string)]"

version="[version identifier of the result (integer)]"

caption="[load display name (string)]"

icon="[name of an image located in images folders (string)]"

location="[node | elemnode | element]"

timehistory="[True | False]"

type="[scalar | vector]"

unit=""

contextual="[true(default) | false]"

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.172

XML Extension Definition

Page 181: ANSYS ACT Developers Guide

averaging="[Average | ElementalDifference | ElementalFraction | ElementalMean | NodalDifference | NodalFraction | Unaverage]"

class="[class_name]"

hasimaginary="[True | False]">

</result>

...

</simdata>

The <result> element supports a set of attributes, as described below, and two child elements: thecallbacks element and the property element. These two elements and their children are presentedin the next two sections.

Mandatory attributes

The value of the name attribute specifies the name usedby the application to reference this result.

name

The value of the version attribute allows the result authorto affect a version number to this result.

version

The value of the caption attribute specifies the namedisplayed in the GUI for this result.

caption

The value of the icon attribute specifies the file name ofthe icon displayed in the GUI for this toolbar button, without

icon

the file extension. (An icon is a 16x16 pixel image in BMP,JPG, or GIF format.) This file has to be stored in one of thefolders previously defined in the <images> elements.

In the case where the custom result is defined with a specificicon, the file that describes this icon must be placed in thefollowing directory:

[ANSYS installation]\aisol\DesignSpace\DSPages\images

The value of the location attribute specifies if the resulthas to be applied on nodes, on elements or on nodes ofelements.

location

The value of the type attribute specifies the type of theresult.

type

The value of the timehistory attribute initializes theCalculateTimeHistory property of the result. Defaultsto True when the attribute is omitted.

timehistory

Optional attributes

The value of the unit attribute specifies the physical quantity to whichthe result refers (for example, Length or Mass. See the ANSYS Workbench

unit

Documentation for details). If no unit is specified, then the result will beconsidered as unitless.

173Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 182: ANSYS ACT Developers Guide

If true, the result can be added directly from the Insert context menuavailable on the load object.

contextual

Indicates the method used to display the original result.averaging

Class name linked with the result.class

Indicates if the result has an imaginary part.hasimaginary

<callbacks> Element

<result name="[result internal name (string)]"

version="[version identifier of the result (integer)]"

caption="[load display name (string)]"

icon="[name of an image located in images folders (string)]"

location="[node | elemnode | element]"

type="[scalar | vector | tensor]"

timehistory="[True| False]"

unit="">

<callbacks>

<onmigrate>[function(newResult,oldResult)]</onmigrate>

<onshow>[function(result)]</onshow>

<onhide>[function(result)]</onhide>

<oninit>[function(result)]</oninit>

<onadd>[function(result)]</onadd>

<onsuppress>[function(result)]</onsuppress>

<onunsuppress>[function(result)]</onunsuppresss>

<oncleardata>[function(result)]</oncleardata>

<onstarteval>[function(result,step)]</onstarteval>

<onendeval>[function(result,step)]</onendeval>

<getvalue>[values=function(result,entityId)]</getvalue>

<canadd>[function(analysis,loadName)]</canadd>

<onduplicate>[function(result)]</onduplicate>

<canduplicate>[function(result,parent_object)]</canduplicate>

<onremove>[function(result)]</onremove>

<canremove>[function(result)]</canremove>

<evaluate>[function(result,stepinfo,collector)]</evaluate>

<getfieldcount>[cuntion(result,entityId)]</getfieldcount>

<isvalid>[function(result)]</isvald>

</callbacks>

...

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.174

XML Extension Definition

Page 183: ANSYS ACT Developers Guide

</result>

The <callbacks> element and its children specify the Python functions that are invoked based onsystem and user-generated events related to the result behavior. The children of the callbacks elementare described below:

<onmigrate> [function(new_result,old_result)] </onmigrate>

The onmigrate element specifies the name of the IronPython function called when Mechanical loadsthe ACT customized result. This function allows you to maintain the extension from one version numberto another. The function is called if the current version of the result is greater than the last saved version.

<onshow>[function(result)]</onshow>

The onshow element specifies the name of the IronPython function called when the result is "visible"(ie. the result in the tree is selected). This function is used to display customized graphical informationassociated with this result.

<onhide>[function(result)]</onhide>

The onhide element specifies the name of the IronPython function called when the result switchesfrom a visible status to a hidden status. This event is called when the ACT object is unselected.

<oninit>[function(result)]</oninit>

The oninit element specifies the name of the IronPython function called when the result is created.

<onadd>[function(result)]</onadd>

The onadd element specifies the name of the IronPython function called when the result is added. Thisevent is called when the ACT object is added to the project.

<onremove>[function(result)]</onremove>

The onremove element specifies the name of the IronPython function called when the result is deleted.This event is called when the ACT object is deleted from the project.

<onsuppress>[function(result)]</onsuppress>

The onsuppress element specifies the name of the IronPython function called when the result switchesfrom an active state to a suppressed state. This event is called when the ACT object is suppressed.

<onunsuppress>[function(result)]</onunsuppress>

The onunsuppress element specifies the name of the IronPython function called when the result switchesfrom a suppressed state to an active state. This event is called when the ACT object is unsuppressed.

<oncleardata>[function(result)]</oncleardata>

The oncleardata element specifies the name of the IronPython function called when the hostingapplication requests that the data stored in relation to this result is cleared. This event may be fired bydirect user action or implicitly as the result of upstream data changes in the application which invalidatethe result.

<onstarteval>[function(result,step)]</onstarteval>

The onstarteval element specifies the name of the IronPython function called when the evaluationof the result is required. Operations such as memory allocations or file access can be done at this stage.The argument step defines the step on which the evaluation has to be done.

175Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 184: ANSYS ACT Developers Guide

<onendeval>[function(result,step)]</onendeval>

The onendeval element specifies the name of the IronPython function called when the evaluation ofthe result is completed. Operations related to clean-up, such as releasing memory allocations or closingexternal files, should be done at this stage.

<getvalue>[values=function(result,entityId)] </getvalue>

The getvalue element specifies the name of the IronPython function called when Mechanical retrievesthe results values. EntityId refers to a node ID or an element ID, depending on the type of the result.

• For scalar results on nodes, the size of values is 1

• For vector results on nodes, the size of values is 3

• For scalar results on elements, the size of values is 1

• For vector results on elements, the size of values is 3

• For scalar results on nodes of elements, the size of values is equal to the number of nodes related to theelement.

• For vector results on nodes of elements, the size of values is equal to 3 multiplied by the number of nodesrelated to the element.

<canadd>[function(analysis,resultName)]</canadd>

The canadd element specifies the name of the IronPython function called when Mechanical evaluatesif a result can be created for the current analysis. canadd takes two arguments: the current analysisand the name of the result to be validated. This function must return True or False.

<onduplicate>[function(result)]</onduplicate>

The onduplicate element specifies the name of the IronPython function called when Mechanicalduplicates the result object.

<canduplicate>[function(result,loadName)]</canduplicate>

The canduplicate element specifies the name of the IronPython function called when Mechanicalchecks if the result object can be duplicated, depending on the selected parent object in the tree.

<onremove>[function(result)]</onremove>

The onremove element specifies the name of the IronPython function called when Mechanical removesthe result object.

<canremove>[function(result)]</canremove>

The canremove element specifies the name of the IronPython function called when Mechanical checksif the result object can be removed.

<evaluate>[function(result,stepinfo,collector)]</evaluate>

The evaluate element specifies the name of the IronPython function called when Mechanical evaluatesthe result.

The callback named evaluate replaces the two callbacks onstarteval and getvalue. This simplifiesthe implementation of ACT results by combining the evaluation of the result with the passing of theresult to the application.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.176

XML Extension Definition

Page 185: ANSYS ACT Developers Guide

The stepinfo argument is an object with properties that provides information on the current resultset number or the current time step.

The collector argument is used by the application for displaying the result. When the function iscalled, collector is already initialized with expected information such as IDs of the FE entities onwhich a result is expected.

For example, for a scalar result to be computed on nodes or elements, the following implementationsends the constant value value to the set of appropriate FE entities:

def evaluate(result, stepinfo, collector): value = 1 for Id in collector.Ids: collector.SetValues(Id,value)

<getfieldcount>[function(result,entityId)]</getfieldcount>

The getfieldcount element specifies the name of the IronPython function called to get the numberof fields for the current result related to one given element or node ID.

<isvalid>[function(result)]</isvalid>

The isvalid element specifies the name of the IronPython function called when Mechanical evaluatesif the result is valid.

<property> Element

The description of the property element for a result is the same as that of the property elementfor the load. Please refer to the section 8.1.3.1.2 for that purpose.

<propertygroup> Element

The description of the propertygroup element for a result is the same as that of the propertygroupelement for the load. Please refer to the section 8.1.3.1.3 for that purpose.

<propertytable> Element

The description of the propertytable element for a result is the same as that of the propertytableelement for the load. Please refer to the section 8.1.3.1.4 for that purpose.

<solver> Element

The <solver> element and its children provide the means to configure a third party solver connectionand specify the IronPython functions that are invoked based on system and user-generated events.

<simdata context="[Project | Mechanical | DesignXplorer]">

...

<solver name="[solver internal name]"

version="[version identifier of the solver]"

caption="[solver display name]"

icon="[name of an icon file]"

analysis="[string (analysis type (Static))]"

177Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 186: ANSYS ACT Developers Guide

physics="[string (physics type (Structural))]"

class="[class name]"

contextual="[True (default) | False]"

toolbox="[toolbox name]">

</solver>

</simdata>

The <solver> element has two child elements. These are the callbacks element and the propertyelement. These two elements and their children are presented in the next two sections.

The <solver> element supports a set of attributes as described below:

Mandatory attributes

The value of the name attribute specifies the name used by the applicationto reference the solver.

name

The value of the version attribute allows to affect a version number to thesolver.

version

The value of the caption attribute specifies the name displayed in the GUIfor the solver.

caption

The value of the icon attribute specifies the file name of the icon displayedin the GUI for the solver. (An icon is a 16x16 pixel image in BMP, JPG, or GIFformat. Icon files are stored in the images sub-folder of the extension folder.)

icon

The value of the analysis attribute specifies the analysis type that thesolver addresses. The current version of ACT only supports the Static analysis.

analysis

The value of the type attribute specifies the physics to be used with thesolver. The current version of the ACT only supports the Structural physics.

physics

Optional attributes

Class name of the controller of the object.class

Indicates if the object has to be displayed in the current context.contextual

Name of the toolbox which defines the group in which the solve takes place.toolbox

<callbacks> Element

<solver name="[solver internal name (string)]"

version="[version identifier of the solver (integer)]"

caption="[load display name (string)]"

icon="[name of an image located in images folders (string)]"

analysis="[string (analysis type (Static))]"

physics="[string (physics type (Structural))]">

<callbacks>

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.178

XML Extension Definition

Page 187: ANSYS ACT Developers Guide

<onmigrate>[function(newSolver,oldSolver)]</onmigrate>

<oninit>[function(solver)]</oninit>

<onshow>[function(solver)]</onshow>

<onhide>[function(solver)]</onhide>

<onbeforesolve>[function(solver)]</onbeforesolve>

<onsolve>[function(solver)]</onsolve>

<oncleardata>[function(solver)]</ onwriteinputfile >

<onwriteinputfile>[function(solver)]</oncleardata>

<getsteps>[function(solver)]</getsteps>

<isanalysisvalid>[function(solver)]</isanalysisvalid>

<getreader>[function(solver)]</getreader>

<onadd>[function(parent object, object name)]</onadd>

<onremove>[function(solver)]</onremove>

<isvalid>[function(solver)]</isvalid>

<oncheckresults>[function(solver)]</oncheckresults>

</callbacks>

...

</solver>

The <callbacks> element and its children provide the means to specify the Python functions thatare invoked based on system and user-generated events related to the solver behavior. The callbackschildren are described below:

<onmigrate>[function(new_solver,old_solver)] </onmigrate>

The onmigrate element specifies the name of the IronPython function called when Mechanical islaunched. This function allows you to maintain the extension from one version to any other more recentone to the next. The function is called if the current version of the solver is newer than the last savedversion.

<oninit>[function(solver)]</oninit>

The oninit element specifies the name of the IronPython function called when Mechanical is launched.

<onshow>[function(solver)]</onshow>

The onshow element specifies the name of the IronPython function called when the customized ana-lysis settings object related to the solver is activated.

<onhide>[function(solver)]</onhide>

The onhide element specifies the name of the IronPython function called when the customized ana-lysis settings object is deactivated.

<onbeforesolve>[function(solver)]</onbeforesolve>

179Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 188: ANSYS ACT Developers Guide

The onbeforesolve element specifies the name of the IronPython function called just before thesolver is launched. The function is useful when an advanced customization is necessary before startingthe external solver.

<onsolve>[function(solver)]</onsolve>

The onsolve element specifies the name of the IronPython function called when the solver is launched.

<oncleardata>[function(solver)]</oncleardata>

The oncleardata element specifies the name of the IronPython function called when the hostingapplication requests that the data stored in relation to this solver is cleared. This event may be fired bydirect user action or implicitly as the result of upstream data changes in the application which invalidatethe solution.

<onwriteinputfile>[function(solver)]</onwriteinputfile >

The onwriteinputfile element specifies the name of the IronPython function called when thehosting application requests that the solver write the input stream. This event may be kicked off bydirect user action or implicitly as the result of upstream request in the application.

<getsteps>[function(solver)]</getsteps>

The getsteps element specifies the name of the IronPython function called to retrieve the list of thestep end time values. This function must return a list of double values.

<isanalysisvalid>[function name(solver,firstCheck)] </isanalysisvalid>

The isanalysisvalid element specifies the name of the IronPython function called when Mechan-ical retrieves the status of the analysis. The declaration of the called function must be:

def function_name(solver,firstCheck):

The input argument solver defines the current solver associated to the current analysis to be checked.

The input argument firstCheck indicates if Mechanical calls this function before or after the standardvalidation. Mechanical will call this function with firstCheck set to True before the standard checkand will call a second time this function with firstCheck set to False after.

This function must return an integer value equal to -1, 0 or 1.

-1 means that the user doesn't want to check anything here, 0 means that the solver definition is notyet valid, and 1 means that the solver is ready to be launched. If the returned value is not equal to -1and firstCheck is equal to True, then the standard check performed by Mechanical is skipped.

<getreader>[function(solver)]</getreader>

The getreader element specifies the name of the IronPython function called to retrieve the nameand string arguments of the result reader associated with this solver. This function must return a list ofstring values, where the first value is the name of the IronPython class.

<onadd>[function(solver)]</onadd>

The onadd element specifies the name of the IronPython function called when Mechanical is launchedfor the first time with the solver connection.

<onremove>[function(solver)]</onremove>

The onremove element specifies the name of the IronPython function called when the system linkedwith the solver is removed from the schematic.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.180

XML Extension Definition

Page 189: ANSYS ACT Developers Guide

<isvalid>[function(solver)]</isvalid>

The isvalid element specifies the name of the IronPython function called when Mechanical checksif the analysis settings object is valid. The function returns True or False.

<oncheckresults>[function(solver)]</oncheckresults>

The oncheckresults element specifies the name of the IronPython function called when Mechanicalstarts a post-processing task. The function returns True or False.

<property> Element

The description of the property element on the solver is the same as the description for the<property> element on the load. Please refer to the section 8.1.3.1.3 for more information.

Note

The applycancel and custom properties cannot be used in one customized analysissettings object with the current version of ACT.

<propertygroup> Element

The description of the propertygroup element on the solver is the same as the description for the<propertygroup> element on the load. Please refer to the section 8.1.3.1.3 for more information.

<propertytable> Element

The description of the propertytable element on the solver is the same as the description for the<propertytable> element on the load. So you can refer to the section 8.1.3.1.4 for more information.

<sampling> Element

This section applies to the ANSYS DesignXplorer application only.

The <sampling> element allows you to configure the properties of the sampling and specify thefunctions that are invoked based on system and user-generated events.

<optimizer> <callbacks> ... </callbacks> <property> <propertygroup> <propertytable></optimizer>

Mandatory Attributes

The name of the object.name

The version of the object.version

Optional Attributes

The caption of the object.Caption

Class name of the controller of the object.Class

181Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 190: ANSYS ACT Developers Guide

Provides messages to generate a log file.LogFile

Indicates the maximum number of double listparameters supported.

MaximumNumberOfDoubleListParameters

Indicates the maximum number of double parameterssupported.

MaximumNumberOfDoubleParameters

Indicates the maximum number of input parameterssupported.

MaximumNumberOfInputParameters

Indicates the maximum number of integer listparameters supported.

MaximumNumberOfIntegerListParamet-ers

For more detailed information on attributes supported by the <sampling> element, see the "Sampling"section in the ACT Reference Guide for DesignXplorer.

<callbacks> Element

The <callbacks> element lets you specify the Python functions that are invoked based on system-generated and user-generated events related to the optimizer behavior. Each child of the <callbacks>element has a specific name and corresponds to a specific callback, as shown below.

<simdata context="DesignXplorer"><sampling name="[sampling internal name]" caption="[sampling display name]" icon="[name of an icon file]" version="[version identifier of the sampling]"> <callbacks> <OnCreate>[function(entity)]</OnCreate> <CanRun>[function(entity)]</CanRun> <Description>[function(entity)]</Description> <Configuration>[function(entity)]</Configuration> <Status>[function(entity)]</Status> <QuickHelp>[function(entity)]</QuickHelp> <InputParametersEdited>[function(entity)]</InputParametersEdited> <MethodPropertiesEdited>[function(entity)]</MethodPropertiesEdited> <OnMigrate>[function(newentity,oldentity)]</OnMigrate> <OnRelease>[function(entity)]</OnRelease> </callbacks></sampling></simdata>

When most callbacks are invoked, an entity object of the type DXUserSampling is passed to them,allowing the function to easily access data and determine the context in which it has been invoked.

On the entity object,

• Each attribute of the <sampling> element appears as a property. For example, the Python code entity.LogFile allows you to access the value of the LogFile attribute.

• Each <property> element appears in the Properties dictionary and is accessible by its name. For in-stance, if the <property> element “MyProperty” is defined, you can access its value in Python by writingentity.Properties[“MyProperty”].Value.

• Several additional properties associated with the sampling also appear as properties. For example,Number-OfInputParametersDefined is an additional property reflecting the current definition of thesamplingstudy. For a comprehensive list of properties, see the "IUserSampling" section in the ACT Refer-ence Guide for DesignXplorer.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.182

XML Extension Definition

Page 191: ANSYS ACT Developers Guide

The following table lists the callbacks available for the <sampling> element. Subsequent sectionsprovide information on using several of the most common callbacks. For more detailed information onavailable callbacks, see the “DOE” section in the ACT Reference Guide for DesignXplorer.

Called to know if the object can be added. Indicates if thesampling is able to process the design of experiments withits current configuration.

CanAdd

Indicates if the sampling is able to process the design ofexperiments with its current configuration.

CanRun

Returns a user readable string summarizing the currentconfiguration of the sampling.

Configuration

Returns a user readable string describing the sampling andits specific capabilities.

Description

Is invoked when the properties of input parameters havechanged.

InputParametersEdited

Is invoked when the properties of the sampling have changed.MethodPropertiesEdited

Called when the object is newly added. This callback is notcalled when the project is reopened.

OnAdd

Is invoked to provide an instance of ISamplingMethod.OnCreate

Called when the object is initialized. This callback is calledafter the OnAdd callback and when the project is reopened.

OnInit

Called when the object version has been changed. It allowsthe migration of data from the old saved object to the newone.

OnMigrate

Is invoked to release the ISamplingMethod instance.OnRelease

Returns a user readable string helping to understand thestate of the sampling when CanRun is false.

QuickHelp

Returns a user readable string describing the status of thesampling resolution.

Status

<OnCreate> and <OnRelease> Callbacks

The OnCreate callback is mandatory for any sampling. It specifies the name of the function to callwhen DX instantiates the external sampling class at the beginning of the sampling process (see TheDesign Exploration Process (p. 72)). The function must return an object implementing the ISampling-Method interface, which is assumed to be a new instance.

Here is an example of callback implementation. Given the partial sampling definition:

<sampling …> <callbacks> <OnCreate>createRandomSampling</OnCreate> </callbacks> <property name="RandomSeed" caption="Random Seed" control="integer" default="0" /></sampling>

The createRandomSampling function is defined by the following IronPython code:

def createRandomSampling(entity): seed = entity.Properties["RandomSeed"].Value instance = RandomSampling(seed) return instance

183Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 192: ANSYS ACT Developers Guide

The createRandomSampling function retrieves the value of the RandomSeed property and createsa new instance of RandomSampling, passing the seed in an argument. The instance implements IS-amplingMethod. It is returned to the caller.

The OnRelease callback specifies the function to allow DX to release the sampling instance at theend of the sampling process. It is assumed that the callback will delete the instance initially created byinvoking OnCreate.

<canRun> and <QuickHelp> Callbacks

The declaration of the capabilities allows DX to determine if the sampling can run in many simplecontexts. For the custom and advanced situations, you can define the CanRun callback to apply yourown logic, based on the properties provided by the DXUserSampling object and with the internaldependencies and conditions managed in your own code. For instance, this function could check withyour own mechanism whether the user has a valid license to use the sampling.. The function definedfor the CanRun callback must return a Boolean value: True if the optimizer can run, False otherwise.If CanRun returns False, the sampling process is aborted.

def canRunSampling(entity): numberOfSamples = entity.Properties["MyMaximumNumberOfSamples"].Value if numberOfSamples <= 0 or numberOfSamples > 10000: return False; return True

This code checks:

• MyNumberOfSamples property

In addition to the CanRun callback, the external sampling can provide a function for the QuickHelpcallback to generate a Quick Help message associated to the sampling context.

def getQuickHelp(entity): if numberOfSamples <= 0 or numberOfSamples > 10000: numberOfSamples = entity.Properties["MyNumberOfSamples"].Value return 'Number of Samples must be positive and lower than 10000' return ''

This function returns a Quick Help message which can be displayed when the user clicks on the QuickHelp icon in the user interface, as shown in Figure 65: Quick Help in the Optimization Outline View (p. 190).

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.184

XML Extension Definition

Page 193: ANSYS ACT Developers Guide

Figure 64: Quick Help in the DOE Outline View

<optimizer> Element

This section applies to the ANSYS DesignXplorer application only.

The <optimizer> element allows you to configure the properties of the optimization and specify thefunctions that are invoked based on system and user-generated events.

<optimizer> <callbacks> ... </callbacks> <property> <propertygroup> <propertytable></optimizer>

Mandatory Attributes

The name of the object.name

The version of the object.version

Optional Attributes

True if the optimizer is only available in the context ofa Direct Optimization component; false otherwise.

BasedOnDirectOptimiza-tionOnly

True if the optimizer is only available in the context ofa Response Surface component; false otherwise.

BasedOnResponseSurfaceOnly

185Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 194: ANSYS ACT Developers Guide

The caption of the object.Caption

Class name of the controller of the object.Class

Supports constraint handling.ConstraintHandling

Supports the Importance property of a constraint.ConstraintImportance

Supports constraints defined on an input parameter.ConstraintOnInputParameter

Provides convergence data.ConvergenceData

Supports the Equal To constraint type.EqualToConstraint

Supports the Greater Than constraint type.GreaterThanConstraint

Defines the X axis type for history charts.HistoryChartXAxisType

The icon of the object.Icon

Supports the Inside Bounds constraint type.InsideBoundsConstraint

Supports the Less Than constraint type.LessThanConstraint

Provides messages to generate a log file.LogFile

Supports the Maximize objective type.MaximizeObjective

Defines the maximum number of constraints supportedby the optimizer.

MaximumNumberOfConstraints

Indicates the maximum number of double list parameterssupported.

MaximumNumberOfDoubleList-Parameters

Indicates the maximum number of double parameterssupported.

MaximumNumberOfDoublePara-meters

Indicates the maximum number of input parameterssupported.

MaximumNumberOfInputPara-meters

Indicates the maximum number of integer list parameterssupported.

MaximumNumberOfIntegerList-Parameters

Defines the maximum number of objectives supportedby the optimizer.

MaximumNumberOfObjectives

Supports the Minimize objective type.MinimizeObjective

Defines the minimum number of constraints required.MinimumNumberOfConstraints

Defines the minimum number of objectives required.MinimumNumberOfObjectives

Supports the Importance property of an objective.ObjectiveImportance

Supports objectives defined on an input parameter.ObjectiveOnInputParameter

Supports parameter relationships.ParameterRelationship

Supports the Seek objective type.SeekObjective

Requires a starting point.StartingPointRequired

For more detailed information on attributes supported by the <optimizer> element, see the "Optim-izer" section in the ACT Reference Guide for DesignXplorer.

<callbacks> Element

The <callbacks> element lets you specify the Python functions that are invoked based on system-generated and user-generated events related to the optimizer behavior. Each child of the <callbacks>element has a specific name and corresponds to a specific callback, as shown below.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.186

XML Extension Definition

Page 195: ANSYS ACT Developers Guide

<simdata context="DesignXplorer"> <optimizer name="[optimizer internal name]" caption="[optimizer display name]" icon="[name of an icon file]" version="[version identifier of the optimizer]"> <callbacks> <OnCreate>[function(entity)]</OnCreate> <CanRun>[function(entity)]</CanRun> <Description>[function(entity)]</Description> <Configuration>[function(entity)]</Configuration> <Status>[function(entity)]</Status> <QuickHelp>[function(entity)]</QuickHelp> <InputParametersEdited>[function(entity)]</InputParametersEdited> <ObjectivesOrConstraintsEdited>[function(entity)]</ObjectivesOrConstraintsEdited> <MethodPropertiesEdited>[function(entity)]</MethodPropertiesEdited> <OnMigrate>[function(newentity,oldentity)]</OnMigrate> <OnRelease>[function(entity)]</OnRelease> </callbacks> </optimizer></simdata>

When most callbacks are invoked, an entity object of the type DXUserOptimizer is passed to them,allowing the function to easily access data and determine the context in which it has been invoked.

On the entity object,

• Each attribute of the <optimizer> element appears as a property. For example, the Python code en-tity.SeekObjective allows you to access the value of the SeekObjective attribute.

• Each <property> element appears in the Properties dictionary and is accessible by its name. For in-stance, if the <property> element “MyProperty” is defined, you can access its value in Python bywriting entity.Properties[“MyProperty”].Value.

• Several additional properties associated with the optimization study also appear as properties. For example,IsDirectOptimization and NumberOfInputParametersDefined are additional properties re-flecting the current definition of the optimization study. For a comprehensive list of properties, see the“IUserOptimizer” section in the ACT Reference Guide for DesignXplorer.

The following table lists the callbacks available for the <optimizer> element. Subsequent sectionsprovide information on using several of the most common callbacks. For more detailed information onavailable callbacks, see the “Optimizer” section in the ACT Reference Guide for DesignXplorer.

Called to know if the object can be added.CanAdd

Indicates if the optimizer is able to process the optimizationstudy with its current configuration.

CanRun

Returns a user readable string summarizing the currentconfiguration of the optimizer.

Configuration

Returns a DXConvergenceDescription object describingthe convergence data provided.

ConvergenceDescription

Returns a user readable string describing the optimizer andits specific capabilities.

Description

Is invoked when the properties of input parameters havechanged.

InputParametersEdited

Is invoked when the properties of the optimization methodhave changed.

MethodPropertiesEdited

187Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 196: ANSYS ACT Developers Guide

Invoked when the definition of objectives or constraints havechanged.

ObjectivesOrConstraintsEdited

Called when the object is newly added. This callback is notcalled when the project is reopened.

OnAdd

Is invoked to provide an instance of IOptimizationMeth-od.

OnCreate

Called when the object is initialized. This callback is calledafter the OnAdd callback and when the project is reopened.

OnInit

Called when the object version has been changed. It allowsthe migration of data from the old saved object to the newone.

OnMigrate

Is invoked to release the IOptimizationMethod instanceOnRelease

Invoked when the definition of parameter relationships havechanged.

ParameterRelationshipsEdited

Returns a user readable string helping to understand thestate of the optimizer when CanRun is false.

QuickHelp

Returns a user readable string describing the status of theoptimization resolution.

Status

<OnCreate> and <OnRelease> Callbacks

The OnCreate callback is mandatory for any optimizer. It specifies the name of the function to callwhen DX instantiates the external optimizer class at the beginning of the optimization process (see TheOptimization Process (p. 139)). The function must return an object implementing the IOptimization-Method interface, which is assumed to be a new instance.

Here is an example of callback implementation. Given the partial optimizer definition:

<optimizer …> <callbacks> <OnCreate>createRandomOptimizer</OnCreate> </callbacks> <property name="RandomSeed" caption="Random Seed" control="integer" default="0" /></optimizer>

The createRandomOptimizer function is defined by the following IronPython code:

def createRandomOptimizer(entity): seed = entity.Properties["RandomSeed"].Value instance = RandomOptimizer(seed) return instance

The createRandomOptimizer function retrieves the value of the RandomSeed property and createsa new instance of RandomOptimizer, passing the seed in an argument. The instance implementsIOptimizationMethod. It is returned to the caller.

The OnRelease callback specifies the function to allow DX to release the optimizer instance at theend of the optimization process. It is assumed that the callback will delete the instance initially createdby invoking OnCreate.

<canRun> and <QuickHelp> Callbacks

The declaration of the capabilities allows DX to determine if the optimizer can run in many simplecontexts. For the custom and advanced situations, you can define the CanRun callback to apply your

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.188

XML Extension Definition

Page 197: ANSYS ACT Developers Guide

own logic, based on the properties provided by the DXUserOptimizer object and with the internaldependencies and conditions managed in your own code. For instance, this function could check withyour own mechanism whether the user has a valid license to use the optimizer. The function definedfor the CanRun callback must return a Boolean value: True if the optimizer can run, False otherwise.If CanRun returns False, the optimization process is aborted.

def canRunOptimizer(entity): maximumNumberOfCandidates = entity.Properties["MyMaximumNumberOfCandidates"].Value numberOfSamples = entity.Properties["MyNumberOfSamples"].Value

if maximumNumberOfCandidates <= 0 or maximumNumberOfCandidates > numberOfSamples: return False;

if numberOfSamples <= 0 or numberOfSamples > 10000: return False; if entity.NumberOfObjectivesDefined == 0 and entity.NumberOfConstraintsDefined == 0 and entity.NumberOfObjectivesDefinedOnInputs == 0 and entity.NumberOfConstraintsDefinedOnInputs == 0: return False return True

This code checks:

• The consistency between the MyMaximumNumberOfCandidates and MyNumberOfSamples properties.

• That at least one objective or one constraint is defined.

In addition to the CanRun callback, the external optimizer can provide a function for the QuickHelpcallback to generate a Quick Help message associated to the optimization context.

def getQuickHelp(entity): maximumNumberOfCandidates = entity.Properties["MyMaximumNumberOfCandidates"].Value numberOfSamples = entity.Properties["MyNumberOfSamples"].Value

if numberOfSamples <= 0 or numberOfSamples > 10000: return 'Number of Samples must be positive and lower than 10000' if maximumNumberOfCandidates <= 0 or maximumNumberOfCandidates > numberOfSamples: return 'Maximum Number of Candidates must be positive and lower than Number of Samples' if entity.NumberOfObjectivesDefined == 0 and entity.NumberOfConstraintsDefined == 0 and entity.NumberOfObjectivesDefinedOnInputs == 0 and entity.NumberOfConstraintsDefinedOnInputs == 0: return 'At least one objective or constraint needs to be defined' return ''

This function returns a Quick Help message which can be displayed when the user clicks on the QuickHelp icon in the user interface, as shown in Figure 65: Quick Help in the Optimization Outline View (p. 190).

189Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

<extension> Element

Page 198: ANSYS ACT Developers Guide

Figure 65: Quick Help in the Optimization Outline View

<Description>, <Configuration>, and <Status> Callbacks

The Description, Configuration, and Status callbacks provide content to be directly exposedin the user interface. When the Optimization node is selected in the Outline view, the Table view ispopulated with a summary of the study, as shown in Figure 66: Information Exposed in the OptimizationProperties View (p. 190).

Figure 66: Information Exposed in the Optimization Properties View

In Figure 66: Information Exposed in the Optimization Properties View (p. 190), we can see that the Op-timization Method group displays a summary of the information provided by the optimizer, as follows:

• The first line contains a brief description of the optimization. The cell A4 contains the name of the optimizeras defined in the XML file, and the cell B4 contains the string returned by the Description callback.

• The second line contains the configuration of the current optimization. The cell B5 is contains the stringreturned by the Configuration callback.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.190

XML Extension Definition

Page 199: ANSYS ACT Developers Guide

• The third line corresponds to the status of the optimization run. The cell B6 contains the string returned bythe Status callback.

Note

If the callbacks are not implemented, cells B4, B5, and B6 remain empty.

Here is an example of a callbacks implementation. Given the partial optimizer definition:

<optimizer …> <callbacks> <Description>getDescription</Description> <Configuration>getConfiguration</Configuration> <Status>getStatus</Status> </callbacks> <property name="MyOptimizationStatus" caption="My Optimization Status" control="text" readonly="true"></property> <property name="MyNumberOfEvaluations" caption="My Number of Evaluations" control="integer" readonly="true"></property></optimizer>

The following are the IronPython function implementations:

def getDescription(entity): description = "Random screening - Python Example" return description

def getConfiguration(entity): maximumNumberOfCandidates = entity.Properties["MyMaximumNumberOfCandidates"].Value numberOfSamples = entity.Properties["MyNumberOfSamples"].Value configuration = 'Generates %d random points, and extracts %d candidates.' %(numberOfSamples,maximumNumberOfCandidates) return configuration

def getStatus(entity): return entity.Properties["MyOptimizationStatus"].Value

XML File Definition

The section below describes in detail a generic XML file that includes all the available tags and attributesthat can be used by an extension. Your XML file does not have to integrate all of this data; select appro-priate elements for the requirements that the extension is addressing.

<extension name="[extension name (string)]"

version="[version id (integer)]"

minorversion="[minor version id (integer)]">

<guid shortid="[extension name (string)]">GUID</guid>

<author>[Name of the author or organisation (string)]</author>

<description>[Description (string)]</description>

<assembly src="[file name]" namespace="[namespace]"/>

<script compiled="[false(default) | true]"

src="[python file name (string)]"></script>

<templates>

<controltemplate name="[template name (string)]"

version="[version id (integer)]">

191Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

XML File Definition

Page 200: ANSYS ACT Developers Guide

<propertygroup>

<property> ... </property>

<propertygroup> ... </propertygroup>

</propertygroup>

</controltemplate>

</templates>

<interface context="[Project | Mechanical]">

<images>[folder name that contains images]</images>

<callbacks>

<oninit>[function(context)]</oninit>

<onbeforesolve>[function(analysis)]</onbeforesolve>

<onaftersolve>[function(analysis)]</onaftersolve>

<isanalysisvalid>[function(analysis,firstCheck)]</isanalysisvalid>

<onload>[function(currentFolder)]</onload>

<onsave>[function(currentFolder)]</onsave>

<ondraw>[function()]</ondraw>

<ondraw2d>[function()]</ondraw2d>

<getprecommands>[function(analysis,stream)]</getprecommands>

<getsolvecommands timedependent="[true | false(default)]">

[function(analysis,stream)]</getsolvecommands>

<getpostcommands>[function(analysis,stream)]</getpostcommands>

<onpostfinished>[function(analysis)]</onpostfinished>

<onpoststarted>[function(analysis)]</onpoststarted>

<onterminate>[function(context)]</onterminate>

<resume>[function(binary reader)]</resume>

<save>[function(binary writer)]</save>

</callbacks>

<toolbar name="[toolbar internal name (string)]"

caption="[toolbar display name (string)]">

<entry name="[toolbar button internal name (string)]"

caption="[toolbar button display name (string)]"

icon="[image located in images folders (string)]">

userobject="[object name (string)]">

<callbacks>

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.192

XML Extension Definition

Page 201: ANSYS ACT Developers Guide

<onclick>[function(analysis)]</onclick>

</callbacks>

</entry>

<separator> ... </separator>

</entry>

<separator> ... </separator>

</toolbar>

</interface>

<simdata context="[Project | Mechanical | DesignXplorer]">

<load name="[load internal name (string)]"

caption="[load display name (string)]"

version="[version identifier of the load (integer)]"

icon="[image name located in images folders (string)]"

class="[class name]"

issupport="[true | false]"

isload="[true | false]"

color="[#xxxxxx]"

unit=""

contextual="[true | false]">

<attributes [attribute="" name=""]="[attribute value]" ...>

<[attribute_name (string)]>[attribute value (string)]

</[attribute_name (string)]>

</attributes>

<callbacks>

<canadd>[function(analysis,loadName)]</canadd>

<action name="[name of the action (string)]"

icon="[image name located in images folders (string)]">

[function(load)]</action>

<onmigrate>[function(newLoad,oldLoad)]</onmigrate>

<onsuppress>[function(load)]</onsuppress>

<onunsuppress>[function(load)]</onunsuppress>

<onadd>[function(load)]</onadd>

<onremove>[function(load)]</onremove>

<onshow>[function(load)]</onshow>

<onhide>[function(load)]</onhide>

<oninit>[function(load)]</oninit>

193Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

XML File Definition

Page 202: ANSYS ACT Developers Guide

<oncleardata>[function(load)]</oncleardata>

<ongenerate>[function(load)]</ongenerate>

<onaftergenerate>[function(load)]</onaftergenerate>

<getprecommands order="[(integer)]">

[function(load,stream)]</getprecommands>

<getsolvecommands order="[(integer)]"

timedependent="[true | false(default)]">

[function(load,stream)]</getsolvecommands>

<getpostcommands order="[(integer)]">

[function(load,filename)]</getpostcommands>

<getnodalvaluesfordisplay>

[values=function(load,nodeIds)]

</getnodalvaluesfordisplay>

</callbacks>

<property name="[property internal name (string)]"

caption="[property internal name (string)]"

unit="[string]"

control="[text(default) | select | float |

integer | custom | applycancel |

[template name (string)]]"

readonly="[true | false(default)]"

visible="[true(default) | false]"

visibleon="[values (separator '|')]"

needupdate="[true(default) | false]"

default="[default value]"

class="[class name]">

<attributes> ... </attributes>

<callbacks>

<onmigrate>[function(new property,old property)]

</onmigrate>

<onactivate>[function(load,property)]</onactivate>

<onvalidate>[function(load,property)]</onvalidate>

<onapply>[function(load,property)]</onapply>

<oncancel>[function(load,property)]</oncancel>

<value2string>[string=function(load,property,value)]

</value2string>

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.194

XML Extension Definition

Page 203: ANSYS ACT Developers Guide

<string2value>[value=function(load,property,string)]

</string2value>

<isvalid>[isvalid=function(load,property)]</isvalid>

<isvisible>[isvalid=function(load,property)]

</isvisible>

<getvalue>[value=function(load,property,value)]

</getvalue>

<oninit>[function(load,property)]</oninit>

<onshow>[function(load,property)]</onshow>

<onhide>[function(load,property)]</onhide>

</callbacks>

</property>

<propertygroup name="[property internal name (string)]"

caption="[property display name (string)]"

unit="[string]"

control="[text(default) | select | float |

integer | custom | applycancel |

[template name (string)]]"

readonly="[true | false(default)]"

visible="[true(default) | false]"

visibleon="[values (separator '|')]"

needupdate="[true(default) | false]"

default="[default value]"

class="[class name]"

display="[none | caption(default) |

property | worksheet]">

<attributes> ... </attributes>

<callbacks>

...

</callbacks>

</propertygroup>

<propertytable name="[property internal name (string)]"

caption="[property display name (string)]"

unit="[string]"

control="[text(default) | select | float |

integer | custom | applycancel |

195Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

XML File Definition

Page 204: ANSYS ACT Developers Guide

[template name (string)]]"

readonly="[true | false(default)]"

visible="[true(default) | false]"

visibleon="[values (separator '|')]"

needupdate="[true(default) | false]"

default="[default value]"

class="[class name]"

display="[none | caption(default) |

property | worksheet]"

allowempty="[true | false(default)]">

<attributes> ... </attributes>

<callbacks>

...

</callbacks>

</propertytable>

</load>

<object> ... </object>

<result name="[result internal name (string)]"

caption="[load display name (string)]"

version="[version identifier of the result (integer)]"

icon="[image name located in images folders (string)]"

class="[class name]"

location="[node | elemnode | element]"

type="[scalar | vector | tensor]"

timehistory="[true | false]"

unit="[quantity nale (string)]" >

<callbacks>

<onmigrate>[function(newResult,oldResult)]</onmigrate>

<onsuppress>[function(result)]</onsuppress>

<onunsuppress>[function(result)]</onunsuppress>

<onadd>[function(result)]</onadd>

<onremove>[function(result)]</onremove>

<onshow>[function(result)]</onshow>

<onhide>[function(result)]</onhide>

<oninit>[function(result)]</oninit>

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.196

XML Extension Definition

Page 205: ANSYS ACT Developers Guide

<oncleardata>[function(result)]</oncleardata>

<ongeneratedata>[function(result)]</ongeneratedata>

<getvalue>[values=function(result,entityId)]</getvalue>

<onstarteval>[function(result,step)]</onstarteval>

<onendeval>[function(result,step)]</onendeval>

</callbacks>

</result>

<solver name="[solver internal name (string)]"

caption="[solver display name (string)]"

version="[version identifier of the solver (integer)]"

icon="[image name located in images folders (string)]"

class="[class name (string)]"

analysis="[string (analysis type (Static))]"

physics="[string (physics type (Structural))]"

toolbox="[name of the toolbox (string)]">

<callbacks>

<onmigrate>[function(newSolver,oldSolver)]</onmigrate>

<onsuppress>[function(solver)]</onsuppress>

<onunsuppress>[function(solver)]</onunsuppress>

<onadd>[function(solver)]</onadd>

<onremove>[function(solver)]</onremove>

<onshow>[function(solver)]</onshow>

<onhide>[function(solver)]</onhide>

<oninit>[function(solver)]</oninit>

<oncleardata>[function(solver)]</oncleardata>

<ongeneratedata>[function(solver)]</ongeneratedata>

<onsolve>[function(solver)]</onsolve>

<onbeforesolve>[function(solver)]</onbeforesolve>

<onwriteinputfile>[function(solver)]</onwriteinputfile>

<isanalysisvalid>[function(solver)]</isanalysisvalid>

<getsteps>[double[]=function(solver)]</getsteps>

<getreader>[string[]=function(solver)]</getreader>

</callbacks>

</solver>

</simdata>

197Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

XML File Definition

Page 206: ANSYS ACT Developers Guide

</extension>

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.198

XML Extension Definition

Page 207: ANSYS ACT Developers Guide

Development and Debugging Tips

Prerequisites

As described earlier, the functions used to run an extension are developed using the IronPython language.The two following links provide documentation for this language.

• IronPython documentation

• Free python book

Debug Mode

When developing an extension, we recommend you activate the Debug mode option available in theExtensions Options, accessed on the Tools>Options menu. The two figures below illustrate how toaccess this mode.

199Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 208: ANSYS ACT Developers Guide

Figure 67: Debug Options Menu

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.200

Development and Debugging Tips

Page 209: ANSYS ACT Developers Guide

Figure 68: Debug Mode for Extensions

The activation of the Debug mode option provides two additional buttons in the ACT toolbar ofMechanical, as shown below.

Figure 69: ACT Debug Buttons

The Reload extensions button allows you to reload from Mechanical the extensions currently loaded.This feature is of particular interest during the development of the extension, as it provides an efficientmethod to interactively test the changes in an XML file or Python function. For major changes, ensurethe object acts as expected by deleting the ACT objects previously defined in Mechanical and recreatingthem. When not in Debug mode, you can reload your extensions by quitting Workbench and restartingyour session.

The View log file button opens the log file. This file provides warning or error messages generated bythe extension. This feature is also very useful during the development of the extensions. Each time anerror occurs in an extension, the icon is shown in red. Note that you can also view the log file from themain project page by selecting Extensions>View Log File.

201Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Debug Mode

Page 210: ANSYS ACT Developers Guide

Figure 70: View Log File Menu

The Debug mode is activated when the Mechanical application is next started. If Mechanical is alreadyopen when the Debug mode is activated, close and restart Mechanical to use Debug mode.

If the Debug mode is not activated, and you have modified the extension XML file, you must close andrestart ANSYS Workbench to reload extensions. If you have made modifications to the Python functions,you must close and restart only the Mechanical process.

ACT Console Extension

This extension is useful for interactively testing commands. The ActConsole extension adds a consolewindow to the application, in which the user can enter python commands and get the result. Informationon the available methods and prototypes are also provided on the top of the main window as describedbelow.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.202

Development and Debugging Tips

Page 211: ANSYS ACT Developers Guide

Figure 71: Console Window for ACT Extension

When you enter a period “.” into the Command Line Editor, a list of available functions are displayedinto the Functions list box. This list is updated only when a period is entered.

When you click on an item in the Functions list box, the prototype of this function is displayed intothe Information pane. Please note that the self argument is an internal python argument, and thisargument does not have to be specified during the call of the function.

Each extension runs with a dedicated script engine. That means that to access to global variables orfunctions associated to an extension the user needs first to select the appropriate extension by selectingit using the extension selector.

Debugging an Extension

Debug a running Python script using one of the following methods.

203Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Debugging an Extension

Page 212: ANSYS ACT Developers Guide

Debugging with Microsoft® Visual StudioUsing Python Tools for Visual Studio®

Debugging with Microsoft® Visual Studio

If you have Microsoft Visual Studio, it is possible to use it to debug IronPython script.

Start Visual Studio, and attach it to the process AnsysWORKBENCHU.exe to debug an extension runninginto Mechanical.

Before attaching the process to Visual Studio, make sure you are using the correct select code. TheManaged (v.4.0) option must be selected.

After attach, you can open your Python code and set some breakpoints into it.

Using Python Tools for Visual Studio®

To ease the development of ACT extensions, we recommend you use the application Python Tools forVisual Studio (PTVS).

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.204

Development and Debugging Tips

Page 213: ANSYS ACT Developers Guide

Python Tools for Visual Studio (PTVS) is a free tool hosted by CodePlex.

Before installing PTVS, download and install Visual Studio 2010 Shell Isolated Mode Redistributablepackage.

http://www.microsoft.com/downloads/en/details.aspx?familyid=8E5AA7B6-8436-43F0-B778-00C3BCA733D3&displaylang=en

Then, download PTVS and install it.

http://pytools.codeplex.com/

You can use any version of Visual Studio from 2010 and above to develop and debug your ACT exten-sions.

205Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Debugging an Extension

Page 214: ANSYS ACT Developers Guide

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.206

Page 215: ANSYS ACT Developers Guide

Advanced Programming in C#

This section explains how to replace IronPython code with C# assemblies. C# is used in this documentbut any language that creates .NET assemblies can also be used for that purpose. This section assumesthat you already know how to create an assembly in C#.

C# provides two major advantages over IronPython:

• Better performance

• Superior development environment which provides auto completion.

Initialize the C# Project

Once you have created a C# project and associated the type "Class Library" with this project, add areference to the Ansys.ACT.Interfaces assembly of ACT. This DLL is located at

<ANSYS_INSTALL_DIR>/Addins/AdvancedAddinPackage/bin/<Platform/Ansys.ACT.In-terfaces.dll.

C# Implementation for a Load

The following XML file declares a load to be created in the ANSYS Mechanical application which requiresC# implementation:

<extension version="1" name="CSharp">

<author>ANSYS</author> <description>This extension demonstrates how to use CSharp to write extension.</description>

<assembly src="CSharp.dll" namespace="CSharp" />

<interface context="Mechanical">

<images>images</images>

</interface>

<simdata context="Mechanical">

<load name="CSharpLoad" caption="CSharp Load" version="1" icon="tload" unit="Temperature" color="#0000FF" class="CSharp.Load"> <property name="Geometry" control="scoping"> <attributes> <selection_filter>face</selection_filter> </attributes> </property> </load>

<result name="CSharpResult" caption="CSharp Result" version="1" unit="Temperature" icon="tload" location="node" type="scalar" class="CSharp.Result"> <property name="Geometry" control="scoping" /> </result>

</simdata>

207Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 216: ANSYS ACT Developers Guide

</extension>

In the definition of the load object, the only change is the use of the attribute class. This attribute mustbe set to the name of the class to be used for the integration of the load.

The CSharp.Load class is described below:

using System;using System.Collections.Generic;using System.Linq;using System.Text;using Ansys.ACT.Interfaces.Mechanical;using Ansys.ACT.Interfaces.UserObject;

namespace CSharp{ public class Load { IMechanicalExtAPI _ExtAPI = null;

public Load(IMechanicalExtAPI extApi,IUserLoad load) { _ExtAPI = extApi; }

public IEnumerable<double> getnodalvaluesfordisplay(ISimLoad load, IEnumerable<int> nodeIds) { List<double> res = new List<double>();

var mesh = load.Analysis.MeshData; foreach (int nodeId in nodeIds) { var node = mesh.NodeById(nodeId); res.Add(Math.Sqrt(node.X * node.X + node.Y * node.Y + node.Z * node.Z)); }

return res; } }}

To implement a callback in C#, create a new method in your class with the name of the callback inlower case.

In the example, you implement the callback <getnodalvaluesfordisplay> by adding the methodgetnodalvaluesfordisplay to the class.

C# Implementation for a Result

The following XML file declares a result to be created in the ANSYS Mechanical application which requiresC# implementation:

<extension version="1" name="CSharp">

<author>ANSYS</author> <description>This extension demonstrates how to use CSharp to write extension.</description>

<assembly src="CSharp.dll" namespace="CSharp" />

<interface context="Mechanical">

<images>images</images>

</interface>

<simdata context="Mechanical">

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.208

Advanced Programming in C#

Page 217: ANSYS ACT Developers Guide

<load name="CSharpLoad" caption="CSharp Load" version="1" icon="tload" unit="Temperature" color="#0000FF" class="CSharp.Load"> <property name="Geometry" control="scoping"> <attributes> <selection_filter>face</selection_filter> </attributes> </property> </load>

<result name="CSharpResult" caption="CSharp Result" version="1" unit="Temperature" icon="tload" location="node" type="scalar" class="CSharp.Result"> <property name="Geometry" control="scoping" /> </result>

</simdata>

</extension>

For the load definition, the attribute class must be set to the name of the class to be used for theintegration of the result.

The CSharp.Result class is described below:

using System;using System.Collections.Generic;using System.Linq;using System.Text;using Ansys.ACT.Interfaces.Mechanical;using Ansys.ACT.Interfaces.Post;using Ansys.ACT.Interfaces.UserObject;

namespace CSharp{ public class Result { internal double[] res = new double[1];

public Result(IMechanicalExtAPI extApi, IUserResult result) { }

public void evaluate(IUserResult entity, IStepInfo stepInfo, IResultCollector collector) { foreach (var id in collector.Ids) { res[0] = id; collector.SetValues(id, res); } } }}

As for the load definition, the implementation of a new callback simply requires you add a new methodwith the name of the callback.

209Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

C# Implementation for a Result

Page 218: ANSYS ACT Developers Guide

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.210

Page 219: ANSYS ACT Developers Guide

Limitations

You should be aware of the following limitations in the current version of ACT before developing yourextensions.

• Localization of ACT is limited to the languages currently supported in ANSYS Workbench. This limitationdoes not apply to the ability to manage various languages within the extension. For example, the propertynames created by an extension do not have to be in the same language as the current activated languagein ANSYS Workbench. There is no mechanism to integrate localization for the property names defined byan extension. You have to develop by yourself the localization if you want manage different languages foryour property names. Both regional settings based on the “.” or the “,” decimal symbol are available. However,the implementation of the extension should use the “.” symbol for any value defined at the XML or Pythonlevel.

• You cannot specify a layer number for layered elements when using the reader to get access to ANSYS results.Only the top of the top layer result and the bottom of the bottom layer results can be retrieved.

211Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 220: ANSYS ACT Developers Guide

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.212

Page 221: ANSYS ACT Developers Guide

Examples

ACT supports application customization by exposing a set of interfaces for each supported application.So far this discussion has focused on making simple additions to the ANSYS user interface and specifyingqueries into the simulation project datum. This chapter focuses on more advanced usages of the APIfor the data model of ANSYS Mechanical and ANSYs DesignXplorer. The examples in this section buildupon the methods and techniques discussed in the previous chapters.

ANSYS Mechanical Extension Examples

Von-Mises Stress as a Custom Result

The example provided in this section reproduces the result for the averaged Von Mises equivalent stress.This result is already available in the standard results that can be selected in ANSYS Mechanical. Thisexample is given to demonstrate how you can define a custom result.

First, consider the support required in XML for the definition of the custom result. The interface XMLelement contains information to add a toolbar and a toolbar button to the user interface. The callbackfunction <Create_Mises_Result> gets called when the toolbar button is clicked. Next the simdataXML element is defined. The child XML element result encapsulates the information needed for thecustom result. One result level callback function is declared. The XML evaluate element provides thename of the function that is called when the custom result (Von Mises Equivalent Stress) needs to becomputed and stored. This function is called when the custom result values are queried for graphicaldisplay. The XML property element defines one property to be added in the Details pane of the customresult. For this example, the property integrates a scoping method in the custom result.

<extension version="1" name="Mises">

<script src="main.py" />

<interface context="Mechanical"> <images>images</images> <toolbar name="Von Mises Stress" caption="Von Mises Stress"> <entry name="Von Mises Stress" icon="result"> <callbacks> <onclick>Create_Mises_Result</onclick> </callbacks> </entry> </toolbar> </interface>

<simdata context="Mechanical">

<result name="Von Mises Stress" version="1" caption="Von Mises Stress" unit="Stress" icon="result" location="node" type="scalar">

<callbacks> <evaluate>Mises_At_Nodes_Eval</evaluate> </callbacks>

<property name="Geometry" caption="Geometry" control="scoping"></property>

</result> </simdata>

213Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 222: ANSYS ACT Developers Guide

</extension>

Figure 72: Von-Mises Stress Details (p. 214) shows how the toolbar and result are added to the ANSYSMechanical user interface.

Figure 72: Von-Mises Stress Details

The Python script for the Mises extension, shown below, defines a callback function named <Cre-ate_Mises_Result>. When activated by the Von Mises Stress toolbar button, this callback createsthe result "Von Mises Stress." The callback invokes the Create_Mises_Result method on thesimDataMgr interface. The Mises.xml file provides the details needed to create the Von MisesStress toolbar/button and result.

In addition, the main.py file contains all the Python functions useful for this extension.

At the top of the script is the list definition for the node adjacency tables. The list, named "link," is alist of hash maps. Each hash map uses as its hash key the numeral corresponding to the type returnedby the IElement Type property. The value for hash map is a list of arrays. The names of the arraysmatch the local node numbers for a typical element of the key (element-type). Finally, the content ofeach array provides the adjacent local node numbers for the corresponding elements node. This list ofarrays makes this extension compatible with all the different element topologies that Mechanical willpotentially create during the mesh generation.

The XML definition for "Von Mises Stress" specifies one other callback that we see in the Python script.This callback is:

<evaluate>Mises_At_Nodes_Eval<evaluate>

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.214

Examples

Page 223: ANSYS ACT Developers Guide

The <evaluate> callback associated with the Mises_At_Nodes_Eval function is invoked as theresult of an event thrown by the ANSYS Mechanical application. The Mises_At_Nodes_Evalunctioncomputes the appropriate stress results and stores them. (The comments in the script below describethe algorithm used.) It returns the nodal results set stored for the specified node ID. This callback isused by the graphics system to display the results.

The Python script example also demonstrates the use of utility sub-functions. Using sub-functions toperform common repetitive task helps to make the script modular and more understandable. The utilitysub-functions used in here are Mises and EigenValues. Mises is called byMises_At_Nodes_Eval and returns the computed equivalent stress for a given stress tensor(SX,SY,SZ,SXY,SXZ,SYZ). The function EigenValues is used by the Mises function to compute theEigen vectors for a given stress tensor.

import unitsimport math

if ExtAPI.Context == 'Mechanical':

link = {} #kHex20 link.Add(ElementTypeEnum.kHex20,{ 0:[3,1,4], 1:[0,2,5], 2:[1,3,6], 3:[2,0,7], 4:[5,0,7], 5:[1,4,6], 6:[5,7,2], 7:[6,3,4], 8:[0,1], 9:[1,2], 10:[2,3], 11:[3,0], 12:[4,5], 13:[5,6], 14:[6,7], 15:[7,4], 16:[0,4], 17:[1,5], 18:[2,6], 19:[3,7]}) #kHex8 link.Add(ElementTypeEnum.kHex8,{ 0:[3,1,4], 1:[0,2,5], 2:[1,3,6], 3:[2,0,7], 4:[5,0,7], 5:[1,4,6], 6:[5,7,2], 7:[6,3,4]}) #kPyramid13 link.Add(ElementTypeEnum.kPyramid13,{ 0:[3,1,4], 1:[0,2,4], 2:[1,3,4], 3:[2,0,4], 4:[0,1,2,3], 5:[0,1], 6:[1,2], 7:[2,3], 8:[3,0], 9:[0,4], 10:[1,4], 11:[2,4], 12:[3,4]}) #kPyramid5 link.Add(ElementTypeEnum.kPyramid5,{ 0:[3,1,4], 1:[0,2,4], 2:[1,3,4], 3:[2,0,4], 4:[0,1,2,3]}) #kQuad4 link.Add(ElementTypeEnum.kQuad4, { 0:[3,1], 1:[0,2], 2:[1,3], 3:[2,0]}) #kQuad8 link.Add(ElementTypeEnum.kQuad8, { 0:[3,1], 1:[0,2], 2:[1,3], 3:[2,0], 4:[0,1], 5:[1,2], 6:[2,3], 7:[3,0]}) #kTet10 link.Add(ElementTypeEnum.kTet10,{ 0:[2,1,3], 1:[0,2,3], 2:[1,0,3], 3:[0,1,2], 4:[0,1], 5:[1,2], 6:[2,0], 7:[0,3], 8:[1,3], 9:[2,3]}) #kTet4 link.Add(ElementTypeEnum.kTet4, { 0:[2,1,3], 1:[0,2,3], 2:[1,0,3], 3:[0,1,2]}) #kTri3 link.Add(ElementTypeEnum.kTri3, { 0:[2,1], 1:[0,2], 2:[1,0]}) #kTri6 link.Add(ElementTypeEnum.kTri6, { 0:[2,1], 1:[0,2], 2:[1,0], 3:[0,1], 4:[1,2], 5:[2,3]}) #kWedge15 link.Add(ElementTypeEnum.kWedge15,{ 0:[2,1,3], 1:[0,2,4], 2:[1,0,5], 3:[5,4,0], 4:[3,5,1], 5:[4,3,2], 6:[0,1], 7:[1,2], 8:[2,0], 9:[3,4], 10:[4,5], 11:[5,3], 12:[0,3], 13:[1,4], 14:[2,5]}) #kWedge6 link.Add(ElementTypeEnum.kWedge6,{ 0:[2,1,3], 1:[0,2,4], 2:[1,0,5], 3:[5,4,0], 4:[3,5,1], 5:[4,3,2]})

def Create_Mises_Result(analysis): analysis.CreateResultObject("Von Mises Stress")

# This function evaluates the specific result (i.e. the Von-Mises stress) on each element # required by the geometry selection# The input data "step" represents the step on which we have to evaluate the resultdef Mises_At_Nodes_Eval(result, stepInfo, collector):

ExtAPI.Log.WriteMessage("Launch evaluation of the Mises result at nodes: ") # Reader initialization reader = result.Analysis.GetResultsData() step = int(stepInfo.Set)

215Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

ANSYS Mechanical Extension Examples

Page 224: ANSYS ACT Developers Guide

reader.CurrentResultSet = step

# Get the stress result from the reader stress = reader.GetResult("S") unit_stress = stress.GetComponentInfo("X").Unit conv_stress = units.ConvertUnit(1.,unit_stress,"Pa","Stress")

# Get the selected geometry prop_geo = result.Properties["Geometry"] ref_ids = prop_geo.Value.Ids

nodal_stress = [0.] * 6

# Get the mesh of the model mesh = result.Analysis.MeshData

# Loop on the list of the selected geometrical entities for ref_id in ref_ids: # Get mesh information for each geometrical entity mesh_region = mesh.MeshRegionById(ref_id) node_ids = mesh_region.NodeIds

# Loop on the nodes related to the current geometrical refId for node_id in node_ids:

for i in range(6): nodal_stress[i] = 0.

element_ids = mesh.NodeById(node_id).ConnectedElementIds num = 0 # Loop on the elements related to the current node for element_id in element_ids: # Get the stress tensor related to the current element tensor = stress.ElementValue(element_id,"X;Y;Z;XY;XZ;YZ")

element = mesh.ElementById(element_id) # Look for the position of the node nodeId in the element element_id # cpt contains this position cpt = element.NodeIds.IndexOf(node_id)

# for corner nodes, cpt is useless. # The n corner nodes of one element are always the first n nodes of the list if cpt < element.CornerNodeIds.Count: for i in range(6): nodal_stress[i] = nodal_stress[i] + tensor[6*cpt+i] else: # For midside nodes, cpt is used and the link table provides the two neighbouring # corner nodes for the midside node identified in the list by cpt itoadd = link[element.Type][cpt] for ii in itoadd: for i in range(6): nodal_stress[i] = nodal_stress[i] + tensor[6*ii+i] / 2.

num += 1

# The average stress tensor is computed before to compute the Von-Mises stress # num is the number of elements connected with the current node node_id for i in range(6): nodal_stress[i] *= conv_stress / num

# Von-Mises stress computation vm_stress = Mises(nodal_stress) # Result storage if node_id in collector.Ids: collector.SetValues(node_id, [vm_stress])

# This function computes the Von-Mises stress from the stress tensor# The Von-Mises stess is computed based on the three eigenvalues of the stress tensor def Mises(tensor):

# Computation of the eigenvalues

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.216

Examples

Page 225: ANSYS ACT Developers Guide

(S1, S2, S3) = Eigen_Values(tensor) return sqrt( ( (S1-S2)*(S1-S2) + (S2-S3)*(S2-S3) + (S1-S3)*(S1-S3) ) / 2. )

# This function computes the three eigenvalues of one [3*3] symetric tensorEPSILON = 1e-4def Eigen_Values(tensor):

a = tensor[0] b = tensor[1] c = tensor[2] d = tensor[3] e = tensor[4] f = tensor[5]

if ((abs(d)>EPSILON) or (abs(e)>EPSILON) or (abs(f)>EPSILON)): # Polynomial reduction A = -(a+b+c) B = a*b+a*c+b*c-d*d-e*e-f*f C = d*d*c+f*f*a+e*e*b-2*d*e*f-a*b*c

p = B-A*A/3 q = C-A*B/3+2*A*A*A/27 R = sqrt(fabs(p)/3) if q < 0: R = -R

z = q/(2*R*R*R) if z < -1. : z = -1. elif z > 1.: z = 1. phi = acos(z)

S1 = -2*R*cos(phi/3)-A/3 S2 = -2*R*cos(phi/3+2*math.pi/3)-A/3 S3 = -2*R*cos(phi/3+4*math.pi/3)-A/3 else: S1 = a S2 = b S3 = c

return (S1, S2, S3)

An Edge-Node Coupling Tool

The example provided in this section creates a tool that can be used to couple two set of nodes relatedto two edges. This example is given to demonstrate how you can develop your own pre-processingfeature (such as a custom load) to address one specific need.

The name chosen for this extension is "Coupling." Shown below is an XML file that defines the customload. Just as we have seen in previous examples, interface XML element contains information to add atoolbar and a toolbar button to the user interface. The callback function named <CreateCoupling>gets called when the toolbar button is clicked. Next the simdata XML element is defined. The child XMLelement load encapsulates the information that defines the support. Of particular importance is thatthe issupport attribute value is set to "true." The issupport attribute tells ANSYS Mechanical whichtype of boundary condition to apply. Three result level callback functions are declared. The functionSolveCmd is registered and called for an event that gets fired when the solver input is being written.The ShowCoupling and HideCoupling functions are registered and called for events used to syn-chronize tree view selections with the content of the graphics pane. The details needed to define theinputs and behavior of this special load consists of the three properties, "Source", "Target" and "Reverse,"along with their behavioral callbacks.

<extension version="1" name="Coupling"><guid shortid="Coupling">e0d5c579d-0263-472a-ae0e-b3cbb9b74b6c</guid> <script src="main.py" /> <interface context="Mechanical"> <images>images</images>

217Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

ANSYS Mechanical Extension Examples

Page 226: ANSYS ACT Developers Guide

<toolbar name="Coupling" caption="Coupling"> <entry name="Coupling" icon="support">

<callbacks> <onclick>CreateCoupling</onclick> </callbacks> </entry> </toolbar> </interface>

<simdata context="Mechanical">

<load name="Coupling" version="1" caption="Coupling" icon="support" issupport="true" color="#FF0000"> <callbacks> <getsolvecommands>SolveCmd</getsolvecommands> <onshow>ShowCoupling</onshow> <onhide>HideCoupling</onhide> </callbacks>

<property name="Source" caption="Source" control="scoping"> <attributes selection_filter="edge" /> <callbacks> <isvalid>IsValidCoupledScoping</isvalid> <onvalidate>OnValidateScoping</onvalidate> </callbacks> </property>

<property name="Target" caption="Target" control="scoping"> <attributes selection_filter="edge" /> <callbacks> <isvalid>IsValidCoupledScoping</isvalid> <onvalidate>OnValidateScoping</onvalidate> </callbacks> </property>

<property name="Reverse" caption="Reverse" control="select" default="No"> <attributes options="No,Yes" /> <callbacks> <onvalidate>OnValidateReverse</onvalidate> </callbacks> </property> </load> </simdata></extension>

Figure 73: Fully-defined Coupling in Mechanical (p. 219) shows how a fully defined coupling appears inANSYS Mechanical.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.218

Examples

Page 227: ANSYS ACT Developers Guide

Figure 73: Fully-defined Coupling in Mechanical

The Python script for the Coupling extension, shown below, defines a callback function named <Create-Coupling>. When activated by the Coupling toolbar button, this callback creates the load "Coupling."The callback invokes the “CreateLoadObject” method for the current analysis. The function “SolveCmd”is called when the solver input is being generated. “SolveCmd” invokes “GetListNodes” to obtain twolists of nodeids corresponding to the Target and Source edges. These nodeids are then used to writeAPDL CP commands to the solver input. “GetListNodes” is also invoked by the <ShowCoupling> callbackfunction. In <ShowCoupling>, the IGraphics interface is used to create a graphics context. Using theobject returned, the inter-nodal lines are drawn to provide a visual representation of the coupling.

The graphics context associated with this custom load and the validation of the user inputs impose tomanage more various situations than for the first example described in the previous section. This explainswhy more functions and sub-functions are required for this example.

import graphics

def CreateCoupling(analysis): analysis.CreateLoadObject("Coupling")

#-------------------------------# Callbacks#-------------------------------

def OnValidateReverse(load, prop): ShowCoupling(load)

def OnValidateScoping(load, prop): ShowCoupling(load)

def IsValidScoping(load, prop):

if not prop.Controller.isvalid(load, prop): return False

selection = prop.Value if selection == None: return False if selection.Ids.Count != 1: return False return True

219Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

ANSYS Mechanical Extension Examples

Page 228: ANSYS ACT Developers Guide

def IsValidCoupledScoping(load, prop):

sProp = load.Properties["Source"] tProp = load.Properties["Target"]

if not IsValidScoping(load, sProp): return False if not IsValidScoping(load, tProp): return False

sIds = sProp.Value.Ids tIds = tProp.Value.Ids

try: mesh = load.Analysis.MeshData sNum = mesh.MeshRegionById(sIds[0]).NodeCount tNum = mesh.MeshRegionById(tIds[0]).NodeCount if sNum == 0 or tNum == 0: return False except: return False

return sNum == tNum

#-------------------------------# Show / Hide#-------------------------------

graphicsContext = {}def getContext(entity): global graphicsContext if entity.Id in graphicsContext : return graphicsContext[entity.Id] else : return None

def setContext(entity, context): global graphicsContext graphicsContext[entity.Id] = context

def delContext(entity): context = getContext(entity) if context != None : context.Visible = False context = None setContext(entity, None)

def ShowCoupling(load): delContext(load) ctxCoupling = ExtAPI.Graphics.CreateAndOpenDraw3DContext()

sourceColor = load.Color targetColor = 0x00FF00 lineColor = 0x0000FF

sProp = load.Properties["Source"] ; sSel = sProp.Value tProp = load.Properties["Target"] ; tSel = tProp.Value

ctxCoupling.LineWeight = 1.5 if sSel != None: ctxCoupling.Color = sourceColor for id in sSel.Ids: graphics.DrawGeoEntity(ExtAPI, load.Analysis.GeoData, id, ctxCoupling) if tSel != None: ctxCoupling.Color = targetColor for id in tSel.Ids: graphics.DrawGeoEntity(ExtAPI, load.Analysis.GeoData, id, ctxCoupling)

if IsValidSelections(load):

ctxCoupling.Color = lineColor ctxCoupling.LineWeight = 1.5

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.220

Examples

Page 229: ANSYS ACT Developers Guide

mesh = load.Analysis.MeshData sList, tList = GetListNodes(load)

for sId, tId in zip(sList, tList): sNode = mesh.NodeById(sId) tNode = mesh.NodeById(tId) ctxCoupling.DrawPolyline([sNode.X,sNode.Y,sNode.Z,tNode.X,tNode.Y,tNode.Z])

ctxCoupling.Close() ctxCoupling.Visible = True setContext(load, ctxCoupling)

def HideCoupling(load): delContext(load)

#-------------------------------# Commands#-------------------------------

def SolveCmd(load, s): s.WriteLine("! Coupling - CP") sList, tList = GetListNodes(load) for sId, tId in zip(sList, tList): s.WriteLine("CP,NEXT,ALL,{0},{1}", sId, tId)

#-------------------------------# Utils#-------------------------------

def IsValidSelections(load): return load.Properties["Source"].IsValid and load.Properties["Target"].IsValid

def GetListNodes(load):

if IsValidSelections(load):

sProp = load.Properties["Source"] ; sIds = sProp.Value.Ids tProp = load.Properties["Target"] ; tIds = tProp.Value.Ids

geometry = ExtAPI.DataModel.GeoData mesh = load.Analysis.MeshData

sList = GetSubListNodes(geometry, mesh, sIds[0]) tList = GetSubListNodes(geometry, mesh, tIds[0])

rev = False r = load.Properties["Reverse"].Value if r == "Yes": rev = True

sList = sorted(sList, key=sList.get) tList = sorted(tList, key=tList.get, reverse=rev)

return (sList, tList)

def GetSubListNodes(geometry, mesh, refId):

entity = geometry.GeoEntityById(refId) region = mesh.MeshRegionById(refId)

result = {} pt = System.Array.CreateInstance(System.Double, 3)

for nodeId in region.NodeIds: node = mesh.NodeById(nodeId) pt[0], pt[1], pt[2] = (node.X, node.Y, node.Z) result[nodeId] = entity.ParamAtPoint(pt)

return result

221Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

ANSYS Mechanical Extension Examples

Page 230: ANSYS ACT Developers Guide

DesignXplorer Extension Examples

DOE Extension Examples

The ACT Developer’s Guide is supplemented by a package of examples DOEExtensionExamples.zip)that illustrate a few solutions to implement a sampling extension with different programming languages.The package contains instructions to install and build each extension and can be found in the ExtensionsLibrary of the ANSYS Customer Portal.

The following examples are included:

DescriptionExample Name

Fully implemented in IronPython (no build required), this exampleis your sandbox. It illustrates many sampling extension featuresand is definitely the best example to start with.

PythonSampling

PythonSampling is running a simple random exploration ofthe parametric space, generating the number of points requestedby the user.

This example demonstrates how an extension can be completelyset up when the ISamplingMethod interface is implementedin C#.

CSharpSampling

Note that the optimization algorithm is also implemented in C#,but one could use only the ISamplingMethod implementationas an adapter to an existing implementation in C# or otherlanguages.

The project is provided for Microsoft Visual Studio 2010.

Optimization Extension Examples

The ACT Developer's Guide is supplemented by a package of examples (OptimizationExten-sionExamples.zip) that illustrate a few solutions to implement an optimization extension withdifferent programming languages. The package contains instructions to install and build each extensionand can be found in the Extensions Library of the ANSYS Customer Portal.

The following examples are included:

DescriptionExample Name

Fully implemented in IronPython (no build required), this exampleis your sandbox. It illustrates many optimization extension featuresand is definitely the best example to start with.

PythonOptimizer

PythonOptimizer is running a simple random exploration ofthe parametric space, generating the number of points requestedby the user and returning the best candidates found.

This example demonstrates how an extension can be completelyset up when the IOptimizationMethod interface isimplemented in C#.

CSharpOptimizer

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.222

Examples

Page 231: ANSYS ACT Developers Guide

Note that the optimization algorithm is also implemented in C#,but one could use only the IOptimizationMethodimplementation as an adapter to an existing implementation inC# or other languages.

The project is provided for Microsoft Visual Studio 2010.

This example demonstrates how an extension can be implementedfrom existing C/C++. The IOptimizationMethod interface is

CppOptimizer

implemented in IronPython as a wrapper to the C++ symbols, usingthe ctypes foreign function library for Python.

Custom ACT Workflows in Workbench Examples

Custom User-Specified GUI Operation

This custom Workbench workflow example implements a custom GUI operation for a task (specifically,the addition of a custom context menu). This functionality is valuable when you require menu entriesbeyond the default Edit menu created by the definition of the <onedit> callback.

Figure 74: Custom GUI Operation Schematic View

XML Extension Defintion File

The XML extension definition file (EmptyGUI.xml) performs the following actions:

• References the IronPython script empty_gui.py.

• Defines a single task in the <tasks> block. Within this block, a single context menu is defined in the<contextmenus> block. Note that it has the <onclick> callback defined, as required.

• Defines the inputs and outputs in the <inputs> and <outputs> blocks. Note that an empty input andan output are defined.

• Defines a single taskgroup which contains a single task in the <taskgroups> block.

223Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom ACT Workflows in Workbench Examples

Page 232: ANSYS ACT Developers Guide

The file, EmptyGUI.xml, contains the following code:

<extension version="1" name="EmptyGUI"> <guid shortid="EmptyGUI">69d0095b-e138-4841-a13a-de12238c83f6</guid> <script src="empty_gui.py" /> <interface context="Project"> <images>images</images> </interface> <workflow name="wf3" context="Project" version="1"> <tasks> <task name="Empty" caption="Empty" icon="Generic_cell" version="1"> <callbacks> <onupdate>update</onupdate> </callbacks> <inputs> <input/> </inputs> <outputs/> <contextmenus> <entry name="Empty Gui Op" type="ContextMenuEntry" priority="1.0" icon="default_op" version="1"> <callbacks> <onclick>click</onclick> </callbacks> </entry> </contextmenus> </task> </tasks> <taskgroups> <taskgroup name="Empty" caption="Empty" icon="Generic" category="ACT Custom Workflows" abbreviation="MT" version="1"> <includeTask name="Empty" caption="Empty"/> </taskgroup> </taskgroups> </workflow></extension>

IronPython Script

The IronPython script (empty_gui.py) contains the Python code the task executes from the contextmenu and update callbacks.

Since the XML extension definition file has both the <onupdate> and <onclick> callbacks, the updateand click methods are defined in the script.

The file, empty_gui.py, contains the following code:

import clrclr.AddReference("Ans.UI.Toolkit")clr.AddReference("Ans.UI.Toolkit.Base")import Ansys.UI.Toolkit

def click(container): Ansys.UI.Toolkit.MessageBox.Show("Empty Test!")def update(container, context): print 'empty update'

Custom, Lightweight, External Application Integration with ParameterDefinition

The following custom Workbench workflow example illustrates the use of parameter definitions to in-tegrate an external application.

Driven by parameters defined in the XML extension definition file, the external application squares thevalue of an input number, which is displayed in the Parameter Set tab. The external application updates

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.224

Examples

Page 233: ANSYS ACT Developers Guide

the output parameter to the computed square value. The use of parameters in this example enablesyou to leverage DesignXplorer functionality.

Figure 75: Squares Example Schematic View

Figure 76: Squares Example in Parameter Set Tab

XML Extension Definiton File

The extension definition XML file (Squares.xml) performs the following actions:

• References the IronPython script Squares.py.

• Defines a single task in the <tasks> block.

• Defines the inputs and outputs in the <inputs> and <outputs> blocks. Note that an empty inputis defined.

225Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom ACT Workflows in Workbench Examples

Page 234: ANSYS ACT Developers Guide

• Defines two parameters in the <parameters> block.

• Defines a single taskgroup which contains a single task in the <taskgroups> block.

The file, Squares.xml, contains the following code:

<extension version="1" name="Squares"> <guid shortid="Squares">69d0095b-e138-4841-a13a-de12238c83f4</guid> <script src="squares.py" /> <interface context="Project"> <images>images</images> </interface> <workflow name="wf1" context="Project" version="1"> <tasks> <task name="Squares" caption="Squares" icon="squares_component" version="1"> <callbacks> <onupdate>update</onupdate> </callbacks> <inputs> <input/> </inputs> <outputs/> <parameters> <parameter name="Input" caption="Input" usage="Input" control="Double" version="1"/> <parameter name="Output" caption="Output" usage="Output" control="Double" version="1"/> </parameters> </task> </tasks> <taskgroups> <taskgroup name="Squares" caption="Squares" icon="squares" category="ACT Custom Workflows" abbreviation="SQRS" version="1"> <includeTask name="Squares" caption="Squares"/> </taskgroup> </taskgroups> </workflow></extension>

IronPython Script

The IronPython script (Squares.py) performs the following actions:

• Obtains the parameters.

• Prepares the inputs.

• Writes the input file.

• Runs the external solver.

• Reads the output file.

• Sets the parameters to the calculated solver values.

Since the XML extension definition file has <onupdate> callback, the update method is defined inthe script. All ACT workflow callbacks get a container (for the task) and a context.

The file, Squares.py, contains the following code:

import clrclr.AddReference("Ans.Utilities")clr.AddReference("Ans.Core")import Ansys.Utilitiesimport Ansys.Core

#convenience method to look up parameters based on a predetermined ID

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.226

Examples

Page 235: ANSYS ACT Developers Guide

def GetParameterByName(parameters, id): match = None for param in parameters: if param.ParameterName == id: match = param break return match

def update(container, context): activeDir = container.GetActiveDirectory() extensionDir = ExtAPI.ExtensionManager.CurrentExtension.InstallDir exeName = "ExampleAddinExternalSolver.exe" solverPath = System.IO.Path.Combine(extensionDir, exeName)

#get parameters owned by container

params = None lock = context.ContainerReadLock(container) params = context.Project.GetDataReferencesByType(container, "ParameterAdapter") lock.Dispose()

#isolate specific parameters

inputParam = GetParameterByName(params, "Input") outputParam = GetParameterByName(params, "Output")

#prep i/o file paths

inputFileName = "input.txt" outputFileName = "output.txt" dpInputFile = System.IO.Path.Combine(activeDir, inputFileName) dpOutputFile = System.IO.Path.Combine(activeDir, outputFileName)

#write input file

if inputParam != None and outputParam != None: val = inputParam.Value #write input file f = open(dpInputFile, "w") f.write('input='+val.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)) f.close()

#run exe

runInMono = Ansys.Utilities.ApplicationConfiguration.DefaultConfiguration.IsRuntimeMono monoPath = "mono" monoArgs = System.String.Format("{0} \"{1}\" \"{2}\"", solverPath, dpInputFile, dpOutputFile) info = None if runInMono: info = System.Diagnostics.ProcessStartInfo(monoPath, monoArgs) else: info = System.Diagnostics.ProcessStartInfo(solverPath, System.String.Format("\"{0}\" \"{1}\"", dpInputFile, dpOutputFile)) info.CreateNoWindow = True info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized p = System.Diagnostics.Process.Start(info) p.WaitForExit()

#read output file

outValue = None f = open(dpOutputFile, "r") currLine = f.readline() while currLine != "": valuePair = currLine.split('=') outValue = System.Int32.Parse(valuePair[1], System.Globalization.NumberFormatInfo.InvariantInfo) currLine = f.readline() f.close()

#set output value

if outValue == None:

227Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom ACT Workflows in Workbench Examples

Page 236: ANSYS ACT Developers Guide

raise Exception("Error in update - no output value detected!") else: outputParam.Value = outValue

Custom, Lightweight, External Application Integration with Custom Data

The following custom Workbench workflow example illustrates the use of custom task properties tointegrate an external application.

Driven by the custom task properties defined in the XML extension definition file, the external applicationsquares the value of an input number, which is displayed in the Parameter Set tab. The external applic-ation updates the custom property values to the computed square value. This example also illustratesprogress and project reporting functionality.

Figure 77: Data Squares Example Schematic View

Figure 78: Data Squares Example Properties

XML Extension Definiton File

The extension definition XML file (DataSquares.xml) performs the following actions:

• References the IronPython script datasquares_complete.py.

• Defines a single task in the <tasks> block.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.228

Examples

Page 237: ANSYS ACT Developers Guide

• Defines the <onreport> callback, which is called when the user generates a project report. This allowsthe task to access the report object and add its own task-specific reporting content.

• Defines the inputs and outputs in the <inputs> and <outputs> blocks. Note that an empty inputis defined.

• Defines two properties in the <properties> block.

• Defines a single taskgroup which contains a single task in the <taskgroups> block.

The file, DataSquares.xml, contains the following code:

<extension version="1" name="DataSquares"> <guid shortid="DataSquares">69d0095b-e138-4841-a13a-de12238c83f2</guid> <script src="datasquares_complete.py" /> <interface context="Project"> <images>images</images> </interface> <workflow name="MyWorkflow" context="Project" version="1"> <tasks> <task name="DataSquares" caption="Data Squares" icon="dsquares_component" version="1"> <callbacks> <onupdate>update</onupdate> <onstatus>status</onstatus> <onreport>report</onreport> </callbacks> <propertygroup name="Inputs"> <property name="Input" caption="Input" control="double" default="0.0" readonly="False" needupdate="true" visible="True" persistent="True" parameterizable="True" /> </propertygroup> <propertygroup name="Outputs"> <property name="Output" caption="Output" control="double" default="0.0" readonly="True" visible="True" persistent="True" parameterizable="True" /> </propertygroup> <inputs> <input/> </inputs> <outputs/> </task> </tasks> <taskgroups> <taskgroup name="DataSquares" caption="Data Squares" icon="dsquares" category="ACT Custom Workflows" abbreviation="DSQRS" version="1"> <includeTask name="DataSquares" caption="Data Squares"/> </taskgroup> </taskgroups> </workflow></extension>

IronPython Script

The IronPython script (dataquares_complete.py) performs the following actions:

• Calls GetActiveDirectory to obtain the task-specific project directory.

• Calls GetCustomEntity to obtain the data entity.

• Calls GetCustomEntityPropertyValue to obtain the input property value.

• Executes external solver.

• Sets outputVal based on the retrieved solver output file.

• Calls SetCustomEntityPropertyValue to update the output property to the solved value.

229Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom ACT Workflows in Workbench Examples

Page 238: ANSYS ACT Developers Guide

• Updates progress information throughout the update process.

The file, datasquares_complete.py, contains the following code:

def update(container, context): activeDir = container.GetActiveDirectory() extensionDir = ExtAPI.ExtensionManager.CurrentExtension.InstallDir exeName = "ExampleAddinExternalSolver.exe" solverPath = System.IO.Path.Combine(extensionDir, exeName)

monitor = context.ProgressMonitor monitor.BeginTask("Data Sqaures Solver", 3, None) monitor.TaskDetails = "Preparing solver input..." System.Threading.Thread.Sleep(2000) monitor.UpdateTask(1, None)

#get param values entity = ACT.GetCustomEntity(container) inputValue = ACT.GetCustomEntityPropertyValue(entity, "Input")

#prep i/o file paths

inputFileName = "input.txt" outputFileName = "output.txt" dpInputFile = System.IO.Path.Combine(activeDir, inputFileName) dpOutputFile = System.IO.Path.Combine(activeDir, outputFileName)

#write input file f = open(dpInputFile, "w") f.write('input='+inputValue.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)) f.close()

monitor.UpdateTask(1, None)

monitor.TaskDetails = "Executing Solver..." System.Threading.Thread.Sleep(2000)

#run exe

runInMono = Ansys.Utilities.ApplicationConfiguration.DefaultConfiguration.IsRuntimeMono monoPath = "mono" monoArgs = System.String.Format("{0} \"{1}\" \"{2}\"", solverPath, dpInputFile, dpOutputFile) info = None if runInMono: info = System.Diagnostics.ProcessStartInfo(monoPath, monoArgs) else: info = System.Diagnostics.ProcessStartInfo(solverPath, System.String.Format("\"{0}\" \"{1}\"", dpInputFile, dpOutputFile)) info.CreateNoWindow = True info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized p = System.Diagnostics.Process.Start(info) p.WaitForExit()

monitor.UpdateTask(1, None)

monitor.TaskDetails = "Retrieving results from solver..." System.Threading.Thread.Sleep(2000)

#read output file

outputValue = None f = open(dpOutputFile, "r") currLine = f.readline() while currLine != "": valuePair = currLine.split('=') outputValue = System.Int32.Parse(valuePair[1], System.Globalization.NumberFormatInfo.InvariantInfo) currLine = f.readline() f.close()

monitor.UpdateTask(1, None)

#set output value

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.230

Examples

Page 239: ANSYS ACT Developers Guide

if outputValue == None: raise Exception("Error in update - no output value detected!") else: ACT.SetCustomEntityPropertyValue(entity, "Output", outputValue) monitor.TaskDetails = "Solve completed..." System.Threading.Thread.Sleep(2000) monitor.EndTask(None)

import clrclr.AddReference("Ans.ProjectSchematic")clr.AddReference("ReportUtility.Interop")import Ansys.ReportUtility.Interopimport Ansys.ProjectSchematicdef status(container, context): status = Ansys.ProjectSchematic.Queries.ComponentState(Ansys.ProjectSchematic.State.Unfulfilled, "This is unfulfilled!") return None

def report(container, context, report): root = report.GetRootSection() section = Ansys.ReportUtility.Interop.ReportSection("My Custom ACT Task Report Content") text = Ansys.ReportUtility.Interop.ReportText("", "Sample text from the data squares component") section.AddChild(text) root.AddChild(section)

Material Transfer

This custom Workbench workflow example implements a material transfer taskgroup that passes MatML-formatted material data to a downstream Engineering Data taskgroup. This example also illustratesinput/output specification and file management capabilities.

Figure 79: Material Transfer Example Engineering Data View

231Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom ACT Workflows in Workbench Examples

Page 240: ANSYS ACT Developers Guide

Figure 80: Material Transfer Example Schematic View

XML Extension Definition File

The XML definition file (GenericMaterialTransferSystem.xml) defines a system named GenericMaterial, which appears in your custom system group in the Workbench Toolbox.

The XML extension definition file (GenericMaterialTransferSystem.xml) performs the followingactions:

• References the IronPython script generic_material_transfer.py.

• Defines a single task in the <tasks> block.

• Specifies that the <onupdate> callback calls the producer_update IronPython function, which accessesa materials file.

• Defines the inputs and outputs in the <inputs> and <outputs> blocks. Note that an empty input andan output are defined. The output type attribute is set to MatML31, specifying the kind of data exposedand generated by this task.

• Defines a single taskgroup which contains a single task in the <taskgroups> block.

The file, GenericMaterialTransferSystem.xml, contains the following code:

<extension version="1" name="GenericMaterialTransfer"> <guid shortid="GenericMaterialTransfer">69d0095b-e138-4841-a13a-de12238c83f8</guid> <script src="generic_material_transfer.py" /> <interface context="Project"> <images>images</images> </interface> <workflow name="wf5" context="Project" version="1"> <tasks> <task name="Material" caption="Material" icon="material_cell" version="1"> <callbacks> <onupdate>update</onupdate> </callbacks> <inputs> <input/> </inputs> <outputs> <output format="" type="MatML31"/> </outputs> </task> </tasks> <taskgroups> <taskgroup name="GenericMaterialTransfer" caption="Generic Material" icon="material_system" category="ACT Custom Workflows" abbreviation="GenMatXfer" version="1"> <includeTask name="Material" caption="Material"/> </taskgroup> </taskgroups> </workflow></extension>

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.232

Examples

Page 241: ANSYS ACT Developers Guide

IronPython Script

The IronPython script (generic_material_transfer.py ) contains the IronPython code thatprovides instructions for passing the MatML-formatted material data to a downstream EngineeringData taskgroup. This includes the update method (called by the <onupdate> callback in the XMLextension definition file), which accesses the SampleMaterials.xml file.

The file, generic_material_transfer.py, contains the following code:

def update(container, context): extensionDir = ExtAPI.ExtensionManager.CurrentExtension.InstallDir matFilePath = System.IO.Path.Combine(extensionDir, "Sample_Materials.xml") matFileRef = None isRegistered = IsFileRegistered(FilePath=matFilePath) if isRegistered == True: matFileRef = GetRegisteredFile(matFilePath) else: matFileRef = RegisterFile(FilePath=matFilePath) AssociateFileWithContainer(matFileRef, container) outputRefs = container.GetOutputData() matOutputSet = outputRefs["MatML31"] matOutput = matOutputSet[0] matOutput.TransferFile = matFileRef

Material File

This file (Sample_Materials.xml), accessed by the IronPython update method, contains theMatML-formatted material data:

<?xml version="1.0" encoding="UTF-8"?><EngineeringData version="16.1"> <Notes /> <Materials> <MatML_Doc> <Material> <BulkDetails> <Name>Sample Material</Name> <Description>Sample material from Driver</Description> <PropertyData property="pr0"> <Data format="string">-</Data> <ParameterValue parameter="pa0" format="float"> <Data>494.1474492,912.7972764,1172.453938,1941.495468,2803.754154,3869.063522,5245.395513,10378.82012,18192.58268,28438.67868,57755.1982,94951.87682,135751.6191,178064.7612,216504.4272,261538.9311,304701.5076,333300.2826,364061.2544,397079.5705,432533.1159,457543.8578,483751.5301</Data> <Qualifier name="Variable Type">Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent,Dependent</Qualifier> </ParameterValue> <ParameterValue parameter="pa1" format="float"> <Data>0.1338,0.2675,0.3567,0.6242,0.8917,1.1592,1.4268,2.051,2.586,3.0318,3.7898,4.3694,4.8153,5.172,5.4395,5.707,5.9299,6.0637,6.1975,6.3312,6.465,6.5541,6.6433</Data> <Qualifier name="Variable Type">Independent,Independent,Independent,Independent,Independent,Independent,Independent,Independent,Independent,Independent,Independent,Independent,Independent,Independent,Independent,Independent,Independent,Independent,Independent,Independent,Independent,Independent,Independent</Qualifier> </ParameterValue> </PropertyData> <PropertyData property="prDriver"> <Data format="string">-</Data> <Qualifier name="Data Link Version">1</Qualifier> <Qualifier name="Model Type">Linear;Isotropic</Qualifier> <Qualifier name="Sample Property">Value</Qualifier> </PropertyData> </BulkDetails> </Material> <Metadata> <ParameterDetails id="pa0"> <Name>Stress</Name>

233Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom ACT Workflows in Workbench Examples

Page 242: ANSYS ACT Developers Guide

<Units> <Unit> <Name>Pa</Name> </Unit> </Units> </ParameterDetails> <ParameterDetails id="pa1"> <Name>Strain</Name> <Units> <Unit> <Name>m</Name> </Unit> <Unit power="-1"> <Name>m</Name> </Unit> </Units> </ParameterDetails> <PropertyDetails id="pr0"> <Unitless /> <Name>Sample Property</Name> </PropertyDetails> <PropertyDetails id="prDriver"> <Unitless /> <Name>Driver Link Details</Name> </PropertyDetails> </Metadata> </MatML_Doc> </Materials> <Loads /> <BeamSections /></EngineeringData>

Mesh Transfer

This custom Workbench workflow example implements a mesh transfer taskgroup.

This taskgroup has both "consuming" and "providing" connections with existing ANSYS applications,consuming a mesh from an upstream Mesh taskgroup and passing it to a downstream Fluent taskgroup.It also illustrates input/output specification, file management capabilities, and the default Edit contextmenu.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.234

Examples

Page 243: ANSYS ACT Developers Guide

Figure 81: End-to-End Mesh Transfer Between Mesh, Mesher, and Fluent Setup

XML Extension Definition File

The XML extension definition file (GenericMeshTransfer.xml) defines a taskgroup named GenericMesh, which appears in your custom taskgroup in the Workbench Toolbox.

The XML extension definition file (GenericMeshTransfer.xml) performs the following actions:

• References the IronPython script generic_mesh_transfer.py.

• Defines a single task in the <tasks> block.

• Defines the <onedit> callback in the task block, which automatically creates a default Edit context menufor the task.

• Defines the an input and an output in the <inputs> and <outputs> blocks.

– The input has type set to MeshingMesh, indicating that the input data type will be a mesh.

– Both the input and output have format set to FluentMesh, specifying that the input and output fileswill have the same FluentMesh format.

• Defines a single taskgroup which contains a single task in the <taskgroups>> block..

The file, GenericMeshTransfer.xml, contains the following code:

235Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom ACT Workflows in Workbench Examples

Page 244: ANSYS ACT Developers Guide

<extension version="1" name="GenericMeshTransfer"> <guid shortid="GenericMeshTransfer">69d0095b-e138-4841-a13a-de12238c83f7</guid> <script src="generic_mesh_transfer.py" /> <interface context="Project"> <images>images</images> </interface> <workflow name="wf6" context="Project" version="1"> <tasks> <task name="Mesher" caption="Mesher" icon="GenericMesh_cell" version="1"> <callbacks> <onupdate>update</onupdate> <onedit>edit</onedit> </callbacks> <inputs> <input format="FluentMesh" type="MeshingMesh" count="1"/> <input/> </inputs> <outputs> <output format="FluentMesh" type="SimulationGeneratedMesh"/> </outputs> </task> </tasks> <taskgroups> <taskgroup name="GenericMeshTransfer" caption="Generic Mesh" icon="GenericMesh" category="ACT Custom Workflows" abbreviation="GenMeshXfer" version="1"> <includeTask name="Mesher" caption="Mesher"/> </taskgroup> </taskgroups> </workflow></extension>

IronPython Script

The IronPython script (generic_mesh_transfer.py ) contains the IronPython code that providesinstructions for passing the mesh data to the downstream Fluent taskgroup .

The file, generic_mesh_transfer.py, contains the following code:

import clrclr.AddReference("Ans.UI.Toolkit")clr.AddReference("Ans.UI.Toolkit.Base")import Ansys.UI.Toolkitdef update(container, context): print 'in system.py update method' #obtain input data upstreamData = container.GetInputDataByType(InputType="MeshingMesh") meshFileRef = None upstreamDataCount = upstreamData.Count if upstreamDataCount > 0: meshFileRef = upstreamData[0] #set our output so that we are just a pass through. outputRefs = container.GetOutputData() meshOutputSet = outputRefs["SimulationGeneratedMesh"] meshOutput = meshOutputSet[0] #meshOutput.MeshFile = meshFileRef meshOutput.TransferFile = meshFileRef #if no new data...nothing to process from upstream sources.def edit(container, context): Ansys.UI.Toolkit.MessageBox.Show("Test!")

Custom Transfer

This custom Workbench workflow example implements a custom transfer from a producing taskgroupto a consuming taskgroup, creating connections between custom tasks (no ANSYS installed products).It also illustrates the creation of single-task vs. multi-task task groups.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.236

Examples

Page 245: ANSYS ACT Developers Guide

Figure 82: Custom Transfer Example Schematic View

XML Extension Definition File

The XML extension definition file (CustomTransfer.xml) defines taskgroups named Producer,Consumer, and CompleteTransfer, all of which appear in the Workbench Toolbox.

Figure 83: Custom Transfer Example Toolbox Taskgroup Entry

The XML extension definition file (CustomTransfer.xml) performs the following actions:

• References the IronPython script customtransfer.py.

• Defines two tasks in the <tasks> block:Producer and Consumer.

• Defines three taskgroups in the <taskgroups> block:Producer,Consumer, and CompleteTransfer.The Producer and Consumer taskgroups each contain a single task. The CompleteTransfer taskgroupcontains two tasks.

The file, CustomTransfer.xml, contains the following code:

<extension version="1" name="CustomTransfer"> <guid shortid="CustomTransfer">69d0095b-e138-4841-a13a-de12238c83f3</guid> <script src="customtransfer.py" /> <interface context="Project"> <images>images</images> </interface>

237Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom ACT Workflows in Workbench Examples

Page 246: ANSYS ACT Developers Guide

<workflow name="wf4" context="Project" version="1"> <tasks> <task name="Producer" caption="Producer" icon="test_component" version="1"> <callbacks> <onupdate>producer_update</onupdate> </callbacks> <inputs> <input/> </inputs> <outputs> <output format="" type="MyData"/> </outputs> </task> <task name="Consumer" caption="consumer" icon="test_component" version="1"> <callbacks> <onupdate>consumer_update</onupdate> </callbacks> <inputs> <input/> <input format="" type="MyData"/> </inputs> <outputs/> </task> </tasks> <taskgroups> <taskgroup name="Producer" caption="Producer" icon="producer_system" category="ACT Custom Workflows" abbreviation="Producer" version="1"> <includeTask name="Producer" caption="Producer"/> </taskgroup> <taskgroup name="Consumer" caption="Consumer" icon="consumer_system" category="ACT Custom Workflows" abbreviation="Consumer" version="1"> <includeTask name="Consumer" caption="Consumer"/> </taskgroup> <taskgroup name="CompleteTransfer" caption="CompleteTransfer" icon="consumer_system" category="ACT Custom Workflows" abbreviation="CompleteTransfer" version="1"> <includeTask name="Producer" caption="Producer"/> <includeTask name="Consumer" caption="Consumer"/> </taskgroup> </taskgroups> </workflow></extension>

IronPython Script

The IronPython script (customtransfer.py) contains the Python code that provides update instruc-tions for the producing taskgroup and for the consuming task to obtain the output data from the up-stream producer.

The file, customtransfer.py, contains the following code:

def consumer_update(container, context): #obtain input data upstreamData = container.GetInputDataByType(InputType="MyData") fileRef = None upstreamDataCount = upstreamData.Count if upstreamDataCount > 0: fileRef = upstreamData[0] AssociateFileWithContainer(fileRef, container) #if no new data...nothing to process from upstream sources.

def producer_update(container, context): filePath = r"C:\Program Files\ANSYS Inc\v162\Addins\AdvancedAddinPackage\extensions\CustomTransfer\Sample_Materials.xml" fileRef = None isRegistered = IsFileRegistered(FilePath=filePath) if isRegistered == True: fileRef = GetRegisteredFile(filePath) else: fileRef = RegisterFile(FilePath=filePath) AssociateFileWithContainer(fileRef, container)

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.238

Examples

Page 247: ANSYS ACT Developers Guide

outputRefs = container.GetOutputData() outputSet = outputRefs["MyData"] myData = outputSet[0] myData.TransferFile = fileRef>

Parametric

The following custom Workbench workflow example illustrates the creation of a parametric taskgroupusing the isparametricgroup attribute. When this attribute is set to true , it indicates that thatthe taskgroup operates only on design points. As such, the taskgroup is added below the ParameterSet bar. The focus on parameters in this example enables you to incorporate DesignXplorer-like func-tionality.

Figure 84: Parametric Example Schematic View

XML Extension Definition File

The XML extension definition file (Parametric.xml) performs the following actions:

• References the IronPython script parametric.py.

• Defines a single task in the <tasks> block.

• Defines the inputs and outputs in the <inputs> and <outputs> blocks. Note that an empty input isdefined.

• Defines a single taskgroup which contains a single task in the <taskgroups> block. Note that the ispara-metricgroup attribute is set to true.

The file, Parametric.xml, contains the following code:

<extension version="1" name="Parametric"> <guid shortid="Parametric">69d0095b-e138-4841-a13a-de12238c83f5</guid> <script src="parametric.py" /> <interface context="Project"> <images>images</images> </interface> <workflow name="wf2" context="Project" version="1"> <tasks> <task name="Parametric" caption="Parametric" icon="parametric_component" version="1"> <callbacks> <onupdate>update</onupdate> </callbacks> <inputs> <input/> </inputs> <outputs/> </task>

239Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom ACT Workflows in Workbench Examples

Page 248: ANSYS ACT Developers Guide

</tasks> <taskgroups> <taskgroup name="Parametric" caption="Parametric" icon="parametric" category="ACT Custom Workflows" abbreviation="PARAMS" isparametricgroup="True" version="1"> <includeTask name="Parametric" caption="Parametric"/> </taskgroup> </taskgroups> </workflow>

IronPython Script

The IronPython script (parametric.py) performs an update on the parameters. Since the XML exten-sion definition file has <onupdate> callback, the update method is defined in the script.

The file, parametric.py, contains the following code:

def update(container, context): print 'test'

Custom Guided Process Examples

This section contains examples of wizards and a custom template.

Wizard Examples:

For our different wizard examples, we'll use the same extension, WizardDemos. The following fourwizards are defined in this extension:

• ProjectWizard: Project wizard

• CreateBridge: Target app wizard (DesignModeler)

• SimpleAnalysis: Target app wizard (Mechanical)

• BridgeSimulation: Mixed wizard

For the wizard examples, we'll review excerpts from the XML extension file and the IronPython scripts.

Custom Template Example:

For our custom template example, we'll use the extension StudyDemo. The custom template Study-Demo1 is defined in this extension.

For the custom template example, we'll review the XML extension file, the IronPython script, and theorganization of custom help files.

Workbench Project Wizard

Our Workbench Project wizard example is called ProjectWizard. It is defined in the extension Wizard-Demos.

XML Extension Definition File

Below is an excerpt of the XML extension file, WizardDemos.xml.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.240

Examples

Page 249: ANSYS ACT Developers Guide

Extension DefinitionThe name and version attributes define the extension name and version. The guid attribute specifiesa unique identifier for the extension.

Script ReferenceThe <script> block specifies the IronPython script referenced by the extension. This wizard referencesthe script main.py.

Interface DefinitionIn the <interface> block:

• The context attribute is set to Project because the extension is executed in the Project tab

• The <images> tag refers to the extension images folder; the image contained in this folder is displayedas the icon for the custom template.

Wizard DefinitionThe wizard and its steps are defined in the <wizard> block.

• The required name and version attributes define the wizard name and version.

• Because the wizard will be executed on the Project tab, the required context attribute is set to Pro-ject.

Step DefinitionsThe <step> tag is used to define the steps of the wizard. There are six steps:Geometry,Mechanical,Fluent,ReportView,CustomStep, and Charts.

For each step:

• The name,version, and caption attributes define the step name, version, and display text for thestep.

• The context attribute is set to the context in which the specific step is executed (i.e. Project, Design-Modeler, Mechanical).

• The HelpFile attribute references the HTML help file to be displayed for the step.

• The <callbacks> block defines the callbacks to the functions defined in the Python script.

– For the Geometry step, the <onupdate> callback executes the CreateGeometry action, creatingthe geometry upon update; the <onreset> callback executes the DeleteGeometry action, remov-ing the geometry when the Back button is clicked.

– For the Mechanical step, the <onupdate> callback executes the CreateMechanical actionand the <onreset> callback executes the DeleteMechanical action.

– For the Fluent step, the <onupdate> callback executes the CreateFluent action.

– For the ReportView step, the <onrefresh> and <onreset> callbacks execute the Re-freshReport and EmptyReset actions.

– For the CustomStep, the <onrefresh>,<onupdate>, and <onreset> callbacks execute theRefreshMechanical,LogReport, and EmptyReset actions

241Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom Guided Process Examples

Page 250: ANSYS ACT Developers Guide

– For the Charts step, the <onrefresh> callback executes the RefreshCharts action.

• The <propertygroup> blocks define properties and property attributes for the steps. For propertiesrequiring validation, the <onvalidate> callback executes an appropriate Python validation function.

<extension version="2" minorversion="1" name="WizardDemos"> <guid>6D33EFFC-C521-4859-8273-BA320044B6B8</guid> <author>ANSYS Inc.</author> <description>Simple extension to test wizards in different contexts.</description>

<script src="main.py" /> <script src="ds.py" /> <script src="dm.py" />

<interface context="Project|Mechanical"> <images>images</images> </interface>

...

<wizard name="ProjectWizard" version="1" context="Project" icon="wizard_icon"> <description>Simple wizard for demonstration in Project page.</description>

<step name="Geometry" caption="Geometry" version="1" HelpFile="help/geometry.html"> <description>Create a geometry component.</description>

<callbacks> <onupdate>CreateGeometry</onupdate> <onreset>DeleteGeometry</onreset> </callbacks>

<propertygroup display="caption" name="definition" caption="Basic properties" > <property name="filename" caption="Geometry file name" control="fileopen" /> <property name="myint" caption="Integer value" control="integer" /> <property name="mytext" caption="Text value" control="text" /> <property name="myquantity" caption="Quantity value" control="float" unit="Pressure" /> <property name="myreadonly" caption="Readonly value" control="text" readonly="true" default="My value" /> <propertygroup display="property" name="myselect" caption="List of choice" control="select" default="Option1"> <attributes options="Option1,Option2" /> <property name="option1" caption="Option1 value" control="text" visibleon="Option1" /> <property name="option2first" caption="Option2 first value" control="float" unit="Pressure" visibleon="Option2" /> <property name="option2seond" caption="Option2 second value" control="float" unit="Length" visibleon="Option2" /> </propertygroup> </propertygroup>

</step>

<step name="Mechanical" caption="Mechanical" enabled="true" version="1" HelpFile="help/mechanical.html"> <description>Create a mechanical component.</description>

<callbacks> <onupdate>CreateMechanical</onupdate> <onreset>DeleteMechanical</onreset> </callbacks>

<property name="name" caption="System name" control="text" /> <propertytable name="table" caption="TabularData" display="worksheet" control="applycancel" class="Worksheet.PropertyGroupEditor.PGEditor"> <property name="Temperature" caption="Temperature" unit="Temperature" control="float"></property> <property name="Pressure" caption="Pressure" unit="Pressure" control="float"></property> </propertytable>

</step>

<step name="Fluent" caption="Fluent" version="1" HelpFile="help/fluent.html"> <description>Create a fluent component.</description>

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.242

Examples

Page 251: ANSYS ACT Developers Guide

<callbacks> <onrefresh>CreateDialog</onrefresh> <onupdate>CreateFluent</onupdate> <onreset>EmptyReset</onreset> </callbacks>

<property name="name" caption="System name" control="text" /> <property name="dialog" caption="Dialog" control="text"> <callbacks> <onvalidate>ValidateDialog</onvalidate> </callbacks> </property> <property name="dialog2" caption="DialogProgress" control="text"> <callbacks> <onvalidate>ValidateDialogProgress</onvalidate> </callbacks> </property> <property name="nextstep" caption="Next Step" control="select" > <callbacks> <onvalidate>ValidateNextStep</onvalidate> </callbacks> </property>

</step>

<step name="ReportView" caption="ReportView" version="1" layout="ReportView@WizardDemos"> <description>Simple example to demonstrate how report can be displayed.</description>

<callbacks> <onrefresh>RefreshReport</onrefresh> <onreset>EmptyReset</onreset> </callbacks>

</step>

<step name="CustomStep" caption="CustomStep" enabled="true" version="1" layout="MyLayout@WizardDemos"> <description>Create a mechanical component.</description>

<callbacks> <onrefresh>RefreshMechanical</onrefresh> <onupdate>LogReport</onupdate> <onreset>EmptyReset</onreset> </callbacks>

<property name="name" caption="System name" control="text" />

</step>

<step name="Charts" caption="Charts" enabled="true" version="1" layout="GraphLayout@WizardDemos"> <description>Demonstrate all chart capabilities.</description>

<callbacks> <onrefresh>RefreshCharts</onrefresh> </callbacks>

</step>

</wizard>

IronPython Script

Below is the IronPython script, main.py.

This script defines all the functions executed by the callbacks in our XML extension file. Each step definedin the XML file may include multiple actions.

geoSystem = NonedsSystem = NonefluentSystem = None

243Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom Guided Process Examples

Page 252: ANSYS ACT Developers Guide

def CreateGeometry(step): global geoSystem template1 = GetTemplate(TemplateName="Geometry") geoSystem = template1.CreateSystem() geometry1 = geoSystem.GetContainer(ComponentName="Geometry") geometry1.SetFile(FilePath=step.Properties["definition/filename"].Value)

def DeleteGeometry(step): global geoSystem geoSystem.Delete()

def RefreshMechanical(step): tree = step.UserInterface.GetPanel("Tree") root = tree.CreateTreeNode("Root") node1 = tree.CreateTreeNode("Node1") node2 = tree.CreateTreeNode("Node2") node3 = tree.CreateTreeNode("Node3") root.Values.Add(node1) root.Values.Add(node2) node2.Values.Add(node1) node2.Values.Add(node3) root.Values.Add(node3) tree.SetTreeRoot(root) chart = step.UserInterface.GetPanel("Chart") chart.Plot([1,2,3,4,5],[10,4,12,13,8],"b","Line1") chart.Plot([1,2,3,4,5],[5,12,7,8,11],"r","Line2")

def CreateMechanical(step): global dsSystem, geoSystem template2 = GetTemplate( TemplateName="Static Structural", Solver="ANSYS") geometryComponent1 = geoSystem.GetComponent(Name="Geometry") dsSystem = template2.CreateSystem( ComponentsToShare=[geometryComponent1], Position="Right", RelativeTo=geoSystem) if step.Properties["name"].Value=="error": raise UserErrorMessageException("Invalid system name. Please try again.") dsSystem.DisplayText = step.Properties["name"].Value

def DeleteMechanical(step): global dsSystem dsSystem.Delete()

def CreateFluent(step): global dsSystem, fluentSystem template3 = GetTemplate(TemplateName="Fluid Flow") geometryComponent2 = dsSystem.GetComponent(Name="Geometry") solutionComponent1 = dsSystem.GetComponent(Name="Solution") componentTemplate1 = GetComponentTemplate(Name="CFDPostTemplate") fluentSystem = template3.CreateSystem( ComponentsToShare=[geometryComponent2], DataTransferFrom=[Set(FromComponent=solutionComponent1, TransferName=None, ToComponentTemplate=componentTemplate1)], Position="Right", RelativeTo=dsSystem) if step.Properties["name"].Value=="error": raise Exception("Invalid system name. Please try again.") fluentSystem.DisplayText = step.Properties["name"].Value

def CreateDialog(step): dlg = step.UserInterface.Container.CreateDialog("MyDialog", "okCancelDialog", "MyTitle", 400, 150) dlg.SetOkButton("Ok") prop = step.Properties["nextstep"] prop.Options.Clear() s = step.NextStep val = s.Caption while s!=None: prop.Options.Add(s.Caption) s = s.NextStep

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.244

Examples

Page 253: ANSYS ACT Developers Guide

prop.Value = val

def cbDialog(sender, args): sender.Container.HideDialog(sender)

def ValidateDialog(step, prop): dialog = step.UserInterface.GetPanel("MyDialog") dialog.SetMessage("My own message") dialog.SetCallback(cbDialog) dialog.Refresh() step.UserInterface.Container.ShowDialog(dialog)

def worker(step): progress = step.UserInterface.GetPanel("Progress") stopped = progress.UpdateProgress("Start progress...", 0, True) step.UserInterface.Container.ShowDialog(progress) for i in range(100): System.Threading.Thread.Sleep(100) stopped = progress.UpdateProgress("Start progress...", i+1, True) if stopped: break step.UserInterface.Container.HideDialog(progress)

def ValidateDialogProgress(step, prop): thread = System.Threading.Thread(System.Threading.ParameterizedThreadStart(worker)) thread.Start(step)

def ValidateNextStep(step, prop): prop = step.Properties["nextstep"] s = step.NextStep v = False while s!=None: if prop.Value==s.Caption: v = True s.IsEnabled = v s = s.NextStep steps = step.UserInterface.GetPanel("Steps") steps.UpdateData() steps.Refresh()

def RefreshReport(step): report = step.UserInterface.GetPanel("Report") report.SetFilename(System.IO.Path.Combine(ExtAPI.Extension.InstallDir,"help","report.html")) 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 randomimport math

def RefreshCharts(step): graph = step.UserInterface.GetPanel("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.GetPanel("GraphB") graphB.Title("Plot Graph") graphB.YTickFormat("0.2f")

xValues = [] yValues = [] for i in range(0, 100):

245Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom Guided Process Examples

Page 254: ANSYS ACT Developers Guide

xValues.append(i) yValues.append(abs(math.sin(i*0.2))*i/100.0) graphB.Plot(xValues, yValues, key="y = a*sin(bx)", color="c") graphB.Plot(xValues, yValues, key="y = x", color="m")

xValues = [] yValues = [] for i in range(0, 100): xValues.append(i) yValues.append(i/100.0) graphB.Plot(xValues, yValues, key="y = x", color="m")

graphB.Plot([0, 10, 20, 30, 100], [0.2, 0.2, 0.2, 0.3, 0.3], key="Smth", color="r") graphB.Plot([0, 10, 20, 30, 100], [0.2, 0.1, 0.3, 0.5, 0.7], key="Smth", color="r") graphB.Plot([0, 10, 20, 30, 100], [0.2, 0.2, 0.2, 0.3, 0.3])

graphC = step.UserInterface.GetPanel("GraphC") graphC.Title("Pie Graph") graphC.Pie([1, 2, 3]) graphC.Pie([20, 30, 5, 15, 12], [0, "Banana", 2, 3, "42"])

graphD = step.UserInterface.GetPanel("GraphD") graphD.Title("Bar Graph") graphD.Bar(["Banana"], [70], key="key") graphD.Bar([0, "Banana", 2, 3, 4], [20, 30, 5, 15, 12], key="key")

graphE = step.UserInterface.GetPanel("GraphE") graphE.Title("Bubble Graph") graphE.XTickFormat("f") graphE.YTickFormat("f") keys = ["one", "two", "three", "four", "five"] colors = ["#BB3333", "#33BB33", "#3333BB", "#BBBB33", "#BB33BB"] for c in range(0, 5): xValues = [] yValues = [] sizeValues = [] for i in range(0, (c+1)*20): rad = random.randrange(c+1, c+2) + (random.random()*2-1) angle = random.random() * 2 * math.pi xValues.append(math.cos(angle) * rad) yValues.append(math.sin(angle) * rad) sizeValues.append(random.random() * 2.0 + 0.5) graphE.Bubble(xValues, yValues, sizeValues, key=keys[c], color=colors[c])

Target Application Wizard (DesignModeler)

Our DesignModeler wizard example is called CreateBridge. It is defined in the extension WizardDemos.

This is a two-step wizard that builds a bridge.

XML Extension Definition File

Below is an excerpt of the XML extension file, WizardDemos.xml.

Extension DefinitionThe name and version attributes define the extension name and version. The guid attribute specifiesa unique identifier for the extension.

Script ReferenceThe <script> block specifies the IronPython script referenced by the extension. This wizard referencesthe script dm.py.

Interface DefinitionThe <interface> block defines details of the interface.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.246

Examples

Page 255: ANSYS ACT Developers Guide

• The context attribute is set to DesignModeler because the extension is executed in the Design-Modeler application.

• The <images> block refers to the extension images folder; the image contained in this folder is displayedas the icon for the wizard.

• The <toolbar> block is used to define two toolbar buttons for exposure in DesignModeler. When thebuttons are clicked, the <onclick> callbacks execute the CreateDeck and CreateSupportfunctions and create a deck geometry with supports.

Simdata DefinitionThe two <simdata> blocks provide data for the creation of the Deck and Support geometries.

Wizard DefinitionThe wizard and its steps are defined in the <wizard> block.

• The required name and version attributes define the wizard name and version.

• The context attribute is set to DesignModeler because the wizard will be executed in the Design-Modeler application.

Step DefinitionsThe <step> tag is used to define the steps of the wizard. There are two steps:Deck and Supports.

For each step:

• The name,version, and caption attributes define the step name, version, and display text for thestep.

• The HelpFile attribute references the HTML help file to be displayed for the step.

• The <callbacks> block defines the callbacks to the functions defined in the Python script.

– For the Deck step, the <onupdate> callback executes the UpdateDeck function to create the deckgeometry using the Deck feature.

– For the Supports step, the <onupdate> callback executes the UpdateSupports function tocreate the bridge supports using the Support geometry.

• The <propertygroup> block defines geometry properties and their attributes.

<extension version="2" minorversion="1" name="WizardDemos"> <guid>6D33EFFC-C521-4859-8273-BA320044B6B8</guid> <author>ANSYS Inc.</author> <description>Simple extension to test wizards in different contexts.</description>

<script src="main.py" /> <script src="ds.py" /> <script src="dm.py" />

...

<interface context="DesignModeler"> <images>images</images>

<toolbar name="Deck" caption="Deck"> <entry name="Deck" icon="deck"> <callbacks> <onclick>CreateDeck</onclick> </callbacks>

247Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom Guided Process Examples

Page 256: ANSYS ACT Developers Guide

</entry> <entry name="Support" icon="Support"> <callbacks> <onclick>CreateSupport</onclick> </callbacks> </entry> </toolbar>

</interface>

<simdata context="DesignModeler"> <geometry name="Deck" caption="Deck" icon="deck" version="1"> <callbacks> <ongenerate>GenerateDeck</ongenerate> </callbacks> <property name="Length" caption="Length" control="float" unit="Length" default="300 [m]" /> <property name="Width" caption="Width" control="float" unit="Length" default="20 [m]" /> <property name="Beams" caption="Beams" control="integer" default="31" /> </geometry> </simdata>

<simdata context="DesignModeler"> <geometry name="Support" caption="Support" icon="support" version="1"> <callbacks> <ongenerate>GenerateSupport</ongenerate> </callbacks> <property name="Length" caption="Length" control="float" unit="Length" default="300 [m]" /> <property name="Height" caption="Height" control="float" unit="Length" default="100 [m]" /> <property name="Width" caption="Width" control="float" unit="Length" default="20 [m]" /> <property name="Number" caption="Number" control="integer" default="3" /> </geometry> </simdata>

...

<wizard name="CreateBridge" version="1" context="DesignModeler" icon="wizard_icon"> <description>Simple wizard for demonstration in DesignModeler.</description>

<step name="Deck" caption="Deck" version="1" HelpFile="help/dm1.html"> <description>Create the deck.</description>

<callbacks> <onupdate>UpdateDeck</onupdate> </callbacks>

<propertygroup display="caption" name="Deck" caption="Deck Definition" > <property name="Length" caption="Length" control="float" unit="Length" default="300 [m]" /> <property name="Width" caption="Width" control="float" unit="Length" default="20 [m]" /> <property name="Beams" caption="Beams" control="integer" default="31" /> </propertygroup>

</step>

<step name="Supports" caption="Supports" enabled="true" version="1" HelpFile="help/dm2.html"> <description>Create supports.</description>

<callbacks> <onupdate>UpdateSupports</onupdate> </callbacks>

<propertygroup display="caption" name="Supports" caption="Supports Definition" > <property name="Height" caption="Height" control="float" unit="Length" default="100 [m]" /> <property name="Number" caption="Number" control="integer" default="3" /> </propertygroup>

</step>

</wizard>

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.248

Examples

Page 257: ANSYS ACT Developers Guide

IronPython Script

Below is the IronPython script, dm.py.

This script defines all the functions executed by the callbacks in our XML extension file. Each step definedin the XML file may include multiple actions.

import units

def CreateDeck(ag): ExtAPI.CreateFeature("Deck")

def CreateSupport(ag): ExtAPI.CreateFeature("Support")

def GenerateDeck(feature,fct): length = feature.Properties["Length"].Value length = units.ConvertUnit(length, ExtAPI.DataModel.CurrentUnitFromQuantityName("Length"), "m") width = feature.Properties["Width"].Value width = units.ConvertUnit(width, ExtAPI.DataModel.CurrentUnitFromQuantityName("Length"), "m") num = feature.Properties["Beams"].Value

builder = ExtAPI.DataModel.GeometryBuilder

bodies = []

boxGen = builder.Primitives.Solid.CreateBox([0.,-width/2.,-0.3],[length,width/2.,0.]) bodies.Add(boxGen.Generate())

w = (length-0.1*num)/(num-1.)+0.1 for i in range(num-1): beamGen = builder.Primitives.Solid.CreateBox([i*w,-width/2.,-0.6],[i*w+0.1,width/2.,-0.3]) bodies.Add(beamGen.Generate())

beamGen = builder.Primitives.Solid.CreateBox([length-0.1,-width/2.,-0.6],[length,width/2.,-0.3]) bodies.Add(beamGen.Generate())

beamGen = builder.Primitives.Solid.CreateBox([0.,-width/2.,-1.],[length,-width/2.+0.2,-0.6]) bodies.Add(beamGen.Generate()) beamGen = builder.Primitives.Solid.CreateBox([0.,width/2.-0.2,-1.],[length,width/2.,-0.6]) bodies.Add(beamGen.Generate())

feature.Bodies = bodies feature.MaterialType = MaterialTypeEnum.Add

return True

def GenerateSupport(feature,fct): length = feature.Properties["Length"].Value length = units.ConvertUnit(length, ExtAPI.DataModel.CurrentUnitFromQuantityName("Length"), "m") height = feature.Properties["Height"].Value height = units.ConvertUnit(height, ExtAPI.DataModel.CurrentUnitFromQuantityName("Length"), "m") width = feature.Properties["Width"].Value width = units.ConvertUnit(width, ExtAPI.DataModel.CurrentUnitFromQuantityName("Length"), "m") num = feature.Properties["Number"].Value

builder = ExtAPI.DataModel.GeometryBuilder

bodies = []

w = (length-2.*num)/(num+1.)+2. for i in range(num): beamGen = builder.Primitives.Solid.CreateBox([(i+1)*w,-width/2.,-1.-height],[(i+1)*w+2.,width/2.,-1.]) bodies.Add(beamGen.Generate())

beamGen = builder.Primitives.Solid.CreateBox([0.,-width/2.,-5.],[2.,width/2.,-1.]) bodies.Add(beamGen.Generate())

beamGen = builder.Primitives.Solid.CreateBox([length-2.,-width/2.,-5.],[length,width/2.,-1.])

249Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom Guided Process Examples

Page 258: ANSYS ACT Developers Guide

bodies.Add(beamGen.Generate())

feature.Bodies = bodies feature.MaterialType = MaterialTypeEnum.Freeze

return True

def UpdateDeck(step): deck = ExtAPI.CreateFeature("Deck") deck.Properties["Length"].Value = step.Properties["Deck/Length"].Value deck.Properties["Width"].Value = step.Properties["Deck/Width"].Value deck.Properties["Beams"].Value = step.Properties["Deck/Beams"].Value ExtAPI.DataModel.FeatureManager.Generate()

def UpdateSupports(step): supports = ExtAPI.CreateFeature("Support") supports.Properties["Length"].Value = step.PreviousStep.Properties["Deck/Length"].Value supports.Properties["Width"].Value = step.PreviousStep.Properties["Deck/Width"].Value+6 supports.Properties["Height"].Value = step.Properties["Supports/Height"].Value supports.Properties["Number"].Value = step.Properties["Supports/Number"].Value ExtAPI.DataModel.FeatureManager.Generate()

Target Application Wizard (Mechanical)

Our Mechanical wizard example is called SimpleAnalysis. It is defined in the extension WizardDemos.

It performs a simple analysis on the bridge built by our previous CreateBridge DesignModeler wizard.

XML Extension Definition File

Below is an excerpt of the XML extension file, WizardDemos.xml.

Extension DefinitionThe name and version attributes define the extension name and version. The guid attribute specifiesa unique identifier for the extension.

Script ReferenceThe <script> block specifies the IronPython script referenced by the extension. This wizard referencesthe script ds.py.

Interface DefinitionThe <interface> block defines details of the interface.

• The context attribute is set to Mechanical because the extension is executed in the Mechanicalapplication.

• The <images> block refers to the extension images folder; the image contained in this folder is displayedas the icon for the wizard.

Wizard DefinitionThe wizard and its steps are defined in the <wizard> block.

• The required name and version attributes define the wizard name and version.

• The context attribute is set to Mechanical because the wizard will be executed in the Mechanicalapplication.

Step DefinitionsThe <step> tag is used to define the steps of the wizard. There are three steps:Mesh,Solution, andResults.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.250

Examples

Page 259: ANSYS ACT Developers Guide

For each step:

• The name,version, and caption attributes define the step name, version, and display text for thestep.

• The HelpFile attribute references the HTML help file to be displayed for the step.

• The <callbacks> block defines the callbacks to the functions defined in the Python script.

– For the Mesh step, the <onreset> callback executes the RemoveControls function to clear existingmesh controls; the <onupdate> callback executes the CreateMeshControls function to createnew mesh controls.

– For the Solution step:

→ The <onrefresh> callback executes the RefreshLoads function to initialize various properties(number of nodes, number of elements computed in the previous step, etc.).

→ The <onreset> callback executes the RemoveLoads function to clear loads.

→ The <onupdate> callback executes the CreateLoads to create new loads, create new results,and perform the solve.

– For the Results step, the <onrefresh> callback executes the RefreshResults function to fillthe property value associated to the result of the computation (Maximum of Total Deformation).

• The <propertygroup> blocks define properties and property attributes for the steps. For propertiesrequiring location selection, the <isvalid> callback executes the IsLocationValid function tovalidate the selection. A custom message can be displayed when the entered value fails validation.

<extension version="2" minorversion="1" name="WizardDemos"> <guid>6D33EFFC-C521-4859-8273-BA320044B6B8</guid> <author>ANSYS Inc.</author> <description>Simple extension to test wizards in different contexts.</description>

<script src="main.py" /> <script src="ds.py" /> <script src="dm.py" />

<interface context="Project|Mechanical"> <images>images</images> </interface>

...

<wizard name="SimpleAnalysis" version="1" context="Mechanical" icon="wizard_icon"> <description>Simple wizard to illustrate how to setup, solve and analyse results of a simulation process.</description>

<step name="Mesh" caption="Mesh" version="1" HelpFile="help/ds1.html"> <description>Setup some mesh controls.</description>

<callbacks> <onreset>RemoveControls</onreset> <onupdate>CreateMeshControls</onupdate> </callbacks>

<propertygroup display="caption" name="Sizing" caption="Mesh Sizing" > <property name="Location" caption="Edge Location" control="geometry_selection"> <attributes selection_filter="edge" /> <callbacks> <isvalid>IsLocationValid</isvalid> </callbacks>

251Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom Guided Process Examples

Page 260: ANSYS ACT Developers Guide

</property> <property name="Ndiv" caption="Divisions" control="integer" /> </propertygroup>

</step>

<step name="Solution" caption="Solution" version="1" HelpFile="help/ds2.html"> <description>Setup loads.</description>

<callbacks> <onrefresh>RefreshLoads</onrefresh> <onreset>RemoveLoads</onreset> <onupdate>CreateLoads</onupdate> </callbacks>

<propertygroup display="caption" name="Mesh" caption="Mesh Statistics" > <property name="Nodes" caption="Nodes" control="text" readonly="true" /> <property name="Elements" caption="Elements" control="text" readonly="true" /> </propertygroup> <propertygroup display="caption" name="FixedSupport" caption="Fixed Support" > <property name="Location" caption="Face Location" control="geometry_selection"> <attributes selection_filter="face" /> <callbacks> <isvalid>IsLocationFSValid</isvalid> </callbacks> </property> </propertygroup>

</step>

<step name="Results" caption="Results" version="1" HelpFile="help/ds3.html"> <description>View Results.</description>

<callbacks> <onrefresh>RefreshResults</onrefresh> </callbacks>

<property name="Res" caption="Deformation" control="text" readonly="true" />

</step>

</wizard>

IronPython Script

Below is the IronPython script, ds.py.

This script defines all the functions executed by the callbacks in our XML extension file. Each step definedin the XML file may include multiple actions.

def IsLocationValid(step, prop): if prop.Value==None: return False if prop.Value.Ids.Count!=1: prop.StateMessage = "Select only one edge." return False return True

def CreateMeshControls(step): model = ExtAPI.DataModel.Project.Model mesh = model.Mesh sizing = mesh.AddSizing() sel = step.Properties["Sizing/Location"].Value entity = ExtAPI.DataModel.GeoData.GeoEntityById(sel.Ids[0]) len = entity.Length ids = [] for part in ExtAPI.DataModel.GeoData.Assemblies[0].Parts: for body in part.Bodies: for edge in body.Edges: if abs(edge.Length-len)/len<1.e-6:

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.252

Examples

Page 261: ANSYS ACT Developers Guide

ids.Add(edge.Id) sel = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities) sel.Ids = ids sizing.Location = sel sizing.Type = SizingType.NumberOfDivisions sizing.NumberOfDivisions = step.Properties["Sizing/Ndiv"].Value step.Attributes.SetValue("sizing", sizing) mesh.GenerateMesh()

def RemoveControls(step): sizing = step.Attributes["sizing"] sizing.Delete()

def IsLocationFSValid(step, prop): if prop.Value==None: return False if prop.Value.Ids.Count!=1: prop.StateMessage = "Select only one face." return False return True

def RefreshLoads(step): model = ExtAPI.DataModel.Project.Model step.Properties["Mesh/Nodes"].Value = model.Mesh.Nodes.ToString() step.Properties["Mesh/Elements"].Value = model.Mesh.Elements.ToString() panel = step.UserInterface.GetPanel("Properties") panel.UpdateData() panel.Refresh()

def CreateLoads(step): model = ExtAPI.DataModel.Project.Model analysis = model.Analyses[0] support = analysis.AddFixedSupport() sel = step.Properties["FixedSupport/Location"].Value entity = ExtAPI.DataModel.GeoData.GeoEntityById(sel.Ids[0]) area = entity.Area ids = [] for part in ExtAPI.DataModel.GeoData.Assemblies[0].Parts: for body in part.Bodies: for face in body.Faces: if abs(face.Area-area)/area<1.e-6: ids.Add(face.Id) sel = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities) sel.Ids = ids support.Location = sel loads = [] loads.Add(support) step.Attributes.SetValue("loads", loads)

loads.Add(analysis.AddEarthGravity()) res = analysis.Solution.AddTotalDeformation() step.Attributes.SetValue("res", res) loads.Add(res) analysis.Solve(True) ExtAPI.Extension.SetAttributeValueWithSync("result", res.Maximum.ToString())

def RemoveLoads(step): loads = step.Attributes["loads"] for load in loads: load.Delete()

def RefreshResults(step): model = ExtAPI.DataModel.Project.Model res = step.PreviousStep.Attributes["res"] step.Properties["Res"].Value = res.Maximum.ToString() panel = step.UserInterface.GetPanel("Properties") panel.UpdateData() panel.Refresh()

253Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom Guided Process Examples

Page 262: ANSYS ACT Developers Guide

Mixed Wizard

Our mixed wizard example is called BridgeSimulation. It is defined in the extension WizardDemos.

It executes one step on the Project tab, reuses the bridge builder in our CreateBridge DesignModelerwizard, reruns the bridge analysis in our SimpleAnalysis Mechanical wizard, and then returns to theProject tab to execute a Results step.

XML Extension Definition File

Below is an excerpt of the XML extension file, WizardDemos.xml. Because this is a mixed wizard in-corporating steps on the Project tab with steps from our existing DesignModeler and Mechanical wizards,it uses all of the content in the XML extension defitinition file.

Script ReferenceThe <script> block specifies the IronPython scripts referenced by the extension. This wizard referencesall three of the script files:main.py,dm.py, and ds.py.

Interface DefinitionThe <interface> blocks define details of the interface. This wizard uses all of the interface blocks.

• In one <interface> block, the context attribute is set to Project|Mechanical. In another<interface> block, the context attribute is set to DesignModeler.

• The <images> tag refers to the extension images folder; the image contained in this folder is displayedas the icon for the custom template.

• The <toolbar> block is used to define two toolbar buttons for exposure in DesignModeler. When thebuttons are clicked, the <onclick> callbacks execute the CreateDeck and CreateSupportfunctions and create a deck geometry with supports.

Simdata DefinitionThe two <simdata> blocks provide data for the creation of the Deck and Support geometries inDesignModeler.

Wizard DefinitionThe wizard and its steps are defined in the <wizard> block.

• The required name and version attributes define the wizard name and version.

• The context attribute is set to Project because the wizard will be executed in the Project tab; itaccesses the target applications from the Project tab instead of executing in them directly.

Step DefinitionsThe <step> tag is used to define the steps of the wizard. There are six steps:Project,Deck,Supports,Mesh,Solution, and Results.

For each step:

• The name,version, and caption attributes define the step name, version, and display text for thestep.

• The HelpFile attribute references the HTML help file to be displayed for the step.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.254

Examples

Page 263: ANSYS ACT Developers Guide

• The <callbacks> block defines the callbacks to the functions defined in the Python script.

– For the Project step, the <onupdate> callback executes the CreateStaticStructuralfunction in main.py.

– For the Deck and Supports steps,<onupdate> callback executes the UpdateDeck and Update-Supports functions in dm.py.

– For the Mesh step, the <onreset> and <onupdate> callbacks execute the RemoveControlsand CreateMeshControls functions in ds.py.

– For the Solution step, the <onrefresh>,<onreset>, and <onupdate> callbacks execute theRefreshLoads,RemoveLoads, and CreateLoads functions in ds.py.

– For the Results step, the <onrefresh> callback executes the RefreshResultsProjectfunction in main.py.

• The <propertygroup> blocks define properties and property attributes for the steps.

<extension version="2" minorversion="1" name="WizardDemos"> <guid>6D33EFFC-C521-4859-8273-BA320044B6B8</guid> <author>ANSYS Inc.</author> <description>Simple extension to test wizards in different contexts.</description>

<script src="main.py" /> <script src="ds.py" /> <script src="dm.py" />

<interface context="Project|Mechanical"> <images>images</images> </interface>

<interface context="DesignModeler"> <images>images</images>

<toolbar name="Deck" caption="Deck"> <entry name="Deck" icon="deck"> <callbacks> <onclick>CreateDeck</onclick> </callbacks> </entry> <entry name="Support" icon="Support"> <callbacks> <onclick>CreateSupport</onclick> </callbacks> </entry> </toolbar>

</interface>

<simdata context="DesignModeler"> <geometry name="Deck" caption="Deck" icon="deck" version="1"> <callbacks> <ongenerate>GenerateDeck</ongenerate> </callbacks> <property name="Length" caption="Length" control="float" unit="Length" default="300 [m]" /> <property name="Width" caption="Width" control="float" unit="Length" default="20 [m]" /> <property name="Beams" caption="Beams" control="integer" default="31" /> </geometry> </simdata>

<simdata context="DesignModeler"> <geometry name="Support" caption="Support" icon="support" version="1"> <callbacks> <ongenerate>GenerateSupport</ongenerate> </callbacks>

255Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom Guided Process Examples

Page 264: ANSYS ACT Developers Guide

<property name="Length" caption="Length" control="float" unit="Length" default="300 [m]" /> <property name="Height" caption="Height" control="float" unit="Length" default="100 [m]" /> <property name="Width" caption="Width" control="float" unit="Length" default="20 [m]" /> property name="Number" caption="Number" control="integer" default="3" /> </geometry> </simdata>

<wizard name="ProjectWizard" version="1" context="Project" icon="wizard_icon"> <description>Simple wizard for demonstration in Project page.</description>

<step name="Geometry" caption="Geometry" version="1" HelpFile="help/geometry.html"> <description>Create a geometry component.</description>

<callbacks> <onupdate>CreateGeometry</onupdate> <onreset>DeleteGeometry</onreset> </callbacks>

<propertygroup display="caption" name="definition" caption="Basic properties" > <property name="filename" caption="Geometry file name" control="fileopen" /> <property name="myint" caption="Integer value" control="integer" /> <property name="mytext" caption="Text value" control="text" /> <property name="myquantity" caption="Quantity value" control="float" unit="Pressure" /> <property name="myreadonly" caption="Readonly value" control="text" readonly="true" default="My value" /> <propertygroup display="property" name="myselect" caption="List of choice" control="select" default="Option1"> <attributes options="Option1,Option2" /> <property name="option1" caption="Option1 value" control="text" visibleon="Option1" /> <property name="option2first" caption="Option2 first value" control="float" unit="Pressure" visibleon="Option2" /> <property name="option2seond" caption="Option2 second value" control="float" unit="Length" visibleon="Option2" /> </propertygroup> </propertygroup>

</step>

<step name="Mechanical" caption="Mechanical" enabled="true" version="1" HelpFile="help/mechanical.html"> <description>Create a mechanical component.</description>

<callbacks> <onupdate>CreateMechanical</onupdate> <onreset>DeleteMechanical</onreset> </callbacks>

<property name="name" caption="System name" control="text" /> <propertytable name="table" caption="TabularData" display="worksheet" control="applycancel" class="Worksheet.PropertyGroupEditor.PGEditor"> <property name="Temperature" caption="Temperature" unit="Temperature" control="float"></property> <property name="Pressure" caption="Pressure" unit="Pressure" control="float"></property> </propertytable>

</step>

<step name="Fluent" caption="Fluent" version="1" HelpFile="help/fluent.html"> <description>Create a fluent component.</description>

<callbacks> <onrefresh>CreateDialog</onrefresh> <onupdate>CreateFluent</onupdate> <onreset>EmptyReset</onreset> </callbacks>

<property name="name" caption="System name" control="text" /> <property name="dialog" caption="Dialog" control="text"> <callbacks> <onvalidate>ValidateDialog</onvalidate> </callbacks> </property> <property name="dialog2" caption="DialogProgress" control="text">

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.256

Examples

Page 265: ANSYS ACT Developers Guide

<callbacks> <onvalidate>ValidateDialogProgress</onvalidate> </callbacks> </property> <property name="nextstep" caption="Next Step" control="select" > <callbacks> <onvalidate>ValidateNextStep</onvalidate> </callbacks> </property>

</step>

<step name="ReportView" caption="ReportView" version="1" layout="ReportView@WizardDemos"> <description>Simple example to demonstrate how report can be displayed.</description>

<callbacks> <onrefresh>RefreshReport</onrefresh> <onreset>EmptyReset</onreset> </callbacks>

</step>

<step name="CustomStep" caption="CustomStep" enabled="true" version="1" layout="MyLayout@WizardDemos"> <description>Create a mechanical component.</description>

<callbacks> <onrefresh>RefreshMechanical</onrefresh> <onupdate>LogReport</onupdate> <onreset>EmptyReset</onreset> </callbacks>

<property name="name" caption="System name" control="text" />

</step>

<step name="Charts" caption="Charts" enabled="true" version="1" layout="GraphLayout@WizardDemos"> <description>Demonstrate all chart capabilities.</description>

<callbacks> <onrefresh>RefreshCharts</onrefresh> </callbacks>

</step>

</wizard>

<wizard name="CreateBridge" version="1" context="DesignModeler" icon="wizard_icon"> <description>Simple wizard for demonstration in DesignModeler.</description>

<step name="Deck" caption="Deck" version="1" HelpFile="help/dm1.html"> <description>Create the deck.</description>

<callbacks> <onupdate>UpdateDeck</onupdate> </callbacks>

<propertygroup display="caption" name="Deck" caption="Deck Definition" > <property name="Length" caption="Length" control="float" unit="Length" default="300 [m]" /> <property name="Width" caption="Width" control="float" unit="Length" default="20 [m]" /> <property name="Beams" caption="Beams" control="integer" default="31" /> </propertygroup>

</step>

<step name="Supports" caption="Supports" enabled="true" version="1" HelpFile="help/dm2.html"> <description>Create supports.</description>

<callbacks> <onupdate>UpdateSupports</onupdate> </callbacks>

<propertygroup display="caption" name="Supports" caption="Supports Definition" >

257Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom Guided Process Examples

Page 266: ANSYS ACT Developers Guide

<property name="Height" caption="Height" control="float" unit="Length" default="100 [m]" /> <property name="Number" caption="Number" control="integer" default="3" /> </propertygroup>

</step>

</wizard>

<wizard name="SimpleAnalysis" version="1" context="Mechanical" icon="wizard_icon"> <description>Simple wizard to illustrate how to setup, solve and analyse results of a simulation process.</description>

<step name="Mesh" caption="Mesh" version="1" HelpFile="help/ds1.html"> <description>Setup some mesh controls.</description>

<callbacks> <onreset>RemoveControls</onreset> <onupdate>CreateMeshControls</onupdate> </callbacks>

<propertygroup display="caption" name="Sizing" caption="Mesh Sizing" > <property name="Location" caption="Edge Location" control="geometry_selection"> <attributes selection_filter="edge" /> <callbacks> <isvalid>IsLocationValid</isvalid> </callbacks> </property> <property name="Ndiv" caption="Divisions" control="integer" /> </propertygroup>

</step>

<step name="Solution" caption="Solution" version="1" HelpFile="help/ds2.html"> <description>Setup loads.</description>

<callbacks> <onrefresh>RefreshLoads</onrefresh> <onreset>RemoveLoads</onreset> <onupdate>CreateLoads</onupdate> </callbacks>

<propertygroup display="caption" name="Mesh" caption="Mesh Statistics" > <property name="Nodes" caption="Nodes" control="text" readonly="true" /> <property name="Elements" caption="Elements" control="text" readonly="true" /> </propertygroup> <propertygroup display="caption" name="FixedSupport" caption="Fixed Support" > <property name="Location" caption="Face Location" control="geometry_selection"> <attributes selection_filter="face" /> <callbacks> <isvalid>IsLocationFSValid</isvalid> </callbacks> </property> </propertygroup>

</step>

<step name="Results" caption="Results" version="1" HelpFile="help/ds3.html"> <description>View Results.</description>

<callbacks> <onrefresh>RefreshResults</onrefresh> </callbacks>

<property name="Res" caption="Deformation" control="text" readonly="true" />

</step>

</wizard>

<wizard name="BridgeSimulation" version="1" context="Project" icon="bridge"> <description>Simple wizard for mixed wizard demonstration.</description>

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.258

Examples

Page 267: ANSYS ACT Developers Guide

<step name="Project" caption="Create Project" version="1" context="Project" HelpFile="help/prj1.html"> <description>Create a static structural analysis.</description>

<callbacks> <onupdate>CreateStaticStructural</onupdate> <onreset>DeleteStaticStructural</onreset> </callbacks>

<property name="Name" caption="system name" control="text" />

</step>

<step name="Deck" caption="Deck" version="1" context="DesignModeler" HelpFile="help/dm1.html"> <description>Create the deck.</description>

<callbacks> <onupdate>UpdateDeck</onupdate> </callbacks>

<propertygroup display="caption" name="Deck" caption="Deck Definition" > <property name="Length" caption="Length" control="float" unit="Length" default="300 [m]" /> <property name="Width" caption="Width" control="float" unit="Length" default="20 [m]" /> <property name="Beams" caption="Beams" control="integer" default="31" /> </propertygroup>

</step>

<step name="Supports" caption="Supports" context="DesignModeler" enabled="true" version="1" HelpFile="help/dm2.html"> <description>Create supports.</description>

<callbacks> <onupdate>UpdateSupports</onupdate> </callbacks>

<propertygroup display="caption" name="Supports" caption="Supports Definition" > <property name="Height" caption="Height" control="float" unit="Length" default="100 [m]" /> <property name="Number" caption="Number" control="integer" default="3" /> </propertygroup>

</step>

<step name="Mesh" caption="Mesh" version="1" context="Mechanical" HelpFile="help/ds1.html"> <description>Setup some mesh controls.</description>

<callbacks> <onreset>RemoveControls</onreset> <onupdate>CreateMeshControls</onupdate> </callbacks>

<propertygroup display="caption" name="Sizing" caption="Mesh Sizing" > <property name="Location" caption="Edge Location" control="geometry_selection"> <attributes selection_filter="edge" /> <callbacks> <isvalid>IsLocationValid</isvalid> </callbacks> </property> <property name="Ndiv" caption="Divisions" control="integer" /> </propertygroup>

</step>

<step name="Solution" caption="Solution" version="1" context="Mechanical" HelpFile="help/ds2.html"> <description>Setup loads.</description>

<callbacks> <onrefresh>RefreshLoads</onrefresh> <onreset>RemoveLoads</onreset> <onupdate>CreateLoads</onupdate> </callbacks>

<propertygroup display="caption" name="Mesh" caption="Mesh Statistics" >

259Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom Guided Process Examples

Page 268: ANSYS ACT Developers Guide

<property name="Nodes" caption="Nodes" control="text" readonly="true" /> <property name="Elements" caption="Elements" control="text" readonly="true" /> </propertygroup> <propertygroup display="caption" name="FixedSupport" caption="Fixed Support" > <property name="Location" caption="Face Location" control="geometry_selection"> <attributes selection_filter="face" /> <callbacks> <isvalid>IsLocationFSValid</isvalid> </callbacks> </property> </propertygroup>

</step>

<step name="Results" caption="Results" version="1" context="Project" HelpFile="help/prj2.html"> <description>View Results.</description>

<callbacks> <onrefresh>RefreshResultsProject</onrefresh> </callbacks>

<property name="Res" caption="Deformation" control="text" readonly="true" />

</step>

</wizard>

</extension>

IronPython Script

Because this is a mixed wizard incorporating steps on the Project tab with steps from our existingDesignModeler and Mechanical wizards, the XML file references the three script files shown in previoussections:

• main.py

• dm.py

• ds.py

AIM Custom Template

Our AIM custom template example is called StudyDemo1. It is defined in the extension StudyDemo.

XML Extension Definition File

Below is the XML extension file, StudyDemo.xml.

Extension DefinitionThe name and version attributes define the extension name and version. The guid attribute specifiesa unique identifier for the extension.

Script ReferenceThe <script> block specifies the IronPython script referenced by the extension. For this custom template,the script is main.py.

Interface DefinitionIn the <interface> block:

• The context attribute is set to Study.

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.260

Examples

Page 269: ANSYS ACT Developers Guide

• The <images> tag refers to the extension images folder; the image contained in this folder is displayedas the icon for the custom template.

Custom Template DefinitionThe custom template is defined in the <wizard> block, which defines the single step of the customtemplate (only single-step guided processes are supported at present).

Step DefinitionsThe <step> tag is used to define the single step of our custom template,step1.

• The required name,version, and context attributes define the step name, version, and context.Because the step will be executed in AIM,context is set to Study.

• The <callbacks> block defines the callbacks to the functions defined in the Python script.

– The <onupdate> callback executes the action function, which creates the Study in AIM.

– The <onreset> executes the reset function, which allows you to modify the template properties.

• The <properties> block defines the properties used in the custom template.

– For the Geometry property, the control attribute is set to fileopen, which displays a file-selectionproperty initialized to the default attribute value.

– For the NAnalysis property:

→ The control attribute is set to integer, which allows you to edit the integer value for the defaultattribute. This value specifies the number of analyses to be performed.

→ The <isvalid> callback calls the isvalid function, which validates that the entered integer isnot less than 1. A custom message can be displayed when the entered value fails validation.

<extension version="1" name="StudyDemo"> <author>ANSYS Inc.</author>

<script src="main.py" />

<interface context="Study"> <images>images</images> </interface> <wizard name="StudyDemo1" version="1" context="Study" icon="icon">

<description>Wizard to demonstrate the concept inside AIM.</description>

<step name="Step1" caption="Load geometry file" version="1" context="Study"> <description>Import a geometry file.</description>

<callbacks> <onupdate>action</onupdate> <onreset>reset</onreset> </callbacks>

<property name="Geometry" caption="Geometry file name" control="fileopen" default="E:/Models/box.agdb" /> <property name="NAnalysis" caption="Number of Analysis" control="integer" default="1"> <callbacks> <isvalid>isvalid</isvalid> </callbacks> </property> </step>

</wizard>

261Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom Guided Process Examples

Page 270: ANSYS ACT Developers Guide

</extension>

IronPython Script

Below is the IronPython script, main.py.

This script defines the functions called by the callbacks in the custom template's XML extension definitionfile.

• The action function is the single step in our custom template. When called by the <onupdate> callback(invoked by the Create Simulation button), it creates the Study workflow by creating and updating theGeometry, Mesh, and Physics tasks.

• The reset function, when called by the <onreset> callback, resets the UI and allows the user to modifyproperties defined for the custom template. This occurs when encountering an error during the executionof the <onupdate> callback.

• The isvalid function, when called by the <isvalid> callback in the <properties> block, validatesthat the property value entered is not less than 1. A custom message can be displayed when the enteredvalue fails validation.

tasksToDelete = []groupsToDelete = []

def action(step): global tasksToDelete,groupsToDelete tasksToDelete = [] groupsToDelete = [] system1 = GetSystem(Name="Study") importComponent1 = Study.CreateTask( Type="Import", System=system1) tasksToDelete.Add(importComponent1) study1 = system1.GetContainer(ComponentName="Study") import1 = importComponent1.GetTaskObject() geometryImportSource1 = study1.CreateEntity( Type="GeometryImportSource", Association=import1) geometryImportSource1.FilePath = step.Properties["Geometry"].Value geometryImportSource1.GenerateImportSourceOperation()

step.UpdateProgressInformation(10.)

pct = 10. for i in range(step.Properties["NAnalysis"].Value): meshingComponent1 = Study.CreateTask( Type="Meshing", System=system1, Input=importComponent1) tasksToDelete.Add(meshingComponent1) meshingComponent1.Refresh() physicsSolutionGroup1 = Study.CreateGroup(Name="Physics Solution") groupsToDelete.Add(physicsSolutionGroup1) physicsDefinitionComponent1 = Study.CreateTask( Type="Physics Definition", System=system1) tasksToDelete.Add(physicsDefinitionComponent1) solvePhysicsComponent1 = Study.CreateTask( Type="Solve Physics", System=system1) tasksToDelete.Add(solvePhysicsComponent1) physicsSolutionGroup1.Add(Component=physicsDefinitionComponent1) physicsSolutionGroup1.Add(Component=solvePhysicsComponent1) AddSourceToComponentInSystem( SourceComponent=physicsDefinitionComponent1,

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.262

Examples

Page 271: ANSYS ACT Developers Guide

TargetComponent=solvePhysicsComponent1) AddSourceToComponentInSystem( SourceComponent=meshingComponent1, TargetComponent=physicsDefinitionComponent1) physicsDefinitionComponent1.Refresh() solvePhysicsComponent1.Refresh() physicsDefinition1 = physicsDefinitionComponent1.GetTaskObject() physicsRegion1 = study1.CreateEntity( Type="PhysicsRegion", Association=physicsDefinition1) solverSettings1 = study1.CreateEntity( Type="SolverSettings", Association=physicsDefinition1) transcript1 = study1.CreateEntity( Type="Transcript", Association=physicsDefinition1) physicsDefinitionComponent1.Refresh() solvePhysicsComponent1.Refresh() meshing1 = meshingComponent1.GetTaskObject() meshing1.EngineeringIntent = "StructuralOrThermalOrElectricConduction" physicsRegion1.Location = ["BODY1"] physicsRegion1.PhysicsType = "Structural" materialAssignment1 = study1.CreateEntity( Type="MaterialAssignment", Association=physicsDefinition1) materialAssignment1.Location = ["BODY1"] material1 = study1.CreateEntity( Type="Material", Association=physicsDefinition1) material1.ImportEngineeringData(Name="Structural Steel") materialAssignment1.Material = material1 pct += 10. step.UpdateProgressInformation(pct)

if i==9: raise UserErrorMessageException("My own error message.")

def reset(step): global tasksToDelete,groupsToDelete system1 = GetSystem(Name="Study") for group in groupsToDelete: Study.DeleteTaskGroup(Group=group) for task in tasksToDelete: task.DeleteTask(System=system1)

def isvalid(step, prop): if prop.Value<1: prop.StateMessage = "Must be greater than 0." return False return True

Defining Custom Help

For our custom template, we've defined an HTML help file for the template and each of our two prop-erties, named them according to our filename rules, and placed them in a help directory inside theextension directory. Support files, such as the workflow.png file (referenced in StudyDemo1.html)are placed at the same level as the HTML file.

Below, you can see the contents of our help directory.

263Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Custom Guided Process Examples

Page 272: ANSYS ACT Developers Guide

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.264

Page 273: ANSYS ACT Developers Guide

Appendix A. ANSYS Workbench Task Inputs and Outputs

Table 1: Autodyn

OutputInputTaskTaskgroup

Autodyn

Setup

AutodynSetupAUTODYN_Remap

MechanicalSetup

SimulationGeneratedMesh

Analysis

NoneNone

Table 2: BladeGen

OutputInputTaskTaskgroup

BladeGen

Blade Design

TurboGeometryNone

VistaGeometry

BladeGen (Beta)

Blade Design

TurboGeometryNone

VistaGeometry

Table 3: CFX

OutputInputTaskTaskgroup

CFX (Beta)

Setup

CFXSetupSimulationGeneratedMesh

SystemCouplingSetupDataCFXMesh

MechanicalSetup

Solution

CFXSolutionCFXSetup

CFXSolution

CFX

Setup

CFXSetupSimulationGeneratedMesh

265Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 274: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

SystemCouplingSetupDataCFXMesh

MechanicalSetup

Solution

CFXSolutionCFXSetup

CFXSolution

Results

CFDAnalysisCFXSolution

FluentSolution

VistaTFSolution

IcePakResults

PolyflowSolutionType

MechanicalSolution

ICEData

Table 4: Design Assessment

OutputInputTaskTaskgroup

DesignAssessment

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.266

ANSYS Workbench Task Inputs and Outputs

Page 275: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

MechanicalSetupMechanicalMesh

SimulationSolutionDataInternal

MechanicalSolution

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

SimulationResults

Table 5: Direct Optimization

OutputInputTaskTaskgroup

DirectOptimization

Optimization

OptimizationModelDesignPointsDataTransfer

Table 6: Electric

OutputInputTaskTaskgroup

Electric

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

267Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 276: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SimulationSolutionDataInternal

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

SimulationResults

Table 7: Engineering Data

OutputInputTaskTaskgroup

EngineeringData

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Table 8: Explicit Dynamics

OutputInputTaskTaskgroup

ExplicitDynamics

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.268

ANSYS Workbench Task Inputs and Outputs

Page 277: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SimulationSolutionDataInternal

EnhancedMechanicalModel

EnhancedModelData

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

SimulationResults

ExplicitDynamics(LS-DYNAExport)

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

269Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 278: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

Table 9: External Data

OutputInputTaskTaskgroup

External Data

Setup

ExternalDataSetupNone

Table 10: External Model

OutputInputTaskTaskgroup

External Model

Setup

ExternalModelOutputProviderNone

Table 11: External Connection

OutputInputTaskTaskgroup

ExternalConnection

ExternalConnection

ExternalConnectionPropertiesNone

Table 12: Finite Element Modeler

OutputInputTaskTaskgroup

Finite ElementModeler

Model

FEMMeshMechanicalSetup

FEMSetupSimulationGeneratedMesh

GeometryMAPDLCdb

FEMSetup

SolidSectionData

CompositeEngineeringData

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.270

ANSYS Workbench Task Inputs and Outputs

Page 279: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

SimulationEngineeringData

Table 13: Fluent

OutputInputTaskTaskgroup

Fluent

Setup

FluentSetupFluentImportable

SystemCouplingSetupDataAnsoftHeatLossDataObject

FluentMesh

FluentCase

SimulationGeneratedMesh

ICEData

ICESetupData

FluentTGridMesh

Solution

FluentSolutionFluentSetup

FluentSolution

Table 14: Fluid Flow – Blow Molding (Polyflow)

OutputInputTaskTaskgroup

Fluid Flow– BlowMolding(Polyflow)

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Mesh

MechanicalModelGeometry

MeshingMeshMeshingGeneratedMeshOutputProvider

SimulationGeneratedMesh

MeshingGeneratedMeshOutputProvider

Setup

PolyflowSetupSimulationGeneratedMesh

PolyflowTransferMesh

Solution

271Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 280: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

PolyflowSolutionTypePolyflowSetup

PolyflowSolutionPolyflowSolution

ExternalDataSetup

Results

CFD AnalysisCFXSolution

FluentSolution

VistaTFSolution

IcePakResults

PolyflowSolutionType

MechanicalSolution

ICEData

Table 15: Fluid Flow – Extrusion (Polyflow)

OutputInputTaskTaskgroup

Fluid Flow– Extrusion(Polyflow)

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Mesh

MechanicalModelGeometry

MeshingMeshMeshingGeneratedMeshOutputProvider

SimulationGeneratedMesh

MeshingGeneratedMeshOutputProvider

Setup

PolyflowSetupSimulationGeneratedMesh

PolyflowTransferMesh

Solution

PolyflowSolutionTypePolyflowSetup

PolyflowSolutionPolyflowSolution

ExternalDataSetup

Results

CFDAnalysisCFXSolution

FluentSolution

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.272

ANSYS Workbench Task Inputs and Outputs

Page 281: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

VistaTFSolution

IcePakResults

PolyflowSolutionType

MechanicalSolution

ICEData

Table 16: Fluid Flow (CFX)

OutputInputTaskTaskgroup

Fluid Flow(CFX)

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Mesh

MechanicalModelGeometry

MeshingMeshMeshingGeneratedMeshOutputProvider

SimulationGeneratedMesh

MeshingGeneratedMeshOutputProvider

Setup

CFXSetupSimulationGeneratedMesh

SystemCouplingSetupDataCFXMesh

MechanicalSetup

Solution

CFXSolutionCFXSetup

CFXSolution

Results

CFDAnalysisCFXSolution

FluentSolution

VistaTFSolution

IcePakResults

PolyflowSolutionType

MechanicalSolution

273Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 282: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

ICEData

Table 17: Fluid Flow (Fluent)

OutputInputTaskTaskgroup

Fluid Flow(Fluent)

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Mesh

MechanicalModelGeometry

MeshingMeshMeshingGeneratedMeshOutputProvider

SimulationGeneratedMesh

MeshingGeneratedMeshOutputProvider

Setup

FluentSetupFluentImportable

SystemCouplingSetupDataAnsoftHeatLossDataObject

FluentMesh

FluentCase

SimulationGeneratedMesh

ICEData

ICESetupData

FluentTGridMesh

Solution

FluentSolutionFluentSetup

FluentSolution

Results

CFDAnalysisCFXSolution

FluentSolution

VistaTFSolution

IcePakResults

PolyflowSolutionType

MechanicalSolution

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.274

ANSYS Workbench Task Inputs and Outputs

Page 283: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

ICEData

Table 18: Fluid Flow (Polyflow)

OutputInputTaskTaskgroup

Fluid Flow(Polyflow)

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Mesh

MechanicalModelGeometry

MeshingMeshMeshingGeneratedMeshOutputProvider

SimulationGeneratedMesh

MeshingGeneratedMeshOutputProvider

Setup

PolyflowSetupSimulationGeneratedMesh

PolyflowTransferMesh

Solution

PolyflowSolutionTypePolyflowSetup

PolyflowSolutionPolyflowSolution

ExternalDataSetup

Results

CFDAnalysisCFXSolution

FluentSolution

VistaTFSolution

IcePakResults

PolyflowSolutionType

MechanicalSolution

ICEData

Table 19: Geometry

OutputInputTaskTaskgroup

Geometry

Geometry

GeometryFEMSetup

275Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 284: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Table 20: Harmonic Response

OutputInputTaskTaskgroup

HarmonicResponse

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

EnhancedModelData

EnhancedMechanicalModel

ExternalDataSetup

MechanicalSolution

AnsoftForceAndMomentDataObject

SimulationSolutionDataInternal

Solution

MechanicalSolutionSimulationSetup

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.276

ANSYS Workbench Task Inputs and Outputs

Page 285: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

SimulationResults

Table 21: Hydrodynamic Diffraction

OutputInputTaskTaskgroup

HydrodynamicDiffraction

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

AqwaModelGeometry

Setup

AqwaSetupAqwaModel

Solution

AqwaSolutionAqwaSetup

Results

AqwaResultsAqwaSolution

Table 22: Hydrodynamic Response

OutputInputTaskTaskgroup

HydrodynamicResponse

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

AqwaModelGeometry

Setup

AqwaSetupAqwaModel

277Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 286: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

AqwaSolution

Solution

AqwaSolutionAqwaSetup

Results

AqwaResultsAqwaSolution

Table 23: ICE

OutputInputTaskTaskgroup

ICE

ICE

ICEDataNone

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Mesh

MechanicalModelGeometry

MeshingMeshMeshingGeneratedMeshOutputProvider

SimulationGeneratedMesh

MeshingGeneratedMeshOutputProvider

ICESolverSetup

ICESetupDataSimulationGeneralMesh

SimulationGeneratedMesh

Setup

FluentSetupFluentImportable

SystemCouplingSetupDataAnsoftHeatLossDataObject

FluentMesh

FluentCase

SimulationGeneratedMesh

ICEData

ICESetupData

FluentTGridMesh

Solution

FluentSolutionFluentSetup

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.278

ANSYS Workbench Task Inputs and Outputs

Page 287: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

FluentSolution

Results

CFDAnalysisCFXSolution

FluentSolution

VistaTFSolution

IcePakResults

PolyflowSolutionType

MechanicalSolution

ICEData

Table 24: ICEM CFD

OutputInputTaskTaskgroup

ICEM CFD

FluentImportableModel

SimulationGeneratedMeshGeometry

MeshingMesh

MechanicalMesh

Table 25: Icepak

OutputInputTaskTaskgroup

Icepak

Setup

IcePakSetupGeometry

AnsoftHeatLossDataObject

Solution

IcePakResultsIcePakSetup

Table 26: Linear Buckling

OutputInputTaskTaskgroup

EigenvalueBuckling

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

279Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 288: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SimulationSolutionDataInternal

EnhancedMechanicalModel

EnhancedModelData

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

SimulationResults

ExternalModelOutputProvider

Table 27: Linear Buckling (Samcef)

OutputInputTaskTaskgroup

EigenvalueBuckling(Samcef )

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.280

ANSYS Workbench Task Inputs and Outputs

Page 289: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SimulationSolutionDataInternal

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

SimulationResults

Table 28: Magnetostatic

OutputInputTaskTaskgroup

Magnetostatic

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

281Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 290: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

SimulationResults

Table 29: Mechanical APDL

OutputInputTaskTaskgroup

MechanicalAPDL

Analysis

NoneMechanicalSetup

SimulationGeneratedMesh

FEMSetup

Geometry

SolidSectionData

MechanicalSolution

MAPDLSolution

MAPDLDatabase

MAPDLResults

MAPDLCdb

Table 30: Mechanical Model

OutputInputTaskTaskgroup

MechanicalModel

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.282

ANSYS Workbench Task Inputs and Outputs

Page 291: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Table 31: Mesh

OutputInputTaskTaskgroup

Mesh

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Mesh

MechanicalModelGeometry

MeshingMeshMeshingGeneratedMeshOutputProvider

SimulationGeneratedMesh

MeshingGeneratedMeshOutputProvider

Table 32: Microsoft Office Excel

OutputInputTaskTaskgroup

MicrosoftOffice Excel

Analysis

283Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 292: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

MSExcelSetupNone

Table 33: Modal (ABAQUS)

OutputInputTaskTaskgroup

Modal(ABAQUS)

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SimulationSolutionDataInternal

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.284

ANSYS Workbench Task Inputs and Outputs

Page 293: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

SimulationResults

Table 34: Modal

OutputInputTaskTaskgroup

Modal

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SimulationSolutionDataInternal

EnhancedMechanicalModel

EnhancedModelData

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

ExternalModelOutputProviderSimulationSolution

MechanicalResults

285Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 294: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

SimulationResults

Table 35: Modal (NASTRAN)

OutputInputTaskTaskgroup

Modal(NASTRAN)

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

SimulationResults

Table 36: Modal (Samcef)

OutputInputTaskTaskgroup

Modal(Samcef )

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.286

ANSYS Workbench Task Inputs and Outputs

Page 295: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SimulationSolutionDataInternal

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

SimulationResults

Table 37: Parameters Correlation

OutputInputTaskTaskgroup

ParametersCorrelation

ParametersCorrelation

CorrelationModelResponseSurfaceDataTransfer

287Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 296: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

DesignPointsDataTransfer

Table 38: Polyflow – Blow Molding

OutputInputTaskTaskgroup

Polyflow –BlowMolding

Setup

PolyflowSetupSimulationGeneratedMesh

PolyflowTransferMesh

Solution

PolyflowSolutionTypePolyflowSetup

PolyflowSolutionPolyflowSolution

ExternalDataSetup

Table 39: Polyflow – Extrusion

OutputInputTaskTaskgroup

Polyflow -Extrusion

Setup

PolyflowSetupSimulationGeneratedMesh

PolyflowTransferMesh

Solution

PolyflowSolutionTypePolyflowSetup

PolyflowSolutionPolyflowSolution

ExternalDataSetup

Table 40: Polyflow

OutputInputTaskTaskgroup

Polyflow

Setup

PolyflowSetupSimulationGeneratedMesh

PolyflowTransferMesh

Solution

PolyflowSolutionTypePolyflowSetup

PolyflowSolutionPolyflowSolution

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.288

ANSYS Workbench Task Inputs and Outputs

Page 297: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

ExternalDataSetup

Table 41: Random Vibration

OutputInputTaskTaskgroup

RandomVibration

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SimulationSolutionDataInternal

EnhancedMechanicalModel

EnhancedModelData

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

289Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 298: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

SimulationResults

Table 42: Response Spectrum

OutputInputTaskTaskgroup

ResponseSpectrum

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SimulationSolutionDataInternal

EnhancedMechanicalModel

EnhancedModelData

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.290

ANSYS Workbench Task Inputs and Outputs

Page 299: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

SimulationResults

Table 43: Response Surface

OutputInputTaskTaskgroup

ResponseSurface

DesignofExperiments

ParametricContextNone

DOEModel

DesignPointsDataTransfer

ResponseSurface

ResponseSurfaceModelParametricContext

ResponseSurfaceDataTransferDOEModel

DesignPointsDataTransfer

Table 44: Response Surface Optimization

OutputInputTaskTaskgroup

ResponseSurfaceOptimization

DesignofExperiments

ParametricContextNone

DOEModel

DesignPointsDataTransfer

ResponseSurface

ResponseSurfaceModelParametricContext

ResponseSurfaceDataTransferDOEModel

DesignPointsDataTransfer

Optimization

OptimizationModelParametricContext

ResponseSurfaceModel

Table 45: Results

OutputInputTaskTaskgroup

Results

291Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 300: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

Results

CFDAnalysisCFXSolution

FluentSolution

VistaTFSolution

IcePakResults

PolyflowSolutionType

MechanicalSolution

ICEData

Table 46: Rigid Dynamics

OutputInputTaskTaskgroup

RigidDynamics

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.292

ANSYS Workbench Task Inputs and Outputs

Page 301: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

Results

MechanicalResultsSimulationSolution

SimulationResults

Table 47: Shape Optimization

OutputInputTaskTaskgroup

ShapeOptimization

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SimulationSolutionDataInternal

CFXSolution

FluentSolution

IcePakResults

MechanicalSolution

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

293Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 302: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

Results

MechanicalResultsSimulationSolution

SimulationResults

Table 48: Six Sigma Analysis

OutputInputTaskTaskgroup

Six SigmaAnalysis

Design ofExperiments(SSA)

ParametricContext

DOEModel

DesignPointsDataTransfer

ResponseSurface (SSA)

ResponseSurfaceModelParametricContext

ResponseSurfaceDataTransferDOEModel

DesignPointsDataTransfer

Six SigmaAnalysis

SixSigmaModelParametricContext

ResponseSurfaceModel

Table 49: Static Structural (ABAQUS)

OutputInputTaskTaskgroup

StaticStructural(ABAQUS)

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.294

ANSYS Workbench Task Inputs and Outputs

Page 303: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SimulationSolutionDataInternal

CFXSolution

FluentSolution

IcePakResults

MechanicalSolution

ExternalDataSetup

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

SimulationResults

Table 50: Static Structural

OutputInputTaskTaskgroup

StaticStructural

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

295Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 304: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SystemCouplingSetupDataEnhancedModelData

SimulationSolutionDataInternal

CFXSolution

FluentSolution

IcePakResults

MechanicalSolution

ExternalDataSetup

AnsoftForceDataObject

EnhancedMechanicalModel

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

ExternalModelOutputProviderSimulationSolution

MechanicalResults

SimulationResults

Table 51: Static Structural (Samcef)

OutputInputTaskTaskgroup

StaticStructural(Samcef )

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.296

ANSYS Workbench Task Inputs and Outputs

Page 305: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SimulationSolutionDataInternal

CFXSolution

FluentSolution

IcePakResults

MechanicalSolution

ExternalDataSetup

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

SimulationResults

Table 52: Steady-State Thermal (ABAQUS)

OutputInputTaskTaskgroup

Steady-StateThermal(ABAQUS)

EngineeringData

EngineeringDataFEMSetup

297Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 306: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

FluentSolution

IcePakResults

MechanicalSolution

SimulationSolutionDataInternal

CFXSolution

ExternalDataSetup

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

SimulationResults

Table 53: Steady-State Thermal

OutputInputTaskTaskgroup

Steady-StateThermal

EngineeringData

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.298

ANSYS Workbench Task Inputs and Outputs

Page 307: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SystemCouplingSetupDataSimulationSolutionDataInternal

CFXSolution

FluentSolution

IcePakResults

MechanicalSolution

ExternalDataSetup

AnsoftHeatLossDataObject

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

SimulationResults

Table 54: Taskgroup Coupling

OutputInputTaskTaskgroup

TaskgroupCoupling

299Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 308: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

Setup

CouplingSetupProviderSystemCouplingSetupData

ExternalDataSetup

Solution

NoneCouplingSetupProvider

Table 55: Thermal-Electric

OutputInputTaskTaskgroup

Thermal-Electric

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

CFXSolution

FluentSolution

IcePakResults

ExternalDataSetup

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.300

ANSYS Workbench Task Inputs and Outputs

Page 309: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

Results

MechanicalResultsSimulationSolution

SimulationResults

Table 56: Throughflow

OutputInputTaskTaskgroup

Throughflow

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Setup

VistaTFSetupVistaGeometry

VistaTFPhysics

Geometry

Solution

VistaTFSolutionVistaTFSetup

VistaTFSolution

Results

CFDAnalysisCFXSolution

FluentSolution

VistaTFSolution

IcePakResults

PolyflowSolutionType

MechanicalSolution

ICEData

Table 57: Throughflow (BladeGen)

OutputInputTaskTaskgroup

Throughflow(BladeGen)

BladeDesign

TurboGeometryNone

VistaGeometry

Setup

VistaTFSetupVistaGeometry

301Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 310: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

VistaTFPhysics

Geometry

Solution

VistaTFSolutionVistaTFSetup

VistaTFSolution

Results

CFDAnalysisCFXSolution

FluentSolution

VistaTFSolution

IcePakResults

PolyflowSolutionType

MechanicalSolution

ICEData

Table 58: Transient Structural (ABAQUS)

OutputInputTaskTaskgroup

TransientStructural(ABAQUS)

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.302

ANSYS Workbench Task Inputs and Outputs

Page 311: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SimulationSolutionDataInternal

CFXSolution

FluentSolution

IcePakResults

MechanicalSolution

ExternalDataSetup

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

SimulationResults

Table 59: Transient Structural

OutputInputTaskTaskgroup

TransientStructural

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

303Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 312: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SystemCouplingSetupDataEnhancedModelData

SimulationSolutionDataInternal

CFXSolution

FluentSolution

IcePakResults

MechanicalSolution

ExternalDataSetup

AnsoftForceDataObject

EnhancedMechanicalModel

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

ExternalModelOutputProviderSimulationSolution

MechanicalResults

SimulationResults

Table 60: Transient Structural (Samcef)

OutputInputTaskTaskgroup

TransientStructural(Samcef )

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.304

ANSYS Workbench Task Inputs and Outputs

Page 313: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SimulationSolutionDataInternal

CFXSolution

FluentSolution

IcePakResults

MechanicalSolution

ExternalDataSetup

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

SimulationResults

Table 61: Transient Thermal (ABAQUS)

OutputInputTaskTaskgroup

TransientThermal(ABAQUS)

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Model

305Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 314: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SimulationSolutionDataInternal

CFXSolution

FluentSolution

IcePakResults

MechanicalSolution

ExternalDataSetup

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

SimulationResults

Table 62: Transient Thermal

OutputInputTaskTaskgroup

TransientThermal

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Geometry

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.306

ANSYS Workbench Task Inputs and Outputs

Page 315: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SystemCouplingSetupDataSimulationSolutionDataInternal

CFXSolution

FluentSolution

IcePakResults

MechanicalSolution

ExternalDataSetup

AnsoftHeatLossDataObject

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

SimulationResults

Table 63: Transient Thermal (Samcef)

OutputInputTaskTaskgroup

TransientThermal(Samcef )

EngineeringData

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryFEMSetup

TurboGeometry

307Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 316: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

AnsoftCADObject

ICEData

Geometry

Model

MechanicalModelSimulationEngineeringData

MechanicalMeshSimulationModelGeneratedMesh

SimulationGeneratedMeshCompositeEngineeringData

SimulationEngineeringDataSolidSectionData

SimulationModelGeneratedMeshExternalModelOutputProvider

ExternalDataSetup

EngineeringData

Geometry

Setup

SimulationSetupMechanicalModel

MechanicalSetupMechanicalMesh

SimulationSolutionDataInternal

CFXSolution

FluentSolution

IcePakResults

MechanicalSolution

ExternalDataSetup

Solution

MechanicalSolutionSimulationSetup

SimulationSolutionDataInternal

SimulationSolution

Results

MechanicalResultsSimulationSolution

SimulationResults

Table 64: Turbomachinery Fluid Flow (BladeEditor)

OutputInputTaskTaskgroup

TurbomachineryFluid Flow(BladeEditor)

Geometry

GeometryFEMSetup

TurboGeometry

AnsoftCADObject

ICEData

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.308

ANSYS Workbench Task Inputs and Outputs

Page 317: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

Geometry

TurboMesh

TurboMeshTurboGeometry

CFXMeshGeometry

FluentImportable

Setup

CFXSetupSimulationGeneratedMesh

SystemCouplingSetupDataCFXMesh

MechanicalSetup

Solution

CFXSolutionCFXSetup

CFXSolution

Results

CFDAnalysisCFXSolution

FluentSolution

VistaTFSolution

IcePakResults

PolyflowSolutionType

MechanicalSolution

ICEData

Table 65: TurboGrid

OutputInputTaskTaskgroup

TurboGrid

TurboMesh

TurboMeshTurboGeometry

CFXMeshGeometry

FluentImportable

Table 66: Vista TF

OutputInputTaskTaskgroup

Vista TF

Setup

VistaTFSetupVistaGeometry

VistaTFPhysics

Geometry

Solution

309Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 318: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

VistaTFSolutionVistaTFSetup

VistaTFSolution

Results

CFDAnalysisCFXSolution

FluentSolution

VistaTFSolution

IcePakResults

PolyflowSolutionType

MechanicalSolution

ICEData

Table 67: Vista AFD

OutputInputTaskTaskgroup

Vista AFD

Meanline

VistaAFDMeanlineProviderNone

Design

VistaAFDDesignProviderVistaAFDMeanlineProvider

Analysis

NoneVistaAFDDesignProvider

Table 68: Vista CCD

OutputInputTaskTaskgroup

Vista CCD

BladeDesign

VistaCCDBladeDesignProviderNone

Table 69: Vista CCD (with CCM)

OutputInputTaskTaskgroup

Vista CCD(with CCM)

BladeDesign

VistaCCDBladeDesignProviderNone

PerformanceMap

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.310

ANSYS Workbench Task Inputs and Outputs

Page 319: ANSYS ACT Developers Guide

OutputInputTaskTaskgroup

NoneVistaCCDBladeDesignProvider

Table 70: Vista CPD

OutputInputTaskTaskgroup

Vista CPD

Blade Design

NoneNone

Table 71: Vista RTD

OutputInputTaskTaskgroup

Vista RTD

Blade Design

NoneNone

Table 72: Vista RTD (Beta)

Vista RTD (Beta)

Blade Design

VistaGeometryNone

VistaTFPhysics

Table 73: ACP (Pre)

ACP (Pre)

Engineering Data

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryAnsoftCADObject

FEMSetup

Geometry

ICEData

TurboGeometry

Model

MechanicalMeshCompositeEngineeringData

MechanicalModelEngineeringData

SimulationEngineeringData

ExternalDataSetup

SimulationGeneratedMesh

ExternalModelOutputProvider

SimulationModelGeneratedMesh

Geometry

311Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 320: ANSYS ACT Developers Guide

SimulationEngineeringData

SimulationModelGeneratedMesh

SolidSectionData

Setup

ACPSetupDataACPSetupData

CompositeEngineeringData

EngineeringData

EnhancedModelDataGeometry

SolidSectionDataSimulationGeneratedMesh

Table 74: ACP (Post)

ACP (Post)

Engineering Data

EngineeringDataFEMSetup

MaterialMatML31

Geometry

GeometryAnsoftCADObject

FEMSetup

Geometry

ICEData

TurboGeometry

Model

MechanicalMeshCompositeEngineeringData

MechanicalModelEngineeringData

SimulationEngineeringData

ExternalDataSetup

SimulationGeneratedMesh

ExternalModelOutputProvider

SimulationModelGeneratedMesh

Geometry

SimulationEngineeringData

SimulationModelGeneratedMesh

SolidSectionData

Results

EngineeringData

MAPDLSolution

MechanicalSolution

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.312

ANSYS Workbench Task Inputs and Outputs

Page 321: ANSYS ACT Developers Guide

SimulationGeneratedMesh

Table 75: Maxwell 3D

Maxwell 3D

Geometry

AnsoftCADObjectAnsoftCADGeometryEntity

AnsoftCellInOutEntityAnsoftGeometryManagerDataObject

AnsoftGeometryManagerDataObject

Geometry

Setup

AnsoftCellInOutEntityAnsoftCellInOutEntity

FeedbackIteratorSetup

Solution

AnsoftForceAndMomentDataObject

AnsoftCellInOutEntity

AnsoftForceDataObject

AnsoftHeatLossDataObject

Table 76: Maxwell 2D

Maxwell 2D

Geometry

AnsoftCADObjectAnsoftCADGeometryEntity

AnsoftCellInOutEntityAnsoftGeometryManagerDataObject

AnsoftGeometryManagerDataObject

Geometry

Setup

AnsoftCellInOutEntityAnsoftCellInOutEntity

FeedbackIteratorSetup

Solution

AnsoftForceAndMomentDataObject

AnsoftCellInOutEntity

AnsoftForceDataObject

AnsoftHeatLossDataObject

Table 77: RMxprt

RMxprt

Setup

AnsoftCellInOutEntity

313Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 322: ANSYS ACT Developers Guide

Solution

AnsoftCellInOutEntity

Table 78: Simplorer

Simplorer

Setup

AnsoftCellInOutEntityMechanicalSetup

Solution

AnsoftCellInOutEntity

Table 79: FeedbackIterator

FeedbackIterator

Feedback Iterator

FeedbackIteratorEntityFeedbackIteratorSetup

Table 80: Turbo Setup

Turbo Setup

Turbo Setup

Table 81: Turbo Machinery Fluid Flow (Bladegen) (Beta)

TurbomachineryFluid Flow(BladeGen) (Beta)

Blade Design

TurboGeometry

VistaGeometry

Turbo Mesh

CFXMeshGeometry

FluentImportableTurboGeometry

TurboMesh

Setup

CFXSetupCFXMesh

SystemCouplingSetupData

MechanicalSetup

SimulationGeneratedMesh

Solution

CFXSolutionCFXSetup

CFXSolution

Results

CFDAnalysisCFXSolution

FluentSolution

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.314

ANSYS Workbench Task Inputs and Outputs

Page 323: ANSYS ACT Developers Guide

ICEData

IcePakResults

MechanicalSolution

PolyflowSolutionType

VistaTFSolution

Table 82: Turbo Machinery Fluid Flow

TurbomachineryFluid Flow

Turbo Mesh

CFXMeshGeometry

FluentImportableTurboGeometry

TurboMesh

Setup

CFXSetupCFXMesh

SystemCouplingSetupData

MechanicalSetup

SimulationGeneratedMesh

Solution

CFXSolutionCFXSetup

CFXSolution

Results

CFDAnalysisCFXSolution

FluentSolution

ICEData

IcePakResults

MechanicalSolution

PolyflowSolutionType

VistaTFSolution

315Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 324: ANSYS ACT Developers Guide

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.316

Page 325: ANSYS ACT Developers Guide

Appendix B. Data Transfer Types

Table 83: Data Transfer Types and Properties

PropertyTransfer Type

ACPSetupData

ACPFileReference

ACPPreFileReference

AnsoftCADGeometryEntity

GeometryFilePath

AnsoftCADObject

AnsoftHeatLossDataObject

AnsoftTransferXMLString

AnsoftProjectResultsFolderAtCurrentDP

AnsoftForceDataObject

AnsoftTransferXMLString

AnsoftProjectResultsFolderAtCurrentDP

AnsoftForceAndMomentDataObject

AnsoftTransferXMLString

AnsoftProjectResultsFolderAtCurrentDP

AnsoftGeometryManagerDataObject

AnsoftCellInOutEntity

FeedbackIteratorEntity

MAPDLSolution

TransferFile

AuxiliaryFiles

MAPDLDatabse

TransferFile

AuxiliaryFiles

MAPDLResults

AuxiliaryFiles

MAPDLCdb

TransferFile

AuxiliaryFiles

AqwaModel

AqwaSetup

AqwaSolution

317Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 326: ANSYS ACT Developers Guide

PropertyTransfer Type

AqwaResults

AutodynSetup

CFDAnalysis

PostStateFile

CFXSetup

CFXSolverInputFile

MAPDLSolverInputFile

CFXSolution

MResLoadOption

CFXResultsFile

AuxiliaryFiles

MAPDLResultsFile

Geometry

GeometryFilePath

PlugInName

ParametricContext

DOEModel

DesignPointsDataTransfer

ResponseSurfaceModel

ResponseSurfaceDatTransfer

OptimizationModel

CorrelationModel

ROModel

SixSigmaModel

EngineeringData

TransferFile

Material

ExternalConnectionProperties

ExternalDataSetup

TransferFile

ExternalModelOutputProvider

TransferFile

InputFiles

SolidSectionData

TransferFile

AuxiliaryFiles

CompositeSectionFiles

EnhancedMechanicalModel

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.318

Data Transfer Types

Page 327: ANSYS ACT Developers Guide

PropertyTransfer Type

EnhancedModelData

FEMMesh

ACMOFile

FEMSetup

FEModelerFile

ANSYSInputFile

ParasolidFile

FiniteElementModelMaterials

AuxiliaryFiles

FluentTGridMesh

TransferFile

FluentSetup

CaseFile

ModelInfoFile

SystemCouplingSetupData

FluentCase

MeshFile

TransferFile

FluentSolution

CaseFile

DataFile

ICEData

ICESetupData

IcePakSetup

IcePakResults

MechanicalModel

File

EdaFile

MeshingGeneratedMeshOutputProvider

PMDBFile

ACMOFile

Mechdb

MeshingMesh

TransferFile

SimulationGeneralMesh

TransferFile

SimulationGeneratedMesh

TransferFile

319Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 328: ANSYS ACT Developers Guide

PropertyTransfer Type

MSExcelSetup

CouplingSetupProvider

TransferFile

PolyflowSetup

PolyflowSolutionType

DataFile

PubFile

GeneratedFiles

PolyflowSolution

MechanicalModel

MechanicalMesh

TransferFile

SimulationEngineeringData

TransferFiles

SimulationModelGeneratedMesh

TransferFile

SimulationSetup

MechanicalSetup

TransferFile

MechanicalSolution

SimulationSolutionDataInternal

SimulationSolution

MechanicalResults

SimulationResults

TurboGeometry

INFFilename

GeometryFilename

TurboMesh

FileName

CFXMesh

FileName

PreFileType

FluentImportable

MeshFile

FileType

Dimension

VistaGeometry

GeoData

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.320

Data Transfer Types

Page 329: ANSYS ACT Developers Guide

PropertyTransfer Type

TransferData

VistaTFPhysics

TransferData

VistaCCDBlaseDesignProvider

TransferData

VistaAFDMeanlineProvider

TransferData

VistaAFDDesignProvider

TransferData

VistaTFSetup

ControlFilename

GeoFilename

AeroFilename

CorrelationsFilename

VistaTFSolution

ResultsFile

RestartFile

FeedbackIteratorSetup

AUTODYN_Remap

MatML31

TransferFile

CompositeEngineeringData

TransferFile

FluentMesh

TransferFile

PolyflowTransferMesh

TransferFile

321Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

of ANSYS, Inc. and its subsidiaries and affiliates.

Page 330: ANSYS ACT Developers Guide

Release 16.2 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.322