Hello everyone,
I have a journal that pulls all the dimensions from a drawing but I want on the diameters only to split that value in half.
I can't figure out the command to tell if it's a cylindrical dimension to split that in half.
In the dimension setting there is the Measurement tab that you chose the Method(Horizontal vertical, Cylindrical, etc).
This is the code I use to pull the text and tolerance information.
I am throwing all these pieces of information to a spreadsheet.
Thank you,
Dim objects1(0) As NXOpen.DisplayableObject
Dim myDimText() As String
Dim myDimDualText() As String
Dim draftingFeatureControlFrameBuilder1
For Each myDimension As Annotations.Dimension In workPart.Dimensions
row += 1
' (1) get the current value and put that into a cell
myDimension.GetDimensionText(myDimText, myDimDualText)
objExcel.Cells(row, column) = myDimText(0)
' (1) get the current value and put that into a cell
myDimension.GetDimensionText(myDimText, myDimDualText)
objExcel.Cells(row, column + 1) = myDimText(0)
objExcel.Cells(row, column+2) = myDimension.UpperMetricToleranceValue
objExcel.Cells(row, column+0) = myDimension.GetAppendedText().GetAfterText()
objExcel.Cells(row, column+3) = myDimension.GetAppendedText().GetBeforeText()
re: cylindrical dimension
You can test the type of dimension to see what you are working with. Run the code below on a part with one or more dimensions. It will report the type of each and write a special message for each cylindrical dimension found.
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module Module137
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
For Each tempDim As Annotations.Dimension In theSession.Parts.Work.Dimensions
lw.WriteLine("dim type: " & tempDim.GetType.ToString)
If TypeOf (tempDim) Is Annotations.CylindricalDimension Then
'do something
lw.WriteLine("CYLINDRICAL DIMENSION FOUND!")
End If
Next
lw.Close()
End Sub
End Module
I ran this and I got this
I ran this and I got this list:
Now I need to get only the Cylindrical dimensions split in half, rest of them need to be exported as is.
Thank you,
dim type: NXOpen.Annotations.HorizontalDimension
dim type: NXOpen.Annotations.HorizontalDimension
dim type: NXOpen.Annotations.HorizontalDimension
dim type: NXOpen.Annotations.HorizontalDimension
dim type: NXOpen.Annotations.HorizontalDimension
dim type: NXOpen.Annotations.HorizontalDimension
dim type: NXOpen.Annotations.HorizontalDimension
dim type: NXOpen.Annotations.HorizontalDimension
dim type: NXOpen.Annotations.HorizontalDimension
dim type: NXOpen.Annotations.HorizontalDimension
dim type: NXOpen.Annotations.HorizontalDimension
dim type: NXOpen.Annotations.HorizontalDimension
dim type: NXOpen.Annotations.CylindricalDimension
dim type: NXOpen.Annotations.CylindricalDimension
dim type: NXOpen.Annotations.CylindricalDimension
dim type: NXOpen.Annotations.CylindricalDimension
dim type: NXOpen.Annotations.CylindricalDimension
dim type: NXOpen.Annotations.CylindricalDimension
dim type: NXOpen.Annotations.CylindricalDimension
dim type: NXOpen.Annotations.CylindricalDimension
dim type: NXOpen.Annotations.RadiusDimension
dim type: NXOpen.Annotations.RadiusDimension
dim type: NXOpen.Annotations.RadiusDimension
dim type: NXOpen.Annotations.HorizontalDimension
dim type: NXOpen.Annotations.RadiusDimension
dim type: NXOpen.Annotations.PerpendicularDimension
re: cylindrical dimension
When a cylindrical dimension is found, get the dimension text, convert it to a double, and divide it by 2.