AnsweredAssumed Answered

WizardHoleFeatureData2 API problem

Question asked by Vinicius Pontes on Sep 26, 2013
Latest reply on Dec 29, 2015 by Yong Ning

Hi,

 

I'm trying to write a function which will change the "Size" of a "Tapped hole" hole wizard type.

 

My HoleWizard feature has the hole in 3 positions, like the picture below. The problem is that only one of them is changed correctly. The oders show a wrong cosmetc, which is reflected in the drawing.

 

I'm changing from M16 to M30, for example. The inner diameter is updated correctly, but the outer don't.

pic1.png

Does anybody know why it's happening?

 

I've notice that after the function completes its job, if I edit the feature and finishe edition without changing anything, the cosmetics is updated.

 

Thanks for any help,

 

Vinicius

 

C++ code below:

 

bool ChangeHoleWizardSize(IModelDoc2 *pModel, LPCTSTR featureName, LPCTSTR value)

{

          HRESULT hr = S_OK;

          VARIANT_BOOL ok = VARIANT_FALSE;

          //

          IModelDocExtensionPtr ptrModelDocExt = NULL;

          pModel->get_Extension(&ptrModelDocExt);

          //

          struct IDispatch *pDispatch = NULL;

          hr = pModel->get_SelectionManager(&pDispatch);

          //

          ISelectionMgrPtr ptrSelMgr = NULL;

          pDispatch->QueryInterface(__uuidof(ISelectionMgr), reinterpret_cast<void**>(&ptrSelMgr));

          pDispatch->Release();

          //

          ICalloutPtr ptrCallout = NULL;

          hr = ptrModelDocExt->SelectByID2(_bstr_t(featureName), _bstr_t("BODYFEATURE"), 0, 0, 0, VARIANT_FALSE, 0, ptrCallout, 0, &ok);

          if ( ok == VARIANT_FALSE )

          {

                    return false;

          }

          //

          hr = ptrSelMgr->GetSelectedObject5(1, &pDispatch);

          //

          IFeaturePtr ptrFeat = NULL;

          pDispatch->QueryInterface(__uuidof(IFeature), reinterpret_cast<void**>(&ptrFeat));

          pDispatch->Release();

          //

          IWizardHoleFeatureData2Ptr ptrHoleWiz = NULL;

          ptrFeat->GetDefinition(&pDispatch);

          pDispatch->QueryInterface(__uuidof(IWizardHoleFeatureData2), reinterpret_cast<void**>(&ptrHoleWiz));

          pDispatch->Release();

          //

          long nStandard = swStandardDIN;

          long nFastnerType = swStandardDINTappedHole;

          hr = ptrHoleWiz->get_Standard2(&nStandard);

          hr = ptrHoleWiz->get_FastenerType2(&nFastnerType);

          //

          hr = ptrHoleWiz->AccessSelections(pModel, NULL, &ok);

          hr = ptrHoleWiz->ChangeStandard(nStandard, nFastnerType, _bstr_t(value), &ok);

          ptrHoleWiz->put_HoleFit(swScrewClearanceNormal);

          ptrFeat->IModifyDefinition2(ptrHoleWiz, pModel, NULL, &ok);

          //

          ptrSelMgr.Release();

          ptrHoleWiz.Release();

          ptrFeat.Release();

          //

          return ( ok != VARIANT_FALSE )?true:false;

}

Outcomes