Read Hole Callout


I am trying to read drawing dimensions to a table. I used workPart.Dimensions.ToArray() method. Linear dimensions fine. However, dimensions that made with "hole callout" have more than one entity in the array. For example, a general hole will have three dimensions in the array (HoleDimension 119341, RadiusDimension 160698, RadiusDimension 160672). Is in NX Open or UG Open a function that bound these dimensions?

Thank you,

You can check the type of the dimension, hole callouts will be type: Annotations.HoleDimension. You can use the HoleDimension properties/methods and/or the RadialDimensionBuilder to get information about the hole callout.

yes I am using radialdimensionbuilder to get information about the hole callout. But when I returning to my original array I still have 2 entities in there which I have to pull out. I can lop it and compare information I got from radialdimensionbuilder and get rid of this entities. However, is there an easier way?


I don't see a good way in the API to tell which dimensions belong to a particular hole dimension. However, I did come up with a method that seems to work. It needs more testing; if you find a situation where it gives incorrect results, please post back or email me.

The journal below will look through the dimensions in the work part. If a hole dimension is found, it will look for dimensions with no lines associated with it. These dimensions will be assumed to be "internal" to the hole dimension.

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Module Module2
    Sub Main()
        Dim theSession As Session = Session.GetSession()
        Dim theUfSession As UFSession = UFSession.GetUFSession()
        If IsNothing(theSession.Parts.BaseWork) Then
            'active part required
        End If
        Dim workPart As Part = theSession.Parts.Work
        Dim lw As ListingWindow = theSession.ListingWindow
        Const undoMarkName As String = "NXJ journal"
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)
        Dim partDimensions As New List(Of Annotations.Dimension)
        Dim holeDimensions As New Dictionary(Of Annotations.Dimension, List(Of Annotations.Dimension))
        Dim theHoleDim As Annotations.HoleDimension = Nothing
        Dim holeDimFound As Boolean = False
        For Each tempDim As Annotations.Dimension In workPart.Dimensions
            If TypeOf (tempDim) Is Annotations.HoleDimension Then
                holeDimFound = True
                theHoleDim = tempDim
                holeDimensions.Add(theHoleDim, New List(Of Annotations.Dimension))
                Continue For
            End If
            If holeDimFound Then
                'any dimensions after a hole dimension that do not
                'have line or arrow blocks belong to the hole dimension
                Dim numBlock(4) As Integer
                theUfSession.Drf.AskNumberBlocks(tempDim.Tag, numBlock)
                If numBlock(0) = 0 Then
                    'dimension is used by the hole dimension
                    If holeDimensions.ContainsKey(theHoleDim) Then
                    End If
                    'this dimension does not belong to the previous hole dimension
                    'reset the "hole dimension found" flag
                    holeDimFound = False
                End If
            End If
        'report the dimensions found
        lw.WriteLine("part dimensions shown (main dim text shown)")
        For Each tempDim As Annotations.Dimension In partDimensions
            lw.WriteLine("tag: " & tempDim.Tag.ToString)
            lw.WriteLine("type: " & tempDim.GetType.ToString)
            Dim mainText() As String = Nothing
            Dim dualText() As String = Nothing
            tempDim.GetDimensionText(mainText, dualText)
            For Each tempLine As String In mainText
                lw.WriteLine("text: " & tempLine)
        lw.WriteLine("hole dimensions found")
        For Each kvp As KeyValuePair(Of Annotations.Dimension, List(Of Annotations.Dimension)) In holeDimensions
            lw.WriteLine("tag: " & kvp.Key.Tag.ToString)
            lw.WriteLine("type: " & kvp.Key.GetType.ToString)
            Dim mainText() As String = Nothing
            Dim dualText() As String = Nothing
            kvp.Key.GetDimensionText(mainText, dualText)
            For Each tempLine As String In mainText
                lw.WriteLine("text: " & tempLine)
            lw.WriteLine("internal dims:")
            For Each temp As Annotations.Dimension In kvp.Value
                lw.WriteLine("  tag: " & temp.Tag.ToString)
                lw.WriteLine("  type: " & temp.GetType.ToString)
                Dim mainText2() As String = Nothing
                Dim dualText2() As String = Nothing
                temp.GetDimensionText(mainText2, dualText2)
                For Each tempLine As String In mainText2
                    lw.WriteLine("  text: " & tempLine)
    End Sub
    Public Function GetUnloadOption(ByVal dummy As String) As Integer
        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
    End Function
End Module

Thank you, I will look thru the code.


Thank you again for your solution. However, I decided to go with NXObject firstObject = firstAssociativity.FirstObject; to define holecallout members in the dimension array I ask for an Associative object. Holecallout members reference arcs with 0 0 coordinates and/or lines that start from 0 0.
For now I sort the dimension array based on that principle. But I am still looking for the improvement.
Thank you


After chatting with GTAC, I found out that the dimensions used by the hole callout will have a layer property value of "257". This is outside the normal layer range and is a good indicator that the dimension is used internally by something else (a hole callout, in this case).

Thank you! It will add to my verification.