2 Replies Latest reply on Dec 12, 2014 9:20 AM by Yong Ning

    c++ API IComponent2->SetSuppression2 doesn't always work

    Chuan Hung

      Hi,

       

      I'm trying to extract the component geometries in a SLDASM file along with the mass properties for each component.

      From what I understand from the documentation:

      1. IComponent2->GetModelDoc2 might return null if the IComponent2 is suppressed or lightweight

      2. IComponent2 needs to be in lightweight mode for me to get the geometry data.

       

      I'm setting the IComponent2 to resolved to get the mass properties first then setting it to lightweight afterward to get the geometry. However the function SetSuppression2 doesn't always work. There are times where GetSuppression2 returns resolved even after I set it to lightweight. Does anyone know why? Thanks in advance.

       

              long lSuppressError;

              HRESULT hr = component->SetSuppression2 ( swComponentSuppressionState_e::swComponentResolved, &lSuppressError );

       

              // extract metadata

              IDispatch* modelDocDispatch;

              hr = component->GetModelDoc2 ( &modelDocDispatch );

              IModelDoc2Ptr modelDoc = NULL;

              double volume;

              double density;

              double mass;

              if ( modelDocDispatch != NULL ) {

                  hr = modelDocDispatch->QueryInterface ( IID_IModelDoc2, ( void** ) &modelDoc );

       

                  IModelDocExtensionPtr modelDocExt = NULL;

                  hr = modelDoc->get_Extension ( &modelDocExt );

       

                  IMassPropertyPtr massProperty = NULL;

                  modelDocExt->CreateMassProperty ( &massProperty );

       

                  massProperty->get_Volume ( &volume );

                  massProperty->get_Mass ( &mass );

                  massProperty->get_Density ( &density );

              } else {

                // error

                  volume = 0;

                  density = 0;

                  mass = 0;

              }

       

              // set suppression state of component to Lightweight is required to extract geometry data off the models

              long lSuppressError2;

              hr = component->SetSuppression2 ( swComponentLightweight, &lSuppressError2 );

            

              // Extract Geometry Below...but sometimes fail because IComponent2 is still resolved.