RAMNX
Mechanical
- Dec 29, 2011
- 28
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
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