Insert New Drawing sheet in middle of the drawing sheets and re-arrange the sheet sequence number

Hi,

I am new to NX open. Can someone help me to achieve my following requirement. I want to insert new drawing sheet in between the drawing sheets in NX drafting mode and also all the sheet sequence number will update automatically. For example we have 10 drawing sheets, I want to insert sheet at No: 5 position. Once add the new sheet all the drawing numbers sequence should be change. Can someone help me.

Thanks

The drawing sheets have a "number" property (this can be viewed/edited in the "edit sheet" dialog). If your drawing currently has 10 sheets, you can add a new sheet with the number set to "5" and all the existing sheets numbers will renumber correctly.

By default, NX will name the sheets "Sheet N", where N is a sequential number based on the other existing sheet names. If you are using the default sheet names and want them to reflect the actual assigned number, you will need to rename all the affected sheets after inserting your new sheet.

Here's some example code. If you run it as-is, it will create a new B size sheet at sheet number 3 (I'd recommend creating a test file that has 5 or more drawing sheets before running the code).

Imports System
Imports NXOpen

Module Module194
Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
Dim lw As ListingWindow = theSession.ListingWindow

Sub Main(ByVal args() As String)

Dim workPart As NXOpen.Part = theSession.Parts.Work
Dim displayPart As NXOpen.Part = theSession.Parts.Display
lw.Open()

Dim markId1 As NXOpen.Session.UndoMarkId = Nothing
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Add Sheet")

Dim newSheet As Drawings.DrawingSheet = Nothing
newSheet = AddSheet("3")

'clear sheet names
Dim j As Integer = 1
For Each temp As Drawings.DrawingSheet In theSession.Parts.Work.DrawingSheets
temp.SetName("temp " & j.ToString)
j += 1
Next

'name sheets based on sheet number
For Each tempSheet As Drawings.DrawingSheet In theSession.Parts.Work.DrawingSheets

Dim sheetNum As String = ""
Dim draftingDrawingSheetBuilder1 As NXOpen.Drawings.DraftingDrawingSheetBuilder = Nothing
draftingDrawingSheetBuilder1 = workPart.DraftingDrawingSheets.CreateDraftingDrawingSheetBuilder(tempSheet)
sheetNum = draftingDrawingSheetBuilder1.Number

draftingDrawingSheetBuilder1.Destroy()

tempSheet.SetName("Sheet " & sheetNum)

Next

lw.Close()
End Sub

Function AddSheet(ByVal sheetNum As String) As Drawings.DrawingSheet

Dim nullNXOpen_Drawings_DraftingDrawingSheet As NXOpen.Drawings.DraftingDrawingSheet = Nothing

Dim draftingDrawingSheetBuilder1 As NXOpen.Drawings.DraftingDrawingSheetBuilder = Nothing
draftingDrawingSheetBuilder1 = theSession.Parts.Work.DraftingDrawingSheets.CreateDraftingDrawingSheetBuilder(nullNXOpen_Drawings_DraftingDrawingSheet)

draftingDrawingSheetBuilder1.Option = NXOpen.Drawings.DrawingSheetBuilder.SheetOption.StandardSize
draftingDrawingSheetBuilder1.Height = 11.0
draftingDrawingSheetBuilder1.Length = 17.0
draftingDrawingSheetBuilder1.StandardEnglishScale = NXOpen.Drawings.DrawingSheetBuilder.SheetStandardEnglishScale.S11
draftingDrawingSheetBuilder1.ScaleNumerator = 1.0
draftingDrawingSheetBuilder1.ScaleDenominator = 1.0
draftingDrawingSheetBuilder1.Units = NXOpen.Drawings.DrawingSheetBuilder.SheetUnits.English
draftingDrawingSheetBuilder1.ProjectionAngle = NXOpen.Drawings.DrawingSheetBuilder.SheetProjectionAngle.Third
draftingDrawingSheetBuilder1.Number = sheetNum
draftingDrawingSheetBuilder1.SecondaryNumber = ""
draftingDrawingSheetBuilder1.Revision = "A"

Dim markId3 As NXOpen.Session.UndoMarkId = Nothing
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Sheet")

Dim nXObject1 As Drawings.DrawingSheet = Nothing
nXObject1 = draftingDrawingSheetBuilder1.Commit()

theSession.DeleteUndoMark(markId3, Nothing)

draftingDrawingSheetBuilder1.Destroy()

theSession.Parts.Work.Drafting.SetTemplateInstantiationIsComplete(True)

Return nXObject1

End Function

End Module

When I run the above code I can able to create the new sheet. But the new sheet creating with custum size template. I want to insert/add sheet with current/working sheet Properties. Could you please help me how can I insert new sheet with existing sheet template.

Switch to the drafting application, start the journal recorder, insert your desired sheet type and stop the recorder. Compare the code returned to the code in the "AddSheet" function and update the code accordingly to get what you want.

By the way, Can U show me how to delete unnecessary sheet.
Thanks!

NX OPEN

If you record a journal and delete one of the drawing sheets, the returned code will show you the necessary commands.

I really don't understand what you mean.
Can you explain more clearly?
Tks!

NX OPEN

Create an extra, unnecessary sheet in your drawing. Start the journal recorder, right click on the sheet and choose "delete". Stop the journal recorder. In the journal file created, there will be code to delete that specific sheet. Investigate which commands were used to delete the sheet and apply them to your code.

Thanks. i got it.
the received code is vb.
because Im learning python, im going to try to convert it to python

NX OPEN