Files
Lesson 3.3 code
Code
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swCustPropMgr As SldWorks.CustomPropertyManager
Dim vConfigNames As Variant
Dim strValue As String
Dim strResolved As String
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'Access cust props at doc level
Set swCustPropMgr = swModel.Extension.CustomPropertyManager("")
Debug.Print swCustPropMgr.Add2("Description", swCustomInfoText, "Intake ring")
swCustPropMgr.Set "Author", "JD"
swCustPropMgr.Get3 "PartNo", True, strValue, strResolved
swCustPropMgr.Delete "PartNo"
'Access cust props at config level
vConfigNames = swModel.GetConfigurationNames
Dim i As Integer
For i = 0 To UBound(vConfigNames)
Set swCustPropMgr = swModel.Extension.CustomPropertyManager(vConfigNames(i))
swCustPropMgr.Add2 "PartNo", swCustomInfoText, strValue & "-" & vConfigNames(i)
swCustPropMgr.Add2 "Material", swCustomInfoText, Chr(34) & "SW-Material@" & swModel.GetTitle & Chr(34)
Next i
End Sub