if somebody has an example script for getting 2 or more selected solids and add them (boolean add) in a combine feature, I could debug my script too.
How are you selecting bodies to be combined? If you are using IModelDocExtension::SelectByID2 method, then you will need to select the bodies using mark '2'. Have a look the example in API help: 2018 SOLIDWORKS API Help - Combine Bodies Example (VBA) , otherwise attach your whole macro or post your full codes for someone to help you.
I literally just stumbled upon this.
I got it working now. I wasn't perfectly sure what it was, but that '2' instead of '0' seemed to make a difference.
Part of the running code now:
' select parts
PartName = Dir(OutFolder & PartType)
Do While PartName <> ""
NodeName = "<" & Left(PartName, InStr(PartName, ".") - 1) & ">-<Imported1>"
boolstatus = swModel.Extension.SelectByID2(NodeName, "SOLIDBODY", 0, 0, 0, True, 2, Nothing, 0)
PartName = Dir
' combine parts
Set swFeatureMgr = swModel.FeatureManager
Set swFeature = swFeatureMgr.InsertCombineFeature(15903, Nothing, Nothing)
So... I think the correct answer credit should go to Nilesh, right?