×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

NX 7.5 Journaling - Moving all Flat Pattern entities in to a layer

NX 7.5 Journaling - Moving all Flat Pattern entities in to a layer

NX 7.5 Journaling - Moving all Flat Pattern entities in to a layer

(OP)
Hi All,
We have a requirement to move all flatpattern objects in to layer 151. This task need to be done for several part files.
I have created below journal to do this task. we need to open each part file and run this journal.

This code find outs all custome views and filters the views with "FLAT-PATTERN". After that it switches to each flat pattern view and moves the visible objects to layer 151. If the part file is not having flat pattern view it gives a message on the scrren.
This journal is moving all curves in to layer but excluding flat pattern annotations(labels).

Can someone help me in improving below code. Thank you in advance.



Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
Sub Main


Dim theSession As Session = Session.GetSession()
Dim theUI As UI = UI.GetUI()

Dim workPart As Part = theSession.Parts.Work
Dim dispPart As Part = theSession.Parts.Display
Dim basepart As part = theSession.Parts.Work



Dim Vwlst As Array

Vwlst = Basepart.Views.GetCustomViews()

Dim b As Integer

b=0

Dim c As Integer

c=Vwlst.Length-1

Dim fviews As Integer

fviews = 0


If Vwlst.Length > 0 Then

For b=0 to c

Dim vn as String

vn=Vwlst(b).ToString()

Dim ff As String

ff=Left(vn,12)

If ff = "FLAT-PATTERN" Then

fviews = fviews+1


Dim layout1 As Layout = CType(workPart.Layouts.FindObject("L1"), Layout)

Dim modelingView1 As ModelingView = CType(workPart.ModelingViews.FindObject(vn), ModelingView)

layout1.ReplaceView(workPart.ModelingViews.WorkView, modelingView1, True)

workPart.ModelingViews.WorkView.Fit()

Dim wv As View
wv = Basepart.views.Workview



Dim ViewObj As Array

ViewObj = wv.AskVisibleObjects()



workPart.Layers.MoveDisplayableObjects(151, ViewObj)





msgBox("Moved all visible objects to layer 151 in view "&vn, ,"Flat Pattern Layer Move")


'lw.writeline("Cusom view name is = " &vn)

end if

Next b

If fviews = 0 then

msgbox("There is no flat pattern view", ,"Flat Pattern Layer Move")

end if

Else

MsgBox("There are no custom views", ,"Flat Pattern Layer Move")

end if




'Dim wv As tag
'wv = Basepart.views.Workview.tag
'lw.writeline(wv.ToString())





End Sub
End Module
























RE: NX 7.5 Journaling - Moving all Flat Pattern entities in to a layer

Try the following code; it iterates through the current work part's features looking for flat pattern features. When one is found it gets the curves and annotations and moves them to layer 151.

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.Work) 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 flat pattern objects"
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

        Const flatPatternLayer As Integer = 151

        Dim flatPatternObjects As New List(Of DisplayableObject)

        For Each tempFeature As Features.Feature In workPart.Features

            If TypeOf (tempFeature) Is Features.FlatPattern Then

                Dim theFlatPattern As Features.FlatPattern = tempFeature

                Dim fpCurves() As NXObject = theFlatPattern.GetCurves
                For Each tempObj As DisplayableObject In fpCurves
                    flatPatternObjects.Add(tempObj)
                Next

                Dim fpAnnotations() As NXObject = theFlatPattern.GetAnnotations
                For Each tempObj As DisplayableObject In fpAnnotations
                    flatPatternObjects.Add(tempObj)
                Next

            End If

        Next

        Dim displayModification1 As DisplayModification
        displayModification1 = theSession.DisplayManager.NewDisplayModification()
        displayModification1.NewLayer = flatPatternLayer

        displayModification1.Apply(flatPatternObjects.ToArray)
        displayModification1.Dispose()

        lw.Close()

    End Sub

End Module 

www.nxjournaling.com

RE: NX 7.5 Journaling - Moving all Flat Pattern entities in to a layer

(OP)
Excellent cowski, This code is working exactly what we need. Thank you very much.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources