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.
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
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
pDispatch->Release();
//
IWizardHoleFeatureData2Ptr ptrHoleWiz = NULL;
ptrFeat->GetDefinition(&pDispatch);
pDispatch->QueryInterface(__uuidof(IWizardHoleFeatureData2), reinterpret_cast
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;
}
SolidworksApi macros