2 Replies Latest reply on Jun 12, 2017 10:04 AM by Sridhar S.

    How to get Drawing Sheet Template Information By Macro?

    Sridhar S.

      Hi,

      I have created a Macro for Solidworks drawing to update the Title Block, For that I have created one User form to select whether it is A-Sheet Template or B-Sheet Template. Instead of this, How can I get Sheet template information by Macro? Thanks in Advance.

       

        • Re: How to get Drawing Sheet Template Information By Macro?
          Deepak Gupta

          You can use swSheet.GetProperties to get the drawing template and set your IF condition based on the return value.

            • Re: How to get Drawing Sheet Template Information By Macro?
              Sridhar S.

              Hi Deepak,

              Thanks for your quick Reply, My codes are Below, In this Where can I add that your code (swSheet.GetProperties)?

              My Sheet Template Name will be Like xxx-A-in, xxx-A-mm,

                                                                    and xxx-B-in, xxx-B-mm.

               

              Option Explicit

                  Global swApp                   As SldWorks.SldWorks

                 Global Part As ModelDoc2

                  Global swDwg As DrawingDoc

                  Global swSht As Sheet

                  Global sThisSheet As String

                  Global sSheetNames As Variant

                  Global iSheets As Integer

                  Global j As Integer

                  Global k As Integer

                  Global boolstatus As Boolean

              Sub main()

               

               

              Set swApp = Application.SldWorks

               

               

                  Set Part = swApp.ActiveDoc

                  Part.CustomInfo("Drawn By") = "xxxxx"

                  Part.CustomInfo("Engineer") = "xxx"

                  Part.CustomInfo("Revision") = "xx"

                  Set swDwg = Part

               

                 Set swSht = swDwg.GetCurrentSheet

                  sThisSheet = swSht.GetName

                 

                  iSheets = swDwg.GetSheetCount

                  sSheetNames = swDwg.GetSheetNames

               

              For k = 1 To iSheets

                      k = k - 1

                  swDwg.ActivateSheet sSheetNames(k)

                   k = k + 1

                 

              Set Part = swApp.ActiveDoc

              Part.ViewZoomtofit2

              boolstatus = Part.Extension.SelectByID2("Sheet" & k, "SHEET", 6.24322292993629E-03, 1.24537656050956E-02, 0, False, 0, Nothing, 0)

              Part.EditTemplate

              Part.EditSketch

              Part.ClearSelection2 True

              boolstatus = Part.Extension.SelectByID2("DetailItem158@Sheet Format" & k, "NOTE", 0.332597233798607, 3.45295355483958E-02, 0, False, 0, Nothing, 0)

              Part.FontFace "Arial"

              Part.FontPoints 8

              Part.ClearSelection2 True

              Part.Extension.StartFormatPainter

              boolstatus = Part.Extension.SelectByID2("DetailItem158@Sheet Format" & k, "NOTE", 0.331886417325251, 3.57142296706566E-02, 0, False, 0, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("DetailItem149@Sheet Format" & k, "NOTE", 0.331965396933402, 3.04225959245582E-02, 0, False, 0, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("DetailItem139@Sheet Format" & k, "NOTE", 0.307876616447431, 2.37883088398975E-02, 0, False, 0, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("DetailItem146@Sheet Format" & k, "NOTE", 0.330227845554086, 0.023946268056199, 0, False, 0, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("DetailItem138@Sheet Format" & k, "NOTE", 0.351511918043344, 2.43505217564103E-02, 0, False, 0, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("DetailItem127@Sheet Format" & k, "NOTE", 0.374929949569057, 2.47841890068865E-02, 0, False, 0, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("DetailItem145@Sheet Format" & k, "NOTE", 0.400674418534784, 0.02450196352825, 0, False, 0, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("DetailItem150@Sheet Format" & k, "NOTE", 0.305108396114115, 1.74789721131497E-02, 0, False, 0, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("DetailItem128@Sheet Format" & k, "NOTE", 0.307241963126297, 1.08115752000798E-02, 0, False, 0, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("DetailItem144@Sheet Format" & k, "NOTE", 0.319865567948376, 1.12560683276178E-02, 0, False, 0, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("DetailItem147@Sheet Format" & k, "NOTE", 0.338800975181495, 0.010544879323557, 0, False, 0, Nothing, 0)

              boolstatus = Part.Extension.SelectByID2("DetailItem148@Sheet Format" & k, "NOTE", 0.338445380679464, 8.4113123113746E-03, 0, False, 0, Nothing, 0)

              Part.EditSheet

              Part.EditSketch

              Part.ClearSelection2 True

              Part.ViewZoomtofit2

              Part.Extension.StopFormatPainter

                  Next k

              Part.ForceRebuild

               

                          End Sub