3 Replies Latest reply on Apr 23, 2013 1:46 PM by Hossein Sadeghi

    Find which view is bringing custom property values

    Hossein Sadeghi

      Hi all,

       

      I am trying to write a macro that replace the template of our drawings. No need to mention that this is my first macro and I am struggling with every line of it. Anyways, I have seen a couple of good macro online which I am modifying to create our own. One particular problem I have is that most of the macros use the "Default" as one of the inputs for SetupSheet5 function and for some wierd reason most of our drawings use different views to get the custom properties and they are tied to different configurations of a part. Is there any command that I can use to get the value for this input for the following function?

       

      Document.SetupSheet5(ShtNam(i), Retval(0), Retval(1), Retval(2), Retval(3), Retval(4), NewTemp, Retval(5), Retval(6),"Default" , True)

       

       

      Thanks

      Hossein

      Custom Property Value.PNG

        • Re: Find which view is bringing custom property values
          Hossein Sadeghi

          I think I figured out what command I should be using! CustomPropertyView!

            • Re: Find which view is bringing custom property values
              Aris Lin

              Dim SwApp As SldWorks
              Dim ModDoc2 As ModelDoc2
              Dim swDraw As DrawingDoc
              Dim swView As View
              Dim swSheet As Sheet
              Dim vSheetProps As Object

               

              SwApp = iSwApp
              ModDoc2 = SwApp.ActiveDoc

              vSheetName = swDraw.GetSheetNames
              .
              .
              .
              swSheet = swDraw.GetCurrentSheet
              vSheetProps = swSheet.GetProperties
              swDraw.SetupSheet5(swSheet.GetName, vSheetProps(0), swDwgTemplates_e.swDwgTemplateNone, vSheetProps(2), vSheetProps(3), vSheetProps(4), swSheet.GetTemplateName, vSheetProps(5), vSheetProps(6), "default", True)
              .
              .
              .

                • Re: Find which view is bringing custom property values
                  Hossein Sadeghi

                  Thanks Aris,

                  But your code has the same problem I mentioned earlier. It uses the custom property from 'Default". As I said I have already solved the problem. Below you can see my code.

                   

                  Dim swApp           As Object

                  Dim Document        As Object

                  Dim myModelView     As Object

                   

                  Set swApp = Application.SldWorks
                  Set Document = swApp.ActiveDoc
                  Set myModelView = Document.ActiveView

                  ShtNam = Document.GetSheetNames()
                  Set Sheet = Document.GetCurrentSheet()

                  Retval = Sheet.GetProperties()

                  Set Sheet = Document.GetCurrentSheet()
                  propertyViewName = Sheet.CustomPropertyView

                  Document.SetupSheet5(ShtNam, Retval(0), Retval(1), Retval(2), Retval(3), _
                                          Retval(4), NewTemp, Retval(5), Retval(6), propertyViewName, True)