Cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop automatic reordering of sheet?

Pioneer
Pioneer

Hello,

 

I have added few sheets to the drawing and changes the name of some sheets.

After that when I add a new sheet to it, it will automatically reorder alpha-numerically. 

 

How to stop that reorder?

 

Or is there anything that needs to be done in Drafting preference. Below is the code.

 

 

Sub AddNew_Sheet()

        theSession = Session.GetSession()
        workPart = theSession.Parts.Work
        displayPart = theSession.Parts.Display

        '---Getting latest NX revsion installed path to use template
        NXPath = Environment.GetEnvironmentVariable("UGII_ROOT_DIR")

        Dim nullDrawings_DrawingSheet As Drawings.DrawingSheet = Nothing


        dwgShtBld = workPart.DrawingSheets.DrawingSheetBuilder(nullDrawings_DrawingSheet)

        dwgShtBld.Option = Drawings.DrawingSheetBuilder.SheetOption.CustomSize
        dwgShtBld.StandardMetricScale = Drawings.DrawingSheetBuilder.SheetStandardMetricScale.S11
        dwgShtBld.StandardEnglishScale = Drawings.DrawingSheetBuilder.SheetStandardEnglishScale.S11
        ' dwgShtBld.MetricSheetTemplateLocation = "C:\eng_apps\NX9\ugii\templates\Drawing-A0-Size2D-template.prt"
        'dwgShtBld.EnglishSheetTemplateLocation = "C:\eng_apps\NX9\ugii\templates\Drawing-A-Size2D-template.prt"

        dwgShtBld.MetricSheetTemplateLocation = NXPath & "templates\Drawing-A0-Size2D-template.prt"
        dwgShtBld.EnglishSheetTemplateLocation = NXPath & "templates\Drawing-A-Size2D-template.prt"
        
            dwgShtBld.Height = 841
            dwgShtBld.Length = 1199
     
      
        dwgShtBld.StandardMetricScale = Drawings.DrawingSheetBuilder.SheetStandardMetricScale.S11
        dwgShtBld.StandardEnglishScale = Drawings.DrawingSheetBuilder.SheetStandardEnglishScale.S11
        dwgShtBld.ScaleNumerator = 1.0
        dwgShtBld.ScaleDenominator = 1.0
        dwgShtBld.Units = Drawings.DrawingSheetBuilder.SheetUnits.Metric


        If Projection_Angles = 0 Then
            dwgShtBld.ProjectionAngle = Drawings.DrawingSheetBuilder.SheetProjectionAngle.First
        ElseIf Projection_Angles = 1 Then
            dwgShtBld.ProjectionAngle = Drawings.DrawingSheetBuilder.SheetProjectionAngle.Third
        End If

        'dwgShtBld.Number = "2"
        dwgShtBld.SecondaryNumber = ""
        dwgShtBld.Revision = "A"
        dwgShtBld.Name = "SHEET" & " " & dwgShtBld.Number
        'dwgShtBld.MetricSheetTemplateLocation = "C:\eng_apps\NX9\ugii\templates\Drawing-A2-Size2D-template.prt"
        dwgShtBld.MetricSheetTemplateLocation = NXPath & "templates\Drawing-A2-Size2D-template.prt"

        Dim nXObject1 As NXObject
        nXObject1 = dwgShtBld.Commit()
        dwgShtBld.Destroy()
        workPart.Drafting.SetTemplateInstantiationIsComplete(True)

    End Sub

 

 

 

2 REPLIES

Re: How to stop automatic reordering of sheet?

Esteemed Contributor
Esteemed Contributor

I think your issue is in this code:

        'dwgShtBld.Number = "2"
        dwgShtBld.SecondaryNumber = ""
        dwgShtBld.Revision = "A"
        dwgShtBld.Name = "SHEET" & " " & dwgShtBld.Number

 

Note the (dwgShtBld.Number = "2") is commented out(?!)

so the name id "SHEET " (???)

Possible fix:

Before creating the "sheet builder", I'd get the current sheet count.

Set the *.Number to (sheet count + 1)

Then the name should come out OK.

Note the display in the PNT may be sorted alphabetically (1, 10, 11, 2, 3, ...) rather than numerically (1, 2,3 ..., 10, 11) unless you add the sheet number column and sort on it.

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: How to stop automatic reordering of sheet?

Pioneer
Pioneer

Hello,

 

I have made changes as you mentioned.

But still sheet order is getting changed. I don't want to stop that reordering.

 

 

  Sub AddNew_Sheet()

        theSession = Session.GetSession()
        workPart = theSession.Parts.Work
        displayPart = theSession.Parts.Display

        Dim sheetcount As Integer
        Dim sheetArray() As Drawings.DrawingSheet
        sheetArray = workPart.DrawingSheets.ToArray


        For i As Integer = 0 To sheetArray.Length - 1
            sheetcount = sheetcount + 1
        Next

        MsgBox(CStr(sheetcount))
        '---Getting latest NX revsion installed path to use template
        NXPath = Environment.GetEnvironmentVariable("UGII_ROOT_DIR")

        Dim nullDrawings_DrawingSheet As Drawings.DrawingSheet = Nothing


        dwgShtBld = workPart.DrawingSheets.DrawingSheetBuilder(nullDrawings_DrawingSheet)

        dwgShtBld.Option = Drawings.DrawingSheetBuilder.SheetOption.CustomSize


        dwgShtBld.MetricSheetTemplateLocation = NXPath & "templates\Drawing-A0-Size2D-template.prt"
        dwgShtBld.EnglishSheetTemplateLocation = NXPath & "templates\Drawing-A-Size2D-template.prt"
  
            dwgShtBld.Height = 841
            dwgShtBld.Length = 1199
     
      
        dwgShtBld.StandardMetricScale = Drawings.DrawingSheetBuilder.SheetStandardMetricScale.S11
        dwgShtBld.StandardEnglishScale = Drawings.DrawingSheetBuilder.SheetStandardEnglishScale.S11
        dwgShtBld.ScaleNumerator = 1.0
        dwgShtBld.ScaleDenominator = 1.0
        dwgShtBld.Units = Drawings.DrawingSheetBuilder.SheetUnits.Metric


        If Projection_Angles = 0 Then
            dwgShtBld.ProjectionAngle = Drawings.DrawingSheetBuilder.SheetProjectionAngle.First
        ElseIf Projection_Angles = 1 Then
            dwgShtBld.ProjectionAngle = Drawings.DrawingSheetBuilder.SheetProjectionAngle.Third
        End If

        dwgShtBld.Number = sheetcount + 1
        dwgShtBld.SecondaryNumber = ""
        dwgShtBld.Revision = "A"
        dwgShtBld.Name = "SHEET" & " " & sheetcount + 1
        dwgShtBld.MetricSheetTemplateLocation = NXPath & "templates\Drawing-A2-Size2D-template.prt"

        Dim nXObject1 As NXObject
        nXObject1 = dwgShtBld.Commit()
        dwgShtBld.Destroy()
        workPart.Drafting.SetTemplateInstantiationIsComplete(True)

    End Sub