I want to create a point at a position where it is at 1/3 of the selected hole depth and at the hole center. How should i do it? Is there a way to know the depth/height of a hole/cylinder?
A little introduction, in NX CAM, we have a cylinder probing function. When you select a cylinder face and define the probing depth as the mid-point, NX computes the mid-point position according to the depth/height of the cylinder face.
For example, if a hole with the depth of 20 mm is selected, the mid-point computed will be located at a position where it is 10 mm from the top of the hole.
It seems that it doesn't use apis like Features.HolePackage. How does NX do it???
Thanks in advance
Thanks for the swift reply.
I know that NX CAM has apis. But that is not really the issue here and plus, I don't need the CAM apis.
I want to know how to get the depth/height of a given cylinder face. So that I can create a point at 1/3 of its depth/height.
If you can obtainn the cylinder feature then you can simply get the feature expressions for diameter and height and the cylinder origin and cylinder direction which should then allow you determine the required point.
Thank you for your reply.
I tried a sample script from the GTAC website yesterday and found out that when it is a through hole, the ".depth" function returns "through hole". I am not familiar with "feature" so I will have a closer look into it.
As for the quesion, I found a very simple work around:
1) Extract the cylinder centerline
2) measure the length of this centerline.
Thank you all for the help
you could try using a bounding box function to get the height. Code below is written in Python and there some more detailed examples in the SampleNXOpen folder. You could use the Point3D class to create a point in space
import NXOpen import NXOpen.BlockStyler import NXOpen.Features class measure_height: def __init__(self): #bunch of code here def bounding_box(self): for body in workPart.Bodies: #calculates the bounding box and then creates a box via the "create box command" (min_corner, directions, distances) = self.theUfSession.ModlGeneral.AskBoundingBoxExact(
body.Tag,0) self.theLw.WriteLine("Cylinder height is" + str(distances)) def main(): try: #create instance of class your_measure_height=measure_height() your_measure_height.bounding_box() except Exception as ex: # ---- Enter your exception handling code here ----- NXOpen.UI.GetUI().NXMessageBox.Show( "Block Styler", NXOpen.NXMessageBox.DialogType.Error, str(ex)) finally: your_measure_height.Dispose() if __name__ == "__main__": main()
I solved this problem a year ago by using virtual curve builder. It worked fine until I came across some clients with old computers installed with NX 7.5 32 bit. This "CreateVirtualCurveBuilder" is just broken in their computers. So I have to find a new way to extract the depth of a cylinder face.
I wonder how do you know the height of the cylinder face with bounding box? If you use max - min, it will only work with the cylindrical face with height larger than the diameter.
The .AskFaceData method will return the axis direction for a cylindrical face. One solution would be to use this direction in conjunction with .AskBoundingBoxAligned to determine the length of the face in the axis direction.