Scripting API

The Scripting Application Program Interface (API) is beneficial for converting large files to geometry, or to create many similar parts by making simple changes to the script file.

This feature provides the option of running JScript files (extension .js) to create basic geometry in the DesignModeler application. Access to the DesignModeler application functions is accessible via the prefix 'agb.', as in the command:

var LF1 = agb.LinePt();

To execute one of these files, click Run Script in the File Menu. This opens a file browser window where you can select the file to run.


Note:  Although JScript is case sensitive, an error message is not generated when an inaccurate variable is entered. JScript allows mixed-case variables by the same name to coexist.


Scripting API topics:

Creation Limits

Bound by the definitions in script, some items can be created via a single command, while others take multiple commands for the full definition. In the multiple command cases, the first command creates the basic item or feature, then additional commands provide the additional required information. This additional information can be in the form of functions or properties of the base object, as noted in:

For most of the multiple commands, an 'agb.Regen();' command is required to complete them. In these cases, the feature in not completely created until the Regen command is executed. If you are creating multiple features, you cannot simply put a single Regen() command after all of them. The Regen command must follow each feature definition as it completes the definition of that feature.

Special Constants

Some commands will require special constants as input arguments. These constants are accessed as 'agc.Name'. For example, when creating a Point feature, you need to provide the Point type and Definition type. Because there is only one form of the Point feature available in script, the following example script can be used to create a Point feature from a coordinate file.

var PF1 = agb.FPoint(agc.FpointConstruction, agc.FPointCoordinateFile);
PF1.CoordinateFile = "D:\\Samples\\SampleCoordFile.txt";
agb.Regen();

In this simple script, the basic Point feature (PF1) is created first, using constants to designate the type of Point feature to create. Next the "Coordinate File" property of the feature is set, giving the full path and name of the coordinate file to read. When the '\' is included in a text string, it is given twice, even though this represents just one '\' in the actual path. Finally the Regen() command completes the operation.

In general most features have a "Name" property. This allows you to set the name that will appear in the tree for this feature. For example, in the above sample, an additional line could be added to set the name that would appear in the tree:

PF1.Name = "BoxPoints";

Note:   The file names using backslash paths apply to the Windows operating system. Linux users must use forward slashes instead.


Sketch Examples

An easy way to create examples of many sketch commands is to create a sketch interactively, then use the Write Script option under the File Menu. There is also an example script shown there.

Customizing DesignModeler with Ansys ACT

With Ansys ACT, you can create custom applications or “extensions” to customize supported Ansys products, including DesignModeler.  ACT provides internal mechanisms that allow you to customize DesignModeler, and then manages the interfaces between DesignModeler and your extensions.

ACT provides two levels of DesignModeler customization:

  • Direct, API-driven product customization

    ACT enables direct, API-driven product customization via standard extensions.  In DesignModeler, this includes generating geometries, defining geometric properties, and applying various geometric operations.

    For more information, see DesignModeler Feature Creation and DesignModeler APIs in the ACT Customization Guide for DesignModeler.

  • Process compression and automation

    ACT enables process compression and automation via wizard extensions, which enable you to leverage both the functionality of DesignModeler and the scripting capabilities of the Workbench framework API.

    When a wizard extension is exposed in DesignModeler, it provides guidance within the application workflow, walking non-expert users step-by-step through a simulation.

    For more information, see DesignModeler Wizards in the ACT Customization Guide for DesignModeler.