6 Replies Latest reply on Nov 2, 2018 3:13 AM by Amen Allah Jlili

    Macro to reset property tab

    Nicolò Bernareggi

      Hi evrybody,

       

      i'm looking for a way to create a macro (or any other system) that reset alla the field of the property tab that i've create to fill the field of my personalized titole block.

       

      i hope you would understand my request! my english is so bad!

      Thanks in advance!

        • Re: Macro to reset property tab
          Fifi Riri

          This macro will delete all Custom properties including the ones created by property tab. Modify it as needed.

           

          Option Explicit

          Dim swApp As SldWorks.SldWorks

          Dim swModel As SldWorks.ModelDoc2

          Sub main()

              Set swApp = Application.SldWorks

              Set swModel = swApp.ActiveDoc

              Dim vConf As Variant

              Dim i As Integer

              ClearCustPrps ""

              For Each vConf In swModel.GetConfigurationNames

                  ClearCustPrps CStr(vConf)

              Next

          End Sub

           

          Sub ClearCustPrps(conf As String)

              Dim swCustPropMgr As SldWorks.CustomPropertyManager

              Dim vPropNames As Variant

              Dim vPropName As Variant

              Set swCustPropMgr = swModel.Extension.CustomPropertyManager(conf)

              If Not swCustPropMgr Is Nothing Then

                  swCustPropMgr.GetAll vPropNames, Empty, Empty

                  If Not IsEmpty(vPropNames) Then

                      For Each vPropName In vPropNames

                          swCustPropMgr.Delete vPropName

                      Next

                  End If

              End If

          End Sub

            • Re: Macro to reset property tab
              Nicolò Bernareggi

              thank you! but if i paste the code inside a new macro nothing happend!!!

               

              where i'm wrong??

                • Re: Macro to reset property tab
                  Fifi Riri

                  The model needs to be rebuild.

                  I modified the above macro with a rebuild function:

                   

                  Option Explicit

                  Dim swApp As SldWorks.SldWorks

                  Dim swModel As SldWorks.ModelDoc2

                  Sub main()

                      Set swApp = Application.SldWorks

                      Set swModel = swApp.ActiveDoc

                      Dim vConf As Variant

                      Dim i As Integer

                      ClearCustPrps ""

                      For Each vConf In swModel.GetConfigurationNames

                          ClearCustPrps CStr(vConf)

                      Next

                      swModel.EditRebuild3

                  End Sub

                   

                  Sub ClearCustPrps(conf As String)

                      Dim swCustPropMgr As SldWorks.CustomPropertyManager

                      Dim vPropNames As Variant

                      Dim vPropName As Variant

                      Set swCustPropMgr = swModel.Extension.CustomPropertyManager(conf)

                      If Not swCustPropMgr Is Nothing Then

                          swCustPropMgr.GetAll vPropNames, Empty, Empty

                          If Not IsEmpty(vPropNames) Then

                              For Each vPropName In vPropNames

                                  swCustPropMgr.Delete vPropName

                              Next

                          End If

                      End If

                  End Sub

              • Re: Macro to reset property tab
                Mithilesh Kapre

                Looks like you want to empty all fields in the Custom Property Pane (under task pane) as below.

                I don't see a way to do that

                • Re: Macro to reset property tab
                  Amen Allah Jlili

                  This is possible but definitely is not worth the investment (Through Windows API). The only thing you can set from the API that is Property Tab Builder related is the template according to my knowledge.