I though this would be a handy little macro to have, and good practise to make.
It's a macrofeature that deletes all solidbodies.
I've removed the Parents, so it can be reordered in the tree, and the parent features can be suppressed or deleted, but I couldn't work out how to just delete a Body - tout suite!
I realised I could perform a Cut Operation on the Body with a copy of itself, but surely I can just 'make' an empty body or whatever is required.
Function swmRebuild(swApp As SldWorks.SldWorks, swModel As SldWorks.ModelDoc2, swFeature As SldWorks.Feature) As Variant
Dim swMFD As SldWorks.MacroFeatureData: Set swMFD = swFeature.GetDefinition
Dim swPart As SldWorks.PartDoc: Set swPart = swModel
swMFD.EnableMultiBodyConsume = True
Dim swbtBodyType As swBodyType_e: swbtBodyType = swSolidBody
Dim bVisibleOnly As Boolean: bVisibleOnly = False
Dim vBodies As Variant: vBodies = swPart.GetBodies2(swbtBodyType, bVisibleOnly)
Dim swBody As SldWorks.Body2
If Not IsEmpty(vBodies) Then
Dim i As Long
For i = 0 To UBound(vBodies)
Set swBody = vBodies(i)
Dim swbOperationType As swBodyOperationType_e
swbOperationType = SWBODYCUT
Dim swboErrorCode As swBodyOperationError_e
swBody.Operations2 swbOperationType, swBody.Copy, swboErrorCode
swMFD.EditBodies = vBodies
Dim ParentFeatures(0) As SldWorks.Feature
Set ParentFeatures(0) = swPart.FeatureByName("Solid Bodies")
swMFD.Parents = ParentFeatures
Set swmRebuild = swBody
2018 swp attached