Delete a feature in a part |
Top Previous Next |
It is a bit delicate if other features depend on the feature you are trying to delete.
void DeletePartFeatureByName(CComPtr<PartComponentDefinition>& pPartCompDef, const wchar_t* const pszName) { // Get the list of features... CComPtr<PartFeatures> pFeaturesList = nullptr ; HRESULT hRes = pPartCompDef->get_Features(&pFeaturesList) ; if (FAILED(hRes)) { ShowCOMError(hRes,L"DPFBN get_Features failed"); return ; }
CComPtr<PartFeature> pFeature = nullptr ; hRes = pFeaturesList->get_Item (CComVariant(pszName),&pFeature) ; if (FAILED(hRes)) { ShowCOMError(hRes,L"DPFBN get_Item(%s) failed",pszName); return ; }
hRes = pFeature->Delete(VARIANT_FALSE,VARIANT_FALSE,VARIANT_FALSE); if (FAILED(hRes)) { ShowCOMError(hRes,L"DPFBN Delete(%s) failed",pszName); } }
|
Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)