1 Reply Latest reply on Dec 20, 2017 9:51 AM by Deepak Gupta

    Check if a custom property is empty

    Frédérik Drouin

      I want to do a macro that will save as a 3D model with a different name but only only if some custom properties with a specific name are not empty. I'm a beginner with SolidWorks's macro, I know how to save as my part with a different name, but i don't know how to check if a custom property is empty or not. Can someone help me with that ?

       

      Thanks

        • Re: Check if a custom property is empty
          Deepak Gupta

          You can use Get5 to get the value and check if the value is empty or not.

           

          Option Explicit
          Dim swApp As SldWorks.SldWorks
          Dim swModel As ModelDoc2
          Dim swCustProp As CustomPropertyManager
          Dim ValOut As String
          Dim ResolvedValOut As String
          Dim wasResolved As Boolean
          Dim resolved As Variant
          
          Sub main()
          Set swApp = Application.SldWorks
          Set swModel = swApp.ActiveDoc
          Set swCustProp = swModel.Extension.CustomPropertyManager("")
          swCustProp.Get5  "Property Name Here", False, ValOut, ResolvedValOut, wasResolved
          If ResolvedValOut <> "" Then msgbox "Property value exists"
          End Sub