+47 67 57 21 00
ANSYS Tutorial: Scripting in DesignModeler
Get under the hood of ANSYS DesignModeler to ease your everyday modeling. Ever wanted to create a pattern of Planes instead of geometric entities in DesignModeler? This article will show you how to use JScripting to do just that.
Even though the ability to run scripts within DesignModeler has been possible for a long time, the procedure is not very well documented, which may be a barrier for most DesignModeler users. However, with a little investigation and a few lines of code, routine tasks can be avoided, saving both time and frustration.
A function which is not implemented in DesignModeler is making a pattern of Planes. If you for example want to use the GUI to make a circular pattern of say 50+ Planes, you have no other option than to define each and every one manually. This is quite frankly a boring and time consuming task. It would be much better to have a script to do the job for you.
JScript
The GUI programming language for the Mechanical/Meshing applications as well as DesignModeler is JScript. The syntax of JScript is similar to C and Java. Basic JScript information and resources are plentiful and a good place to start is http://www.w3schools.com/js/.
CircularPlanePattern Script
The CircularPlanePattern script first makes a copy of the plane which is highlighted in DesignModeler, then initiates a simple for-loop to copy this plane, transform and name it, activate export to Mechanical, and continue with these operations until all planes are created. The complete script is seen in the below figure.
The plane transform is defined by the function AddTransform(type, value, edge). In this case, we want to rotate the plane around the global Z-axis, which is achieved by setting type to XformGlobalZRotate, followed by the angle of rotation. The edge input can in this case be excluded.
Run Script
Before you run the script, be sure to highlight the plane you want to make a circular pattern of. Here, this is Plane7.
Then, go to File >> Run Script and choose the file which contains the script. In this case, it is simply called CircularPlanePattern.js. Click Open.
Now, DesignModeler automatically goes through the procedure of creating the circular pattern of planes as defined in the script. On the right side of the above figure, you see the Tree Outline after the plane creation is finished. It’s that easy.
If you want to export the planes to Mechanical, be sure to check the “Import Coordinate Systems” tab in the Properties window in the Workbench environment. Now, the coordinate systems created can be used to e.g. define Remote Forces in Mechanical:
This tutorial is merely an example of what you can do with a little bit of scripting in DesignModeler. For other possibilities, a peak into ANSYS Help is recommended. Here, you can find a short introduction to DesignModeler API scripting, as well as a number of other available functions and script examples.



