-
Re: Create a new custom property from a portion of an existing property?
Deepak Gupta Jul 10, 2012 2:05 PM (in response to Jeff Madden)Check the macro here: https://forum.solidworks.com/message/133512#133512
-
Re: Create a new custom property from a portion of an existing property?
Keith Rice Aug 2, 2012 9:46 AM (in response to Jeff Madden)Jeff,
Are you trying to create a new custom property or simply update an existing one? If the latter, here is code that will find a custom property called "FileName" with a value of "AA-XXXX" and update it to "XXXX":
=====
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swCustPropMgr As SldWorks.CustomPropertyManager
Dim strValOut As String
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swCustPropMgr = swModel.Extension.CustomPropertyManager(Empty)
swCustPropMgr.Get4 "FileName", True, strValOut, Empty
swCustPropMgr.Set "FileName", Replace(strValOut, "AA-", "")
End Sub
=====
Alternatively, if you are actually adding a new custom property, then use ICustomPropertyManager::Add2 instead of ICustomPropertyManager::Set.
Keith