AnsweredAssumed Answered

Combine Macro to works on both assembly and part to set Custom property

Question asked by Niels Eskelund on Mar 14, 2019
Latest reply on Sep 6, 2019 by Niels Eskelund

Hi There

I have 2 macro's to set Custom properties, and i am trying to combine them so that i have only one macro

The macro's are adding and setting a custom property with the value SW-SurfaceArea

 

CustomProp.png

 

I have them working seperately

But i need help to jump the one that is to be ignored "SW-SurfaceArea@Assembly1.SLDASM" when it is a part and "SW-SurfaceArea@Part1.SLDPRT" when it is an assembly.

 

And i am trying to get the Current date to work as well

 

Dim swApp As SldWorks.SldWorks

 

Dim swModel As SldWorks.ModelDoc2

 

Dim swCustPropMgr As SldWorks.CustomPropertyManager

 

Sub main()

 

Set swApp = Application.SldWorks

 

Set swModel = swApp.ActiveDoc

Set config = swModel.GetActiveConfiguration

 

Set cusPropMgr = config.CustomPropertyManager

 

cusPropMgr.Add3 "sSurface", swCustomInfoText, Chr(34) & "SW-SurfaceArea@Part1.SLDPRT" & Chr(34), swCustomPropertyReplaceValue

 

swCustPropMgr.Add3 "sSurface", swCustomInfoText, Chr(34) & "SW-SurfaceArea@Assembly1.SLDASM" & Chr(34), swCustomPropertyReplaceValue

 

cusPropMgr.Add3 "SapMaterialHeader", swCustomInfoText, "Default", swCustomPropertyReplaceValue

cusPropMgr.Add3 "Revision", swCustomInfoText, "01", swCustomPropertyReplaceValue

cusPropMgr.Add3 "CheckedDate", swCustomInfoText, "CurrentDate", swCustomPropertyReplaceValue

 

End Sub

 

BackH
Thanks in advancedTha

Outcomes