0 Replies Latest reply on Nov 10, 2014 9:15 AM by Wasim Ahmed

    Modifying hole wizard definition

    Wasim Ahmed

      Hello,

      I am trying to change the hole definition of a hole created holewizard feature in a part which is an assembly component. Here is the code and the problem is id does not work at modify definition which returns false.I am not able to get what the problem is ......Could some one help

      CComPtr<IModelDoc2> swModel;

        HRESULT hr = pSwApp->get_IActiveDoc2(&swModel);

        if (FAILED(hr)||!swModel) return E_FAIL;

       

       

        CComPtr<IModelDocExtension> pModExtn;

        hr = swModel->get_Extension(&pModExtn);

        if (FAILED(hr)||!pModExtn) return E_FAIL;

       

       

        CComPtr<ISelectionMgr> pSelMgr;

        hr = swModel->get_ISelectionManager(&pSelMgr);

        if (FAILED(hr)||!pSelMgr) return E_FAIL;

       

       

        CComPtr<IAssemblyDoc> pAssem;

        hr = swModel->QueryInterface(&pAssem);

        if (FAILED(hr)||!pAssem) return E_FAIL;

       

       

        CComBSTR Name = L"CBORE for M10 Hex Head Bolt1@U-1@00/Upper Shoe-1@U";

        CComBSTR Type = L"BODYFEATURE";

        VARIANT_BOOL vbstat;

        hr = pModExtn->SelectByID2(Name, Type, 0.0, 0.0, 0.0, VARIANT_FALSE, 0, NULL, 0, &vbstat);

        if (FAILED(hr)) return E_FAIL;

       

       

        long Ind , Mark ;

        Ind = 1; Mark = -1;

        CComPtr<IDispatch> pDisp;

        hr = pSelMgr->GetSelectedObject6(Ind, Mark, &pDisp);

        if (FAILED(hr)) return E_FAIL;

       

       

        CComPtr<IFeature> pFeat;

        hr = pDisp->QueryInterface(&pFeat);

        if (FAILED(hr)||!pFeat) return E_FAIL;

       

       

        CComBSTR bstType;

        hr = pFeat->GetTypeName2(&bstType);

        if (FAILED(hr)) return E_FAIL;

       

       

        CComPtr<IEntity> pEnt;

        hr = pFeat->QueryInterface(&pEnt);

        if (FAILED(hr)) return E_FAIL;

       

       

        CComPtr<IComponent2> pComp;

        hr = pEnt->IGetComponent2(&pComp);

        if (FAILED(hr)||!pComp) return E_FAIL;

       

       

        CComBSTR bstCompName;

        hr = pComp->get_Name2(&bstCompName);

        if (FAILED(hr)) return E_FAIL;

       

       

        CComPtr<IDispatch> pUnk;

        hr = pFeat->GetDefinition(&pUnk);

        if (FAILED(hr)) return E_FAIL;

       

       

        CComPtr<IWizardHoleFeatureData2> pWizHole;

        hr = pUnk->QueryInterface(&pWizHole);

        if (FAILED(hr)) return E_FAIL;

       

       

        long Std;

        hr = pWizHole->get_Standard2(&Std);

        if (FAILED(hr)) return E_FAIL;

       

       

        long FastenerType;

        hr = pWizHole->get_FastenerType2(&FastenerType);

        if (FAILED(hr)) return E_FAIL;

       

       

        CComBSTR FastnerSize;

        hr = pWizHole->get_FastenerSize(&FastnerSize);

        if (FAILED(hr)) return E_FAIL;

       

       

        int HoleType;

        hr = pWizHole->get_Type(&HoleType);

        if (FAILED(hr)) return E_FAIL;

       

       

        VARIANT_BOOL VbStat;

        hr = pWizHole->IAccessSelections(swModel, pComp, &VbStat);

        if (FAILED(hr)) return E_FAIL;

       

       

        CComBSTR bstSize(L"M12");

        hr = pWizHole->ChangeStandard(Std, FastenerType, bstSize, &VbStat);

        if (FAILED(hr)) return E_FAIL;

       

        hr = pFeat->IModifyDefinition2(pWizHole, swModel, pComp, &VbStat);

        if (FAILED(hr)) return E_FAIL;

       

       

        hr = pAssem->EditAssembly();

        if (FAILED(hr)) return E_FAIL;