I am new to the world of macros, as well as to the programming language.
I need a macro to add a new custom property (which will always be called the same) and put in its 'Value/Text Expression' the evaluated value that binds to the configuration name property ($PRP:"SW-Configuration Name").
This is the value I need to write to the custom property:
And this is how the result would look after executing the desired macro:
I don't know how I can integrate this into the code...
It's possible?
I found a macro to be able to add a new custom property. But this only allows you to add the property name and value manually.
This is the macro:
Code: Select all
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swCustPropMgr As SldWorks.CustomPropertyManager
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Code As String
Sub setcode()
Code = "SIF0030010503M5"
End Sub
Sub main()
setcode
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swCustPropMgr = swModel.Extension.CustomPropertyManager("")
swCustPropMgr.Add3 "DENOM. SIF", swCustomInfoText, Code, swCustomPropertyReplaceValue
End Sub
- Add (in the active document) a new property called 'DENOM. SIF', whose value or text expression is the result of the formula $PRP:"SW-Configuration Name" (In the macro that I show I have added the value manually --> Code = "SIF0030010503M5")
- Save the Part.
- Close the document.
I would greatly appreciate a little help.
Thanks in advance.