rmaddin
Mechanical
- Aug 4, 2016
- 7
Hi,
I'm trying to write a journal that will select dimensions on an existing drawing and change their color.
I have recorded a journal that does what I would like but it won't work for other drawings as I know that I need to include a loop to select dimensions in a non-sticky way.
Once working my plan is to expand this to include other drafting entities such as centerlines, symbols etc..
Here's my code, any help greatly appreciated.
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
' ----------------------------------------------
' Menu: Edit->Selection->Select All
' ----------------------------------------------
' Refer to the sample NXOpen application, Selection for "Select All" alternatives.
' ----------------------------------------------
' Menu: Edit->Object Display...
' ----------------------------------------------
' ----------------------------------------------
' Dialog Begin Color
' ----------------------------------------------
Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Edit Object Display")
Dim displayModification1 As NXOpen.DisplayModification = Nothing
displayModification1 = theSession.DisplayManager.NewDisplayModification()
displayModification1.ApplyToAllFaces = True
displayModification1.ApplyToOwningParts = False
displayModification1.NewColor = 103
Dim objects1(18) As NXOpen.DisplayableObject
Dim minorAngularDimension1 As NXOpen.Annotations.MinorAngularDimension = CType(workPart.FindObject("HANDLE R-9005"), NXOpen.Annotations.MinorAngularDimension)
objects1(0) = minorAngularDimension1
Dim perpendicularDimension1 As NXOpen.Annotations.PerpendicularDimension = CType(workPart.FindObject("HANDLE R-9049"), NXOpen.Annotations.PerpendicularDimension)
objects1(1) = perpendicularDimension1
Dim perpendicularDimension2 As NXOpen.Annotations.PerpendicularDimension = CType(workPart.FindObject("HANDLE R-9102"), NXOpen.Annotations.PerpendicularDimension)
objects1(2) = perpendicularDimension2
Dim perpendicularDimension3 As NXOpen.Annotations.PerpendicularDimension = CType(workPart.FindObject("HANDLE R-9133"), NXOpen.Annotations.PerpendicularDimension)
objects1(3) = perpendicularDimension3
Dim parallelDimension1 As NXOpen.Annotations.ParallelDimension = CType(workPart.FindObject("HANDLE R-9162"), NXOpen.Annotations.ParallelDimension)
objects1(4) = parallelDimension1
Dim cylindricalDimension1 As NXOpen.Annotations.CylindricalDimension = CType(workPart.FindObject("HANDLE R-9894"), NXOpen.Annotations.CylindricalDimension)
objects1(5) = cylindricalDimension1
Dim verticalDimension1 As NXOpen.Annotations.VerticalDimension = CType(workPart.FindObject("HANDLE R-9978"), NXOpen.Annotations.VerticalDimension)
objects1(6) = verticalDimension1
Dim verticalDimension2 As NXOpen.Annotations.VerticalDimension = CType(workPart.FindObject("HANDLE R-10010"), NXOpen.Annotations.VerticalDimension)
objects1(7) = verticalDimension2
Dim verticalDimension3 As NXOpen.Annotations.VerticalDimension = CType(workPart.FindObject("HANDLE R-10088"), NXOpen.Annotations.VerticalDimension)
objects1(8) = verticalDimension3
Dim verticalDimension4 As NXOpen.Annotations.VerticalDimension = CType(workPart.FindObject("HANDLE R-10116"), NXOpen.Annotations.VerticalDimension)
objects1(9) = verticalDimension4
Dim perpendicularDimension4 As NXOpen.Annotations.PerpendicularDimension = CType(workPart.FindObject("HANDLE R-10041"), NXOpen.Annotations.PerpendicularDimension)
objects1(10) = perpendicularDimension4
Dim verticalDimension5 As NXOpen.Annotations.VerticalDimension = CType(workPart.FindObject("HANDLE R-8479"), NXOpen.Annotations.VerticalDimension)
objects1(11) = verticalDimension5
Dim verticalDimension6 As NXOpen.Annotations.VerticalDimension = CType(workPart.FindObject("HANDLE R-8501"), NXOpen.Annotations.VerticalDimension)
objects1(12) = verticalDimension6
Dim perpendicularDimension5 As NXOpen.Annotations.PerpendicularDimension = CType(workPart.FindObject("HANDLE R-46410"), NXOpen.Annotations.PerpendicularDimension)
objects1(13) = perpendicularDimension5
Dim verticalDimension7 As NXOpen.Annotations.VerticalDimension = CType(workPart.FindObject("HANDLE R-60019"), NXOpen.Annotations.VerticalDimension)
objects1(14) = verticalDimension7
Dim cylindricalDimension2 As NXOpen.Annotations.CylindricalDimension = CType(workPart.FindObject("HANDLE R-55261"), NXOpen.Annotations.CylindricalDimension)
objects1(15) = cylindricalDimension2
Dim holeDimension1 As NXOpen.Annotations.HoleDimension = CType(workPart.FindObject("HANDLE R-45371"), NXOpen.Annotations.HoleDimension)
objects1(16) = holeDimension1
Dim horizontalDimension1 As NXOpen.Annotations.HorizontalDimension = CType(workPart.FindObject("HANDLE R-88071"), NXOpen.Annotations.HorizontalDimension)
objects1(17) = horizontalDimension1
Dim verticalDimension8 As NXOpen.Annotations.VerticalDimension = CType(workPart.FindObject("HANDLE R-72251"), NXOpen.Annotations.VerticalDimension)
objects1(18) = verticalDimension8
displayModification1.Apply(objects1)
Dim nErrs1 As Integer = Nothing
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
displayModification1.Dispose()
theSession.CleanUpFacetedFacesAndEdges()
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
End Sub
End Module
Regards,
Russell.
I'm trying to write a journal that will select dimensions on an existing drawing and change their color.
I have recorded a journal that does what I would like but it won't work for other drawings as I know that I need to include a loop to select dimensions in a non-sticky way.
Once working my plan is to expand this to include other drafting entities such as centerlines, symbols etc..
Here's my code, any help greatly appreciated.
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
' ----------------------------------------------
' Menu: Edit->Selection->Select All
' ----------------------------------------------
' Refer to the sample NXOpen application, Selection for "Select All" alternatives.
' ----------------------------------------------
' Menu: Edit->Object Display...
' ----------------------------------------------
' ----------------------------------------------
' Dialog Begin Color
' ----------------------------------------------
Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Edit Object Display")
Dim displayModification1 As NXOpen.DisplayModification = Nothing
displayModification1 = theSession.DisplayManager.NewDisplayModification()
displayModification1.ApplyToAllFaces = True
displayModification1.ApplyToOwningParts = False
displayModification1.NewColor = 103
Dim objects1(18) As NXOpen.DisplayableObject
Dim minorAngularDimension1 As NXOpen.Annotations.MinorAngularDimension = CType(workPart.FindObject("HANDLE R-9005"), NXOpen.Annotations.MinorAngularDimension)
objects1(0) = minorAngularDimension1
Dim perpendicularDimension1 As NXOpen.Annotations.PerpendicularDimension = CType(workPart.FindObject("HANDLE R-9049"), NXOpen.Annotations.PerpendicularDimension)
objects1(1) = perpendicularDimension1
Dim perpendicularDimension2 As NXOpen.Annotations.PerpendicularDimension = CType(workPart.FindObject("HANDLE R-9102"), NXOpen.Annotations.PerpendicularDimension)
objects1(2) = perpendicularDimension2
Dim perpendicularDimension3 As NXOpen.Annotations.PerpendicularDimension = CType(workPart.FindObject("HANDLE R-9133"), NXOpen.Annotations.PerpendicularDimension)
objects1(3) = perpendicularDimension3
Dim parallelDimension1 As NXOpen.Annotations.ParallelDimension = CType(workPart.FindObject("HANDLE R-9162"), NXOpen.Annotations.ParallelDimension)
objects1(4) = parallelDimension1
Dim cylindricalDimension1 As NXOpen.Annotations.CylindricalDimension = CType(workPart.FindObject("HANDLE R-9894"), NXOpen.Annotations.CylindricalDimension)
objects1(5) = cylindricalDimension1
Dim verticalDimension1 As NXOpen.Annotations.VerticalDimension = CType(workPart.FindObject("HANDLE R-9978"), NXOpen.Annotations.VerticalDimension)
objects1(6) = verticalDimension1
Dim verticalDimension2 As NXOpen.Annotations.VerticalDimension = CType(workPart.FindObject("HANDLE R-10010"), NXOpen.Annotations.VerticalDimension)
objects1(7) = verticalDimension2
Dim verticalDimension3 As NXOpen.Annotations.VerticalDimension = CType(workPart.FindObject("HANDLE R-10088"), NXOpen.Annotations.VerticalDimension)
objects1(8) = verticalDimension3
Dim verticalDimension4 As NXOpen.Annotations.VerticalDimension = CType(workPart.FindObject("HANDLE R-10116"), NXOpen.Annotations.VerticalDimension)
objects1(9) = verticalDimension4
Dim perpendicularDimension4 As NXOpen.Annotations.PerpendicularDimension = CType(workPart.FindObject("HANDLE R-10041"), NXOpen.Annotations.PerpendicularDimension)
objects1(10) = perpendicularDimension4
Dim verticalDimension5 As NXOpen.Annotations.VerticalDimension = CType(workPart.FindObject("HANDLE R-8479"), NXOpen.Annotations.VerticalDimension)
objects1(11) = verticalDimension5
Dim verticalDimension6 As NXOpen.Annotations.VerticalDimension = CType(workPart.FindObject("HANDLE R-8501"), NXOpen.Annotations.VerticalDimension)
objects1(12) = verticalDimension6
Dim perpendicularDimension5 As NXOpen.Annotations.PerpendicularDimension = CType(workPart.FindObject("HANDLE R-46410"), NXOpen.Annotations.PerpendicularDimension)
objects1(13) = perpendicularDimension5
Dim verticalDimension7 As NXOpen.Annotations.VerticalDimension = CType(workPart.FindObject("HANDLE R-60019"), NXOpen.Annotations.VerticalDimension)
objects1(14) = verticalDimension7
Dim cylindricalDimension2 As NXOpen.Annotations.CylindricalDimension = CType(workPart.FindObject("HANDLE R-55261"), NXOpen.Annotations.CylindricalDimension)
objects1(15) = cylindricalDimension2
Dim holeDimension1 As NXOpen.Annotations.HoleDimension = CType(workPart.FindObject("HANDLE R-45371"), NXOpen.Annotations.HoleDimension)
objects1(16) = holeDimension1
Dim horizontalDimension1 As NXOpen.Annotations.HorizontalDimension = CType(workPart.FindObject("HANDLE R-88071"), NXOpen.Annotations.HorizontalDimension)
objects1(17) = horizontalDimension1
Dim verticalDimension8 As NXOpen.Annotations.VerticalDimension = CType(workPart.FindObject("HANDLE R-72251"), NXOpen.Annotations.VerticalDimension)
objects1(18) = verticalDimension8
displayModification1.Apply(objects1)
Dim nErrs1 As Integer = Nothing
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
displayModification1.Dispose()
theSession.CleanUpFacetedFacesAndEdges()
' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------
End Sub
End Module
Regards,
Russell.