I now have a macro that is adding the custom properties that I need (pasted some of the code below). The only problem is that I want the properties to be configuration specific, not only under the Custom tab where they now end up. The config names in our models can vary, so I guess that the macro has to retrieve the config names before adding the proerties, or...?
Any help with this will be highly appreciated.
SolidworksApi macrosSet CusPropMgr = swModel.Extension.CustomPropertyManager("")
'Get the File Name of the Part
strFilename = swModel.GetPathNamebolCheck = False
inCount = 1strResFilename = Left(strFilename, Len(strFilename) - 7)
Do While bolCheck = False
strModString = Right(strResFilename, intCount)
If Left(strModString, 1) = "\" Then
strResFilename = Right(strResFilename, intCount - 1)
bolCheck = True
Else
intCount = intCount + 1
End If
LoopIf swModel.GetType = swDocPART Then
'Create PART custom properties if they are missing.
sValue = Chr(34) & "Mass [kg]@" & strResFilename & ".SLDPRT" & Chr(34)
AddStatus = CusPropMgr.Add2("Mass kg", swCustomInfoText, sValue)
SetStatus = CusPropMgr.Set("Mass kg", sValue)
sValue = Chr(34) & "Volume [cm³]@" & strResFilename & ".SLDPRT" & Chr(34)
AddStatus = CusPropMgr.Add2("Volume cm³", swCustomInfoText, sValue)
SetStatus = CusPropMgr.Set("Volume cm³", sValue)
sValue = Chr(34) & "Surface area [cm²]@" & strResFilename & ".SLDPRT" & Chr(34)
AddStatus = CusPropMgr.Add2("Surface area cm²", swCustomInfoText, sValue)
SetStatus = CusPropMgr.Set("Surface area cm²", sValue)
'swApp.ActiveDoc.ActiveView.FrameState = 1
MsgBox "Default KA properties have been set in PART", vbExclamation
' swModel.FileSummaryInfoElseIf swModel.GetType = swDocASSEMBLY Then
'Create ASSY custom properties if they are missing.
sValue = Chr(34) & "Surface area@" & strResFilename & ".SLDASM" & Chr(34)
AddStatus = CusPropMgr.Add2("Surface area", swCustomInfoText, sValue)
SetStatus = CusPropMgr.Set("Surface area", sValue)
'swApp.ActiveDoc.ActiveView.FrameState = 1
MsgBox "Default KA properties have been set in ASSY", vbExclamation
' swModel.FileSummaryInfoElse
' instructions for drawing
MsgBox "Not a Drawing Macro, run Macro on PART or ASSY", vbExclamationEnd If