This blog is the second part of a 3 part series on NX journalling

The aim of this blog post is to display dimensions of a part

Part dimensions will be stored in workPart.Dimensions and can be displayed on a listing window.

Continuing from the previous post, we could write the following program

Imports System
Imports NXOpen

Module NXJournal
Sub Main (ByVal args() As String)

Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim workPart As NXOpen.Part = theSession.Parts.Work

Dim displayPart As NXOpen.Part = theSession.Parts.Display
Dim markId1 As NXOpen.Session.UndoMarkId

markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, “Show Dimensions”)

Dim lw As ListingWindow = theSession.ListingWindow

Dim extrude1 As NXOpen.Features.Extrude = CType(workPart.Features.FindObject(“EXTRUDE(2)”), NXOpen.Features.Extrude)

extrude1.ShowDimensions()

For Each tempDim As Annotations.Dimension In workPart.Dimensions
            Dim myDimText() As String
            Dim myDimDualText() As String
            lw.WriteLine(“dimension type is ” & tempDim.GetType.ToString)
            tempDim.GetDimensionText(myDimText, myDimDualText)
            lw.WriteLine(“dimension value is ” & myDimText(0))
        Next

Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)

End Sub
End Module

The above code can also be found at https://github.com/HarshaAsh/NXBasics

One Reply to “Getting the dimensions of the selected Part”

Leave a Reply

Your email address will not be published. Required fields are marked *