Change size of a hole

Top  Previous  Next

Here is an example:

 

void ChangeForoValvolinaDiam (CComPtr<PartComponentDefinition>& pPartCompDef, const double kmmNewDiam)

{

   // Get the list of features...

   CComPtr<PartFeatures> pFeaturesList ;

   HRESULT hRes = pPartCompDef->get_Features(&pFeaturesList) ;

   if (FAILED(hRes)) {

       ShowCOMError(ekLogMsg,hRes,L"CFVD get_Features failed");

       return ;

   }

 

   // Find the feature which is the hole I want to change...

   CComPtr<PartFeature> pFeature;

   hRes = pFeaturesList->get_Item (CComVariant(L"ForoValvolina"), &pFeature);

   if (FAILED(hRes)) {

       ShowCOMError(ekLogMsg,hRes,L"CFVD get_Item failed");

       return ;

   }

 

   // The name is correct, see if it is actually a hole...

   if (pFeature->GetType() == kHoleFeatureObject) {

 

       // Convert the general pFeature it into the specific pHoleFeature

       // This is an example of using a CComQIPtr

       CComQIPtr<HoleFeature> pHoleFeature (pFeature) ;

       if (pHoleFeature == nullptr) {

           gLogger.Printf (ekLogMsg,L"Cannot cast") ;

           return ;

       }

 

       // Get the value of the parameter as a variant...

       CComVariant cmDiam (pHoleFeature->HoleDiameter->GetValue()) ;

       const double kmmDiam = cmDiam.dblVal*10.0 ;

       gLogger.Printf (ekLogMsg,L"hole diam = %6.3fmm",kmmDiam) ;

 

       // Change into centimeters...

       cmDiam.dblVal = kmmNewDiam/10.0 ;

 

       // Actually change the size of the hole...

       pHoleFeature->HoleDiameter->Value = cmDiam ;

   }

}

 

Enter topic text here.

Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)