Files
Lesson 3.3 homework solution
Code
'Homework 3.3
'Write a macro that changes the doc-level custom property called "Revision" to "03400-B", _
deletes out the configuration specific custom properties called "Author" and creates a _
new custom property called "Author" with the same value at the document level. _
Note: You can create the part yourself simply by creating a part with two configurations, _
with each config having a custom property called "Author" (use your initials for the _
value) and a doc level custom property called "Revision" (initial value is arbitrary).
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swCustPropMgr As SldWorks.CustomPropertyManager
Dim vConfigNames As Variant
Dim strValue As String
Dim strResValue As String
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'configuration specific level
vConfigNames = swModel.GetConfigurationNames
For i = 0 To UBound(vConfigNames)
Set swCustPropMgr = swModel.Extension.CustomPropertyManager(vConfigNames(i))
'use false for UseCached if the config has not been activated
swCustPropMgr.Get3 "Author", False, strValue, strResValue
swCustPropMgr.Delete "Author"
Next i
'document level
Set swCustPropMgr = swModel.Extension.CustomPropertyManager("")
swCustPropMgr.Set "Revision", "03400-B"
swCustPropMgr.Add2 "Author", swCustomInfoText, strValue
End Sub