AnsweredAssumed Answered

Mass Properties of Component in Assembly Context

Question asked by Patrick Jensen on Mar 25, 2019
Latest reply on Mar 26, 2019 by Patrick Jensen



I have a macro that iterates through all components within an assembly. For each component I get the mass properties like such (this is just a code snippet to get an idea of how I'm doing it, and not intended to be run-able):


For Each Component In Components

     Set swComp = Component

     Set SwModel = swComp.GetModelDoc

     Set swModExt = SwModel.Extension

     swModExt.IncludeMassPropertiesOfHiddenBodies = False

     vMass = swModExt.GetMassProperties(2, massStatus)




Next Component


The problem is when parts are hidden in a subassembly but only within the context of the parent assembly. The subassembly does not have these parts hidden in it's model document. Therefore, when I get the mass properties of the subassembly, it is including the weight of these hidden components because I am getting the model document.


I am aware that ModelDocExtension::GetMassProperties2 has the ability to get the mass properties of selected components only, but this isn't feasible because the assembly has ~10,000 parts and this would take very long to run. Ideally, there would be no in-context assembly editing, but I cannot control this, and need to account for it.


Any suggestions for how I can get the mass properties of the component within the context of the parent assembly?