Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Module Module1
Sub Main()
Dim theSession As Session = Session.GetSession()
If IsNothing(theSession.Parts.BaseWork) Then
'active part required
Return
End If
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
Const undoMarkName As String = "move tube bodies to layer"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)
Dim tubeBodies As New List(Of Body)
For Each temp As Features.Feature In workPart.Features
If TypeOf (temp) Is Features.Tube Then
Dim tempTube As Features.Tube = temp
tubeBodies.Add(tempTube.GetBodies(0))
End If
Next
Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()
displayModification1.NewLayer = 3
displayModification1.Apply(tubeBodies.ToArray)
displayModification1.Dispose()
lw.Close()
End Sub
End Module