Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Move one feture to especific layer

Status
Not open for further replies.

reem13

Mechanical
Feb 10, 2016
7
Hi I am new in this assignment and I need your help in one journal I don´t know how to send a feature tube to one leyer specific, this tube is the representation of weld in my assembly.

Can someone help me please.
 
Replies continue below

Recommended for you

Do you have a reference to the tube feature? If so, you can get the resulting body from the {feature}.GetBodies method. Once you have a reference to the body object (features cannot be moved to layers, only displayable objects can) you can move it to a different layer.

If you need an example of how to change an object's layer, the journal recorder is good for that.

www.nxjournaling.com
 
The following journal (NX 9) will look for tube features in the work part and move the tube bodies to layer 3. Modify all or part of it to suit your needs.

Code:
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


www.nxjournaling.com
 
Cowski you are the best, the journal is incredible, thanks for all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor