Solidworks VBA: How do I get the quantity of the selected component in an assembly?

Hello

I'm coding a macro that aims to return the quantity of a selected component in the assembly. I tried with the "GetSelectedObjectCount2" function but it just returns the number of selected objects (not the quantity in the assembly).

 

More concretely: if I select a screw in the assembly, I would like to know how many screws there are in it. Then, to be able to assign this value to a variable for example. I know that we can see the quantity thanks to the BOM, but I can't get and assign the value in a variable.

 

PS: I'm new to VBA and I admit to getting lost in the "SldWorks" library of the solidworks API help...

Hello;

That's a late answer but always try this:

Macro: (VBA) count all selected components using SOLIDWORKS API

https://www.codestack.net/solidworks-api/document/assembly/components/count-all-selected-components/

Kind regards.