niedzviedz
Mechanical
- Apr 1, 2012
- 307
Hello everybody,
I would like to change every centerline (2D, 3D etc) and center mark to specific color, for example 186. I have found some example here Link but there is a problem. For example when I add:
I receive an error: "cannot convert integer to NXOpen.NXcolor". Any one can help with this part?
I tried:
Dim color as NXcolor = (255,0,0) and also have some errors, so I changed my code to this:
but i receive an error (memory access violation) in this line:
displayModification1.Apply(objects1)
any help will be appreciated.
With best regards
Michael
I would like to change every centerline (2D, 3D etc) and center mark to specific color, for example 186. I have found some example here Link but there is a problem. For example when I add:
Code:
centerline3dBuilder1.Settings.Color = 186
I receive an error: "cannot convert integer to NXOpen.NXcolor". Any one can help with this part?
I tried:
Dim color as NXcolor = (255,0,0) and also have some errors, so I changed my code to this:
Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.Annotations
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 lw As ListingWindow = theSession.ListingWindow
Dim count As Integer = 0
Dim Color as Integer = 186
lw.open
For each cline As Centerline in workPart.Annotations.Centerlines
count = count+1
'lw.WriteLine(count.ToString() & ". " & cline.ToString() & " Type: " & cline.GetType().ToString())
If TypeOf cline Is NXOpen.Annotations.Centerline3d Then
Dim markId1 As NXOpen.Session.UndoMarkId
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Edit Object Display")
Dim displayModification1 As NXOpen.DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()
displayModification1.ApplyToAllFaces = True
displayModification1.ApplyToOwningParts = False
displayModification1.NewColor = Color
Dim objects1(0) As NXOpen.DisplayableObject
for each centerline2d1 As NXOpen.Annotations.Centerline2d in workPart.annotations.Centerlines
objects1(0) = centerline2d1
displayModification1.Apply(objects1)
displayModification1.Dispose()
next
Else If TypeOf cline Is NXOpen.Annotations.Centerline2d Then
Else If TypeOf cline Is NXOpen.Annotations.SymmetricalCenterline Then
Else If TypeOf cline Is NXOpen.Annotations.CenterMark Then
Else If TypeOf cline Is NXOpen.Annotations.BoltCircleCenterline Then
Else
lw.WriteLine(" -> Unknown Centerline Type")
End If
Next
Return
lw.close
End Sub
End Module
but i receive an error (memory access violation) in this line:
displayModification1.Apply(objects1)
any help will be appreciated.
With best regards
Michael