Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations Ron247 on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Journal to move components visible to the user to layer 1

Status
Not open for further replies.

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.

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.
 
Replies continue below

Recommended for you

There are functions called IdentifyExteriorUsingHl and IdentifyExteriorUsingRays that might be handy for your situation.

www.nxjournaling.com
 
Thanks Cowski, I found some information on 'IdentifyExteriorUsingHl' which has mostly worked for what I'm doing. Ill play around with it and see what I get.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor