Null tag not allowed: Changing the color of composite curves within the same journal file using VB
Null tag not allowed: Changing the color of composite curves within the same journal file using VB
(OP)
I am writing a journal file which is designed to extract a composite curve from a selected edge (or group of edges), assign it some attributes, and also give it a bright color so the user knows they've already done the process on that edge, after the process. Everythiing runs flawlessly, with the exception of the color change.
The error I'm getting is this: "NXOpen.NXException: Null tag not allowed"
at NXOpen.DisplayModification.Apply(DisplayableObject[] objects)
at [tool name].ColorChange(CompositeCurve_curve3) in [file location]:line 625
at [tool name].apply_cb() in [file location]:line 277
Line 277 is where the function is called. Line 625 is where my issue is. Here's mycode:
.
.
.
ColorChange(compCurve)
.
.
.
Public Function ColorChange(ByRef curve3 As Features.CompositeCurve) ', ByRef WeldName As String)
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim curves1() As Curve
curves1 = GetCurvesOfCompositeCurve(curve3) 'this extracts all the curve ibjects from the composite curve feature as an array of curves
Dim dispObjs(curves1.Length - 1) As DisplayableObject
For i As Integer = 0 To curves1.Length - 1
dispObjs(i) = CType(curves1(i), DisplayableObject)
Next
Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()
displayModification1.NewColor = 3
displayModification1.Apply(dispObjs) 'this is line 625
displayModification1.Dispose()
End Function
I'd really appreciate any advice anyone can offer, I have almost no experience with programming and this specific function has given me lots of grief.
Please let me know if any more information.
Thank you,
Peter
The error I'm getting is this: "NXOpen.NXException: Null tag not allowed"
at NXOpen.DisplayModification.Apply(DisplayableObject[] objects)
at [tool name].ColorChange(CompositeCurve_curve3) in [file location]:line 625
at [tool name].apply_cb() in [file location]:line 277
Line 277 is where the function is called. Line 625 is where my issue is. Here's mycode:
.
.
.
ColorChange(compCurve)
.
.
.
Public Function ColorChange(ByRef curve3 As Features.CompositeCurve) ', ByRef WeldName As String)
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim curves1() As Curve
curves1 = GetCurvesOfCompositeCurve(curve3) 'this extracts all the curve ibjects from the composite curve feature as an array of curves
Dim dispObjs(curves1.Length - 1) As DisplayableObject
For i As Integer = 0 To curves1.Length - 1
dispObjs(i) = CType(curves1(i), DisplayableObject)
Next
Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()
displayModification1.NewColor = 3
displayModification1.Apply(dispObjs) 'this is line 625
displayModification1.Dispose()
End Function
I'd really appreciate any advice anyone can offer, I have almost no experience with programming and this specific function has given me lots of grief.
Please let me know if any more information.
Thank you,
Peter





RE: Null tag not allowed: Changing the color of composite curves within the same journal file using VB
RE: Null tag not allowed: Changing the color of composite curves within the same journal file using VB
CODE
www.nxjournaling.com
RE: Null tag not allowed: Changing the color of composite curves within the same journal file using VB
Thanks you very much for responding...can't tell you how annoying it was to have an automation journal work great in almost every regard but look ugly simply because I couldn't change some colors. Fortunately I did figure this out using precisely that solution a week or two ago. Here's the code I settled on:
CODE -->
Public Function ColorChange(ByRef curve3 As Features.CompositeCurve) 'changes the color of a comp-curve Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Dim displayPart As Part = theSession.Parts.Display Dim curves1() As Curve curves1 = GetCurvesOfCompositeCurve(curve3) 'gets curve objects from the composite curve feature Dim dispObjs(curves1.Length - 1) As DisplayableObject Dim displayModification1 As DisplayModification displayModification1 = theSession.DisplayManager.NewDisplayModification() displayModification1.NewColor = 6 'sets the color of the lines to yellow Dim objArray(0) As DisplayableObject For Each cu As Curve In curves1 'for each curve, Try objArray(0) = cu 'this makes the curve a displayable object displayModification1.Apply(objArray) 'and this turns that object yellow Catch ex As Exception End Try Next End Function 'changes the color of a composite curveI was under the impression that using the ".color" method I would have to regenerate all my work to display the change, so the ".redisplayobject()" is a good solution and great to know about.
Thanks again,
Peter