Forums:
Hello all,
i have recorded a journal in NX where i move all my views, notes and dimension from sheet x to sheet y. This is because of a new titleblock.
in the past the pattern was used for this but the new templates are using the new titleblock function of NX.
What is the fastest way to change this.
My recorded script is always looking to the specified view names. How can i make this variable?
Kind regards
Ruud
' NX 10.0.3.5 ' Journal created by Ruud on Mon May 30 13:37:49 2016 W. Europe Daylight Time ' Option Strict Off Imports System Imports NXOpen Module NXJournal Sub Main (ByVal args() As String) Dim theSession As NXOpen.Session = NXOpen.Session.GetSession() Dim workPart As NXOpen.Part = theSession.Parts.Work Dim displayPart As NXOpen.Part = theSession.Parts.Display ' ---------------------------------------------- ' Menu: Format->Layer Settings... ' ---------------------------------------------- Dim markId1 As NXOpen.Session.UndoMarkId markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start") theSession.SetUndoMarkName(markId1, "Layer Settings Dialog") Dim stateArray1(0) As NXOpen.Layer.StateInfo stateArray1(0) = New NXOpen.Layer.StateInfo(256, NXOpen.Layer.State.Selectable) workPart.Layers.ChangeStates(stateArray1, False) Dim stateArray2(0) As NXOpen.Layer.StateInfo stateArray2(0) = New NXOpen.Layer.StateInfo(256, NXOpen.Layer.State.Hidden) workPart.Layers.ChangeStates(stateArray2, False) theSession.SetUndoMarkName(markId1, "Layer Settings") theSession.DeleteUndoMark(markId1, Nothing) ' ---------------------------------------------- ' Menu: Edit->Selection->Select All ' ---------------------------------------------- ' Refer to the sample NXOpen application, Selection for "Select All" alternatives. ' ---------------------------------------------- ' Menu: Edit->Cut ' ---------------------------------------------- workPart.PmiManager.RestoreUnpastedObjects() Dim markId2 As NXOpen.Session.UndoMarkId markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Drafting Cut") Dim nErrs1 As Integer nErrs1 = theSession.UpdateManager.DoUpdate(markId2) Dim markId3 As NXOpen.Session.UndoMarkId markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start") Dim nullNXOpen_Drawings_DrawingSheet As NXOpen.Drawings.DrawingSheet = Nothing Dim drawingSheetBuilder1 As NXOpen.Drawings.DrawingSheetBuilder drawingSheetBuilder1 = workPart.DrawingSheets.DrawingSheetBuilder(nullNXOpen_Drawings_DrawingSheet) drawingSheetBuilder1.AutoStartViewCreation = True drawingSheetBuilder1.StandardMetricScale = NXOpen.Drawings.DrawingSheetBuilder.SheetStandardMetricScale.S11 drawingSheetBuilder1.StandardEnglishScale = NXOpen.Drawings.DrawingSheetBuilder.SheetStandardEnglishScale.S11 drawingSheetBuilder1.AutoStartViewCreation = False drawingSheetBuilder1.MetricSheetTemplateLocation = "C:\PLM\NX\NX100\UGII\templates\Drawing-A0-Size2D-template.prt" drawingSheetBuilder1.EnglishSheetTemplateLocation = "C:\PLM\NX\NX100\UGII\templates\Drawing-A-Size2D-template.prt" drawingSheetBuilder1.Height = 841.0 drawingSheetBuilder1.Length = 1189.0 drawingSheetBuilder1.StandardMetricScale = NXOpen.Drawings.DrawingSheetBuilder.SheetStandardMetricScale.S11 drawingSheetBuilder1.StandardEnglishScale = NXOpen.Drawings.DrawingSheetBuilder.SheetStandardEnglishScale.S11 drawingSheetBuilder1.ScaleNumerator = 1.0 drawingSheetBuilder1.ScaleDenominator = 1.0 drawingSheetBuilder1.Units = NXOpen.Drawings.DrawingSheetBuilder.SheetUnits.Metric drawingSheetBuilder1.ProjectionAngle = NXOpen.Drawings.DrawingSheetBuilder.SheetProjectionAngle.Third drawingSheetBuilder1.Number = "2" drawingSheetBuilder1.SecondaryNumber = "" drawingSheetBuilder1.Revision = "A" theSession.SetUndoMarkName(markId3, "Sheet Dialog") drawingSheetBuilder1.MetricSheetTemplateLocation = "C:\PLM\NX\NX100\UGII\templates\Drawing-A0-Size2D-template.prt" drawingSheetBuilder1.MetricSheetTemplateLocation = "C:\PLM\NX\NX100\UGII\templates\Drawing-A2-Size2D-template.prt" drawingSheetBuilder1.MetricSheetTemplateLocation = "C:\PLM\NX\NX100\UGII\templates\Drawing-A0-Size2D-template.prt" Dim markId4 As NXOpen.Session.UndoMarkId markId4 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Sheet") theSession.DeleteUndoMark(markId4, Nothing) Dim markId5 As NXOpen.Session.UndoMarkId markId5 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Sheet") Dim nXObject1 As NXOpen.NXObject nXObject1 = drawingSheetBuilder1.Commit() theSession.DeleteUndoMark(markId5, Nothing) theSession.SetUndoMarkName(markId3, "Sheet") drawingSheetBuilder1.Destroy() workPart.Drafting.SetTemplateInstantiationIsComplete(True) ' ---------------------------------------------- ' Menu: Edit->Paste ' ---------------------------------------------- Dim markId6 As NXOpen.Session.UndoMarkId markId6 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Paste View(s)") Dim baseView1 As NXOpen.Drawings.BaseView = CType(workPart.DraftingViews.FindObject("Front@1"), NXOpen.Drawings.BaseView) baseView1.RestoreViewBorder() Dim detailView1 As NXOpen.Drawings.DetailView = CType(workPart.DraftingViews.FindObject("DETAIL@7"), NXOpen.Drawings.DetailView) detailView1.RestoreViewBorder() Dim detailView2 As NXOpen.Drawings.DetailView = CType(workPart.DraftingViews.FindObject("DETAIL@8"), NXOpen.Drawings.DetailView) detailView2.RestoreViewBorder() Dim detailView3 As NXOpen.Drawings.DetailView = CType(workPart.DraftingViews.FindObject("DETAIL@9"), NXOpen.Drawings.DetailView) detailView3.RestoreViewBorder() Dim baseView2 As NXOpen.Drawings.BaseView = CType(workPart.DraftingViews.FindObject("Left@4"), NXOpen.Drawings.BaseView) baseView2.RestoreViewBorder() Dim baseView3 As NXOpen.Drawings.BaseView = CType(workPart.DraftingViews.FindObject("Bottom@2"), NXOpen.Drawings.BaseView) baseView3.RestoreViewBorder() Dim baseView4 As NXOpen.Drawings.BaseView = CType(workPart.DraftingViews.FindObject("Right@3"), NXOpen.Drawings.BaseView) baseView4.RestoreViewBorder() Dim detailView4 As NXOpen.Drawings.DetailView = CType(workPart.DraftingViews.FindObject("DETAIL@6"), NXOpen.Drawings.DetailView) detailView4.RestoreViewBorder() Dim views1(7) As NXOpen.Drawings.DraftingView views1(0) = baseView1 views1(1) = detailView1 views1(2) = detailView2 views1(3) = detailView3 views1(4) = baseView2 views1(5) = baseView3 views1(6) = baseView4 views1(7) = detailView4 Dim drawingSheet1 As NXOpen.Drawings.DrawingSheet = CType(nXObject1, NXOpen.Drawings.DrawingSheet) workPart.DraftingViews.MoveViewsToDrawing(views1, drawingSheet1) Dim id1 As NXOpen.Session.UndoMarkId id1 = theSession.NewestVisibleUndoMark Dim nErrs2 As Integer nErrs2 = theSession.UpdateManager.DoUpdate(id1) ' ---------------------------------------------- ' Menu: Edit->Delete... ' ---------------------------------------------- Dim markId7 As NXOpen.Session.UndoMarkId markId7 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Delete") Dim notifyOnDelete1 As Boolean notifyOnDelete1 = theSession.Preferences.Modeling.NotifyOnDelete theSession.UpdateManager.ClearErrorList() Dim markId8 As NXOpen.Session.UndoMarkId markId8 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Delete") Dim objects1(0) As NXOpen.NXObject Dim view1 As NXOpen.View = CType(workPart.Views.FindObject("Sheet 1@0"), NXOpen.View) objects1(0) = view1 Dim nErrs3 As Integer nErrs3 = theSession.UpdateManager.AddToDeleteList(objects1) Dim notifyOnDelete2 As Boolean notifyOnDelete2 = theSession.Preferences.Modeling.NotifyOnDelete Dim nErrs4 As Integer nErrs4 = theSession.UpdateManager.DoUpdate(markId8) theSession.DeleteUndoMark(markId7, Nothing) ' ---------------------------------------------- ' Menu: Format->Layer Settings... ' ---------------------------------------------- Dim markId9 As NXOpen.Session.UndoMarkId markId9 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start") theSession.SetUndoMarkName(markId9, "Layer Settings Dialog") Dim stateArray3(0) As NXOpen.Layer.StateInfo stateArray3(0) = New NXOpen.Layer.StateInfo(256, NXOpen.Layer.State.Selectable) workPart.Layers.ChangeStates(stateArray3, False) Dim stateArray4(0) As NXOpen.Layer.StateInfo stateArray4(0) = New NXOpen.Layer.StateInfo(256, NXOpen.Layer.State.Visible) workPart.Layers.ChangeStates(stateArray4, False) theSession.SetUndoMarkName(markId9, "Layer Settings") theSession.DeleteUndoMark(markId9, Nothing) ' ---------------------------------------------- ' Menu: Tools->Journal->Stop Recording ' ---------------------------------------------- End Sub End Module <code>