3 Replies Latest reply on Jul 16, 2015 5:25 AM by Deepak Gupta

    How to reload sheet format?

    Yong Ning

      Reload. If you make changes to the Sheet Format, click to return to the default format.

      0.jpg

       

       

      Sheet Format/Size

      Standard sheet size. Select a standard sheet size, or click Browse and locate a custom sheet format file.

      Reload. If you make changes to the Sheet Format, click to return to the default format.

      Display sheet format. Display border, title block, and so on.

       

      **********************************

       

      Why use SetTemplateName or SetupSheet4 don't reload the Sheet Format?

       

                     tmpPlateName = oRng

                     SwSheet.SetTemplateName tmpPlateName

                     SwDraw.SetupSheet4 SwSheet.GetName, 12, 12, 1, oScale, True, tmpPlateName, 0.42, 0.297, "Default" ', True

       

      *****************************************

      Private Sub del()

         Dim Xls As Excel.Application, Rng As Range

             Set Xls = GetObject(, "Excel.Application")

             Set Rng = Xls.Selection

         Dim PathName

             PathName = Xls.ActiveWorkbook.Path & "\" & Rng

             Stop

         Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

             Set SwApp = Application.SldWorks

             Set SwModel = SwApp.ActiveDoc

         Dim SwSheet As Sheet

              Set swDraw = SwModel

              Set SwSheet = swDraw.GetCurrentSheet

              vSheetProps = SwSheet.GetProperties

              SwModel.SetupSheet5 SwSheet.GetName, swDwgPapersUserDefined, swDwgTemplateCustom, _

                     vSheetProps(2), vSheetProps(3), False, PathName, 0.42, 0.297, "Default", True

              swDraw.ForceRebuild3 False

      End Sub

          • Re: How to reload sheet format?
            Yong Ning

            key code?

             

            Reload Sheet Format | SOLIDWORKS Forums

            https://forum.solidworks.com/message/477234#477234

             

             

             

             

            Sub TraverseEditTemplate0716()

             

               Dim PDFApp As New AcroApp, PDF1 As New AcroPDDoc, PDF2 As New AcroPDDoc

               Dim E As Long, W As Long, PDFFile

               ''

               Debug.Print Time

               Dim FinishTime, Txt, T: T = Timer

                  Txt = Time

               ''

               Dim Xls As Excel.Application, Rng As Range

                  Set Xls = GetObject(, "Excel.Application")

                  Set Rng = Xls.Selection

                

               Dim AsmFile, oArr, MergePDF

                  AsmFile = Rng(0, 1)

                  FinishTime = Rng(0, 2)

                  MergePDF = Rng(0, 3)

               Dim oRng As Range, PDFRng As Range

               Dim R1 As Range, R2 As Range, R3 As Range, R4 As Range

               Dim R5 As Range, R6 As Range, R7 As Range

                  Set R1 = Xls.Range(Rng(1, 1))

                  Set R2 = Xls.Range(Rng(2, 1))

                  Set R3 = Xls.Range(Rng(3, 1))

                  Set R4 = Xls.Range(Rng(4, 1))

                  Set R5 = Xls.Range(Rng(5, 1))

                  ''

               Dim RegExp As New RegExp, oRegExp As New RegExp, Str

                

                  For ii = 1 To R4.Rows.Count

                     If R4(ii, 1) <> "" Then

                       Str = Str & R4(ii, 1) & "|"

                     End If

                  Next ii

                  RegExp.Pattern = Left(Str, Len(Str) - 1)

                  ''

                  For ii = 1 To R5.Rows.Count

                     If R5(ii, 1) <> "" Then

                       Str = Str & R5(ii, 1) & "|"

                     End If

                  Next ii

                  oRegExp.Pattern = Left(Str, Len(Str) - 1)

                  Debug.Print oRegExp.Pattern

                

                

                  ''

                  'Set R6 = Xls.Range(Rng(6, 1))

                  Set R7 = Xls.Range(Rng(7, 1))

                

                  ''

               Dim xyRng As Range

                  ''

               Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2, SwDraw As DrawingDoc

                  Set SwApp = Application.SldWorks

                  SwApp.SetUserPreferenceToggle swUserPreferenceToggle_e.swSketchInference, False

                  ''

               Dim SwLayerMgr As LayerMgr, tmpPlateName

                

               Dim Xx1, Yy1, Xx2, Yy2, Xx3, Yy3, Xx4, Yy4

               Dim vSheet, SwSheet As Sheet, ConfName, View1, X1, Y1, View2, X2, Y2, oScale As Double

               Dim SwView As View

               For kk = R1.Rows.Count To 1 Step -1

                  Set SwModel = SwOpenFile(SwApp, R1(kk, 1))

                  Set SwLayerMgr = SwModel.GetLayerManager

                  Set xyRng = R7(kk, 1).Resize(1, R7.Columns.Count)

                  'Debug.Print kk, SwModel.GetTitle,

                  Set SwDraw = SwModel

                  With SwDraw

                     vSheet = .GetSheetNames

                     For jj = UBound(vSheet) To 0 Step -1

                        If R2(kk, jj + 1) <> "-" Then

                           'Debug.Print R2(kk, jj + 1), R2(kk, jj + 1).Address

                         

                           Set oRng = Xls.Range(R2(kk, jj + 1))

                         

                           'Debug.Print oRng.Address, oRng.Parent.Name

            '              Debug.Print oRng.Areas(7).Address, oRng.Areas(7)

                           oScale = oRng.Areas(7)

                           .ActivateSheet vSheet(jj)

                         

                           Set SwView = SwDraw.GetFirstView

                              Do While Not SwView Is Nothing

                              If jj = 0 Then

                                 RegExpDelDim SwModel, SwView, RegExp

                              Else

                                 RegExpDelDim SwModel, SwView, oRegExp

                              End If

                              Set SwView = SwView.GetNextView

                           Loop

                         

                           Set SwSheet = .GetCurrentSheet

                           'SwSheet.SetScale 1, oScale, False, False

                           If jj <= 3 Then

                              Set oRng = R3(1, jj + 1)

                           Else

                              Str = "Rib" & Split(SwSheet.GetName, "筋板")(1)

                              Set oRng = R3.Find(What:=Str, LookIn:=xlValues)

                           End If

                           tmpPlateName = "E:\Drawing\SldDrt\t.slddrt"

                           SwDraw.SetupSheet4 SwSheet.GetName, 12, 12, 1, 1, True, tmpPlateName, 0.42, 0.297, "" ', True

                           SwModel.ViewZoomtofit

                           SwModel.ForceRebuild3 False

                           'Stop

                           tmpPlateName = oRng

                           'SwSheet.SetTemplateName tmpPlateName

                           'Debug.Print SwSheet.GetName, tmpPlateName

                         

                           SwDraw.SetupSheet4 SwSheet.GetName, 12, 12, 1, oScale, True, tmpPlateName, 0.42, 0.297, "Default" ', True

                           SwModel.EditSketch

                           SwModel.ForceRebuild3 False

                           'Stop

                           EditTemplateCreateLine SwDraw, xyRng, SwLayerMgr

                           SwModel.ForceRebuild3 True

                           ''

                        End If

                        ''

                     Next jj

                  End With

                  'Stop

                  SwModel.Save

                  Debug.Print SwModel.GetTitle,

                  SwApp.CloseDoc SwModel.GetTitle

                

                  PrintTiming T

               Next kk

                

            End Sub

             

             

            *************************************************

             

            Private Sub ll()

               Dim Xls As Excel.Application, Rng As Range

                  Set Xls = GetObject(, "Excel.Application")

                  Set Rng = Xls.Selection

               Dim TemplateName

                  TemplateName = Rng

               Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                  Set SwApp = Application.SldWorks

                  Set SwModel = SwApp.ActiveDoc

               Dim SwDraw As DrawingDoc

                  Set SwDraw = SwModel

               Dim vSheet, SwSheet As Sheet, Pp

                 vSheet = SwDraw.GetSheetNames

                

                 For ii = UBound(vSheet) To 0 Step -1

                     SwDraw.ActivateSheet vSheet(ii)

                     Set SwSheet = SwDraw.GetCurrentSheet

                     Pp = SwSheet.GetProperties

                     Debug.Print SwSheet.GetName

                     'SwDraw.SetupSheet SwSheet.GetName, swDwgPaperBsize, TemplateName, Pp(2), Pp(3)

                    

                     SwDraw.SetupSheet4 SwSheet.GetName, 12, 12, Pp(2), Pp(3), True, TemplateName, 0.42, 0.297, "" ', True

                     SwDraw.EditSheet

                     SwModel.ForceRebuild3 True

                 Next ii

            End Sub