ArcMcE
Electrical
- Dec 7, 2015
- 4
Hello,
I'm trying to create a journal to move the components in an assembly that are currently visible to the user, to a layer. I pulled together the following code using .AskVisibleObjects, but this has the effect of moving everything on screen to the layer.
If possible I wanted it to only select the outermost components of an assembly and move them to the designated layer, so that all inner components can be switched on and off in layer settings without affecting what the user will usually see.
Is there an alternative to .AskVisibleObjects that will do this? The only other place I have noticed where this type of selection behavior occurs is when using the 'hide components in view' function in drafting mode - where you can drag a selection box over the whole assembly, and only components visible from that camera angle are selected, leaving everything else behind and not visible un-selected.
Hope this makes sense, and thanks in advance.
I'm trying to create a journal to move the components in an assembly that are currently visible to the user, to a layer. I pulled together the following code using .AskVisibleObjects, but this has the effect of moving everything on screen to the layer.
Code:
Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main (ByVal args() As String)
Dim theSession As Session = Session.GetSession()
Dim lw As ListingWindow = theSession.ListingWindow
Dim workpart As Part = theSession.Parts.Work
Dim visibleObjects() As DisplayableObject
VisibleObjects = workPart.Views.WorkView.AskVisibleObjects
Const VisLayer As Integer = 150
Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()
displayModification1.NewLayer = VisLayer
displayModification1.Apply(VisibleObjects)
displayModification1.Dispose()
End Sub
End Module
If possible I wanted it to only select the outermost components of an assembly and move them to the designated layer, so that all inner components can be switched on and off in layer settings without affecting what the user will usually see.
Is there an alternative to .AskVisibleObjects that will do this? The only other place I have noticed where this type of selection behavior occurs is when using the 'hide components in view' function in drafting mode - where you can drag a selection box over the whole assembly, and only components visible from that camera angle are selected, leaving everything else behind and not visible un-selected.
Hope this makes sense, and thanks in advance.