SolidWorks macro: copy cut-list properties to configuration
This macro copies all cut-list properties into the active configuration properties of a sheet metal part. Useful when you need config-level properties for drawings, BOMs, or exports.
How it works
- Finds the first cut-list folder and reads all custom properties.
- Writes those properties into the active configuration’s property manager.
- Shows a quick message when done (or when no cut-list is found).
Macro (VBA)
Const CONF_SPEC_PRP As Boolean = False
Const COPY_RES_VAL As Boolean = True
Dim PROPERTIES As Variant
Sub Init(Optional dummy As Variant = Empty)
PROPERTIES = Empty
End Sub
Sub CopyCutListPropertiesToConfigProperties()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swCutListPrpMgr As SldWorks.CustomPropertyManager
Dim swConfPrpMgr As SldWorks.CustomPropertyManager
Dim vPropNames As Variant
Dim i As Integer
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swCutListPrpMgr = GetCutListPropertyManager(swModel)
If Not swCutListPrpMgr Is Nothing Then
Set swConfPrpMgr = swModel.ConfigurationManager.ActiveConfiguration.CustomPropertyManager
vPropNames = swCutListPrpMgr.GetNames
For i = 0 To UBound(vPropNames)
swConfPrpMgr.Add2 vPropNames(i), swCutListPrpMgr.GetType2(vPropNames(i)), swCutListPrpMgr.Get(vPropNames(i))
Next
MsgBox "Cutlist properties have been copied to configuration properties manager by rejith :-D."
Else
MsgBox "Cut-list is not found."
End If
End Sub
Function GetCutListPropertyManager(model As SldWorks.ModelDoc2) As SldWorks.CustomPropertyManager
Dim swFeat As SldWorks.Feature
Set swFeat = model.FirstFeature
While Not swFeat Is Nothing
If swFeat.GetTypeName2() = "CutListFolder" Then
Set GetCutListPropertyManager = swFeat.CustomPropertyManager
Exit Function
End If
Set swFeat = swFeat.GetNextFeature
Wend
End Function
Usage
- Open your sheet metal part.
- Run the macro; it will copy the cut-list properties into the active configuration.
- Check custom properties at the configuration level for downstream use.