CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ANSYS Meshing & Geometry (https://www.cfd-online.com/Forums/ansys-meshing/)
-   -   [DesignModeler] Find face normals to selected faces (https://www.cfd-online.com/Forums/ansys-meshing/190861-find-face-normals-selected-faces.html)

Pallati July 24, 2017 14:16

Find face normals to selected faces
 
Hi Everbody,
I am writing a script (JScript) in Design Modeler which automatically creates face splits on surfaces. We select a set of bodies on which we require facesplits at the contact surfaces and run the script. The script was written in the following way:
1. Select a set of bodies on which we intend to split faces at the contact surfaces and run the script.
2. Find distance between each body using 'Distance Finder' in Design Modeler and consider only the bodies which have zero distance between them.
3. Consider a single body from set of bodies obtained from step 2. Store the labels of each face of the selected body in a variable, say 'a'.
4. Now consider all the bodies which are at zero distance with the selected body and store labels of all its surfaces in a variable, say 'b'.
5. Consider each surface stored in 'a' and compare with each and every surface stored in 'b' to find the distance using 'Distance Finder'. Take the surfaces in 'b' which have zero distance with surfaces in 'a' and store the labels of edges of those particular surfaces in a separate variable 'c'. Now we have faces to be split in 'a' and the edges with which it should be split in 'c'.
6. Invoke 'Face Split' feature in Design Modeler and feed the surfaces to be split (stored in 'a') to "Target Face" and the edges with which they split (stored in 'c') to "Tool Geometry"and "Generate".
7. Loop over each body until all the bodies are split.
I am facing a problem in Step 5. I am able to successfully filter the surfaces which have zero distance between them but these surfaces also include surfaces which are at an angle and have zero distance. This is because 'Distance Finder' in Design Modeler gives zero distance for inclined surfaces with one edge sitting on the face of another surface. Now I have to reject all those surfaces which are at an angle to each other. I couldn't get a suitable condition to give in 'if(condition)' to reject angled surfaces.

Simply put,
i). I am unable to find normals to each of selected surfaces which gives me condition to reject angled faces (how are face normals to highlighted surfaces stored in variables?, What is the syntax?, agc.DirNormal not working?, agc.DirNormal is used only when Extrude is invoked). In the following script if we could place the syntax for face normals at the commented section, hopefully problem gets solved.

var a = new Array();
var d = new Array();
var count = ag.m.GetBodySelListSize();
WBScript.Out("Number of Bodies = "+count, true);
for(i=0;i<count;i++)
{
a[i] = ag.m.GetBodySelListIndex(i).Label;
}
if(count==0){ WBScript.Out("Select Bodies",true); }
for(i=0;i<count;i++)
{
ag.m.FindEntity(0, 0, a[i], 0);
ag.m.SelectionMgr.ShowTopologicalConnections(0);
var FC = ag.m.GetFaceSelListSize();
for(n=0;n<FC;n++)
{
d[n] = ag.m.GetFaceSelListIndex(n).Label;
}
for(n=0;n<FC;n++)
{
ag.m.FindEntity(0, 0, d[n], 0);
WBScript.Out("Face Label = " + d[n],true);

//At this line I have to write syntax to find the direction/normal of selected surface which I couldn't (Help Needed)
}
}

ii). If I create plane with face and find the normal of that plane, I think I would get a condition to reject angled faces. So finding normal to plane could solve the problem.
iii). Finding the angle between two selected surfaces also solves my problem.

Solution to either i. or ii. or iii. could solve my problem. If you have any other solution please inform me. Your help is appreciated.

The document which helped me a lot is at the following location
" http://www.cadfamily.com/download-pd...ignModeler.pdf "
The script for auto facesplit is attached which didn't include the 'if(condition)' mentioned above.

Pallati July 26, 2017 11:04

Hi everybody,
Can you help me with this please.


All times are GMT -4. The time now is 13:49.