Submitted by Mahoor on Fri, 11/13/2015 - 03:58
Forums:
Hello,
A very basic question:
How can I select a face of which I know three (or more) points? Do we have something like the following?
Dim face1 as NXOpen.Face = GetFace(p1, p2, p3)
re: selecting a face
So you want to select a face based on a number of points that lie on the face?
I'm pretty sure that this can be done, but I don't know of any function that will take the points as input and directly return the face. However, there are functions that will tell you if a point lies on a face. You can iterate through the faces in the file, testing each until you find the correct face. One such method is AskPointContainment.
re: selecting a face
I have a number of bodies in my part. On one face of each of them there is an Arc, of which I know the attributes. Actually for each Arc I need to select its body in a loop, and I thought by knowing the face, on which the Arc exists and using GetBody(), the desired body can be selected.
Do you think this is a proper way? If not, could you please help me with a piece of code which can select the body, on which an specific Arc exists?
Regards
re: find face
One way to do it would be to iterate through the .Arcs collection to find the arc that you want, then iterate through the .Bodies collection and perform a distance measurment from arc to body - the body with the zero distance (or near zero within tolerance) is the body that you are looking for.
Speedups
Comparing every arc with every face is obviously going to be pretty slow on large models. It's worth trying it, to see if it's fast enough for your purposes. If it's not, you need some quick way to eliminate arcs or faces from consideration, with doing a lot of math. Among other things, there are some simple tests based on the center-point of the arc. For example, an arc can lie on a plane only if its center lies on the plane, and checking that a point lies on a (infinite) plane is very fast/easy. Similarly, an arc can lie on a cylinder only if its center-point lies on the cylinder's centerline. And so on.