Showing results for 
Search instead for 
Do you mean 

How to get depth/height of a cylinder face?


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








Re: How to get depth/height of a cylinder face?

NX CAM does also Support for journals, doesn't it? Have you tried to record the steps in NX CAM? Maybe the API lets you define the percentage of the position?

Re: How to get depth/height of a cylinder face?

Hi Josch,


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.





Re: How to get depth/height of a cylinder face?

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.


Frank Swinkels

Re: How to get depth/height of a cylinder face?

Do you have a "hole Feature"? Maybe you can get the Information from ".Location" and some calculations with the direction vector and the depth?

Re: How to get depth/height of a cylinder face?

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





Re: How to get depth/height of a cylinder face?

[ Edited ]

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():

        #create instance of class


    except Exception as ex:
        # ---- Enter your exception handling code here -----
            "Block Styler", NXOpen.NXMessageBox.DialogType.Error, str(ex))

if __name__ == "__main__":


Re: How to get depth/height of a cylinder face?

You probably shouldn't use hole features. Many holes are made without hole features, and hole features sometimes represent things that are not holes. Look for cylindrical faces that span 360 degrees. Then, as the other reply suggested, get the bounding box of the face, and it's centerline. Use these to compute the point. If you need more details, please ask again.

Re: How to get depth/height of a cylinder face?

Hello Yamada


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. 

Re: How to get depth/height of a cylinder face?

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.