NX Journaling Help
NX Journaling Help
(OP)
Hello Everyone
I have this following code which loads a part/rev in NX and changes all objects on Layer 1 to Layer 180. Am getting an error while running this code. ""object reference not set to an instance of an object" ON line [allObjects = workPart.Layers.GetAllObjectsOnLayer(layerNumber)]
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpenUI
Module NXJournal
Sub Main
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim answer as String
dim layerNumber as Integer = 1
dim i as Integer = 0
Dim lw As ListingWindow = theSession.ListingWindow
Dim allObjects as NXObject()
Dim pointObject as Point
Dim myPoints as DisplayableObject()
Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()
'open a part with revision
Dim BasePart1 as BasePart
BasePart1 = theSeesion.Parts.OpenBseDisplay("@DB/AB0000123/R000"",PartLoadStatus1)
allObjects = workPart.Layers.GetAllObjectsOnLayer(layerNumber)
lw.Open
for each someObject as NXObject in allObjects
redim preserve myPoints(i)
myPoints(i) = someObject
i += 1
next
'move or copy object to another layer using the layer manager
'workPart.Layers.MoveDisplayableObjects(4, myPoints)
workPart.Layers.CopyObjects(180, myPoints)
With displayModification1
'move layers with a display modification
.NewLayer = 180
.Apply(myPoints)
.Dispose
End With
End Sub
End Module
Please Help
I have this following code which loads a part/rev in NX and changes all objects on Layer 1 to Layer 180. Am getting an error while running this code. ""object reference not set to an instance of an object" ON line [allObjects = workPart.Layers.GetAllObjectsOnLayer(layerNumber)]
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpenUI
Module NXJournal
Sub Main
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim answer as String
dim layerNumber as Integer = 1
dim i as Integer = 0
Dim lw As ListingWindow = theSession.ListingWindow
Dim allObjects as NXObject()
Dim pointObject as Point
Dim myPoints as DisplayableObject()
Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()
'open a part with revision
Dim BasePart1 as BasePart
BasePart1 = theSeesion.Parts.OpenBseDisplay("@DB/AB0000123/R000"",PartLoadStatus1)
allObjects = workPart.Layers.GetAllObjectsOnLayer(layerNumber)
lw.Open
for each someObject as NXObject in allObjects
redim preserve myPoints(i)
myPoints(i) = someObject
i += 1
next
'move or copy object to another layer using the layer manager
'workPart.Layers.MoveDisplayableObjects(4, myPoints)
workPart.Layers.CopyObjects(180, myPoints)
With displayModification1
'move layers with a display modification
.NewLayer = 180
.Apply(myPoints)
.Dispose
End With
End Sub
End Module
Please Help




