____________________________________________________________________________________
Script Example in ANSYS DesignModeler
(Creating Surface from Line)
Description:
Here is an example of how to use scripts in DesignModeler.
Solution:
The script file is written in JScript (extension *.js)
// Two slashes indicate a comment
// Reading of point sequence data
var PF1 = [Link]([Link], [Link]);
[Link] = "TablePoints"; //Change feature name
[Link] = "C:\\Users\\hmachida\\Desktop\\[Link]";
[Link](); //Run Generate
// Create line body(LinesFromPoints)
var LF1 = [Link]();
[Link]([Link](1, 1), [Link](1, 2)); // Connect
ID1 of Group 1 and ID2 of Group 1
[Link]([Link](1, 2), [Link](1, 3));
[Link]([Link](1, 3), [Link](1, 4),1); // When
connecting, set the edge ID of that edge to No. 1
[Link]([Link](1, 4), [Link](1, 1));
[Link]();
// Create line body
var LF2 = [Link]();
[Link]([Link](1, 3), [Link](2, 1), 2);
[Link]([Link](2, 1), [Link](2, 2), 3);
[Link]([Link](2, 2), [Link](1, 4), 4);
[Link]();
// Create a surface body 1
var i;
var edge;
var edgeNum = [Link](); // Get number of edges from first line body
if(edgeNum > 0)
{
[Link]();
for(i=1 ; i < edgeNum+1 ; i++)
{
edge = [Link](i);
[Link](agc.TypeEdge3d, edge); // Select Edge }
var surf1 = [Link]();
[Link]();
}
© 2016 ANSYS, Inc. All rights reserved.
// Create surface body 2
[Link]();
[Link](1); // Select edge with edge ID = 1
[Link](2);
[Link](3);
[Link](4);
var surf2 = [Link]();
[Link]();
Results
Point sequence data ([Link]) used in script: text format
# Group 1
1 1 0.0 0.0 0.0
1 2 0.0 1.0 0.0
1 3 1.0 1.0 0.0
1 4 1.0 0.0 0.0
#Group 2
2 1 2.0 1.0 0.0
2 2 2.0 0.0 0.0
Reading point sequence data: a total of six points are read in two groups. It is not necessary to group the
point sequence data.
Figure 1: Points and their IDs
Create a line body of hollow squares consisting of four lines from the four points of group 1.
Here, specify edge ID = 1 only for certain edges.
© 2016 ANSYS, Inc. All rights reserved.
Figure 2: Creating first line body
Similarly, a second line body that is "U-shaped" is created from two points of group 1 and two points of
group 2. Here, edge ID = 2, 3, 4 is specified for the three edges respectively.
Figure 3: Creating second line body
In this step, all edges constituting a line body are selected to create a surface body.
Therefore, the line body must be closed.
© 2016 ANSYS, Inc. All rights reserved.
Figure 4: First surface body
The second surface body will be created using a different method. In this method, the edge is selected
using the ID of the edge specified at the time of line body creation. The ID of the edge can be specified
irrespective of the line body and it may be shared/reused.
Figure 5: Second surface body created with ID
Additional Notes
The main problem with creating a surface body is getting the wrong side of the face. In 2D analysis, it
may be a big issue in ANSYS Meshing if the face is not properly oriented. With the second method, you
can rotate the face clockwise, but in the first method, DesignModeler will choose an orientation based on
the table. If you end up with the opposite face, simply turn it over using Surface Flip.
Also, the edge ID used in the second method can only be set in the script; it cannot be set from normal
GUI operations.
© 2016 ANSYS, Inc. All rights reserved.