×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

NX Journaling Help

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources