How can I modify the code below to work in a SolidWorks drawing instead of a part?
Sub Main()
Set swApp = CreateObject("SldWorks.Application")
Set CurrentDoc = swApp.ActiveDoc
Set Part = swApp.ActiveDoc
' No document loaded error handler
If Part Is Nothing Then
MsgBox "No document loaded!", vbCritical
End
Else
End If
Part.ClearSelection2 True
' Assign custom properties
PropName(0) = "Die Number"
PropName(1) = "Plant"
PropName(2) = "File Name"
PropName(3) = "Press"
PropName(4) = "Drawn Date"
PropName(5) = "Del Date"
PropName(6) = "Bolster"
PropName(7) = "Cavities"
' Add custom properties (won't overwrite if they already exist)
Prop = CurrentDoc.AddCustomInfo3("", PropName(0), swCustomInfoText, " ")
Prop = CurrentDoc.AddCustomInfo3("", PropName(1), swCustomInfoText, " ")
Prop = CurrentDoc.AddCustomInfo3("", PropName(2), swCustomInfoText, " ")
Prop = CurrentDoc.AddCustomInfo3("", PropName(3), swCustomInfoText, " ")
Prop = CurrentDoc.AddCustomInfo3("", PropName(4), swCustomInfoText, " ")
Prop = CurrentDoc.AddCustomInfo3("", PropName(5), swCustomInfoText, " ")
Prop = CurrentDoc.AddCustomInfo3("", PropName(6), swCustomInfoText, " ")
Prop = CurrentDoc.AddCustomInfo3("", PropName(7), swCustomInfoText, " ")
Call CheckProps
End Sub
SolidworksApi macros