Issues with moving an object to a layer

I am having a really hard time getting a body to move to layer 255. I create a new component within an assembly, and mirror a body within the new component. Then I attempt to move the original body to layer 255 and it will not work.

If my assembly is more than 2 levels deep, then I can make the component's parent my display part, and it appears correctly. While I do these operations, I have the highest component available in the assembly my display part. Does anyone have any ideas why this might happen?

I attempted to grab/clean up some of the code snippets I've tried to accomplish this, they are below.


Dim objs As DisplayableObject = CType(bod, DisplayableObject)
objs.Layer = 255
objs.RedisplayObject()


displayPart.Layers.ApplyMoveToLayerToOwningParts(255, arrBodies)


Dim objs() As NXObject
Dim lay As Integer
Dim prt As Part = CType(obj.OwningPart, Part)
Dim objs() As DisplayableObject = {CType(obj, DisplayableObject)}
prt.Layers.MoveDisplayableObjects(lay, objs)

There are different layer options that can be used when adding a component to an assembly. The "specified layer" option will force all of the component's objects to the specified layer; the "original" option will keep the component's objects on the same layer as in the component part file. If the component was added with the "specified layer" option, it may be limiting your options when moving layers.

If the "original" layer option was used, you may need to synchronize the subassembly properties. In interactive NX, this can be accomplished by right clicking on the subassembly in the ANT -> properties -> assembly -> click the "layers" button in the "synchronize subassembly properties" section. This will synchronize the layer changes to update the current assembly.

I do add the component on the original layer. I attempted the Synchronize Layers manually for each parent of the added component. There didn't seem to be any affect on the layers for the body.

DHuskic
Nx 9 VB

Are you sure that you have a reference to the prototype body and not an occurrence body?

Hi developer,

My current code will work on bodies only and I can do the same thing for datums or any object.I am wondering if it is possible to use on bloack to all hidden object or features.

Option Strict Off
Imports System
Imports NXOpen
Imports System.Windows.Forms

Module TEST
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim objArray(0) As DisplayableObject

Sub Main()
System.Diagnostics.Debugger.Launch()
Dim LH As Integer = 7
If theSession.Parts.Work Is Nothing Then
MessageBox.Show("No Part Loaded!")
Return
End If

For Each obj As DisplayableObject In workPart.Bodies
If obj.IsBlanked = True Then
objArray(0) = obj
workPart.Layers.MoveDisplayableObjects(LH, objArray)
End If
Next
End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function

End Module

The example below doesn’t work and the reason I want any hidden object or feature to be on certain layer is to avoid list all types of object or features.

Option Strict Off
Imports System
Imports NXOpen
Imports System.Collections.Generic
Imports System.Windows.Forms

Module TEST
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim objArray(0) As DisplayableObject

Sub Main()
System.Diagnostics.Debugger.Launch()
Dim LH As Integer = 7
If theSession.Parts.Work Is Nothing Then
MessageBox.Show("No Part Loaded!")
Return
End If

For Each obj As DisplayableObject In New List(Of DisplayableObject)
If obj.IsBlanked = True Then
objArray(0) = obj
workPart.Layers.MoveDisplayableObjects(LH, objArray)
End If
Next

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function

End Module

Raeed Kena
{Mechanical / Civil Engineer}