C++: delete feature from part

Pioneer
Pioneer

Hi colleagues,

 

Does anyone knows C++ code that deletes a feature (identified by IDispatchPtr) from a part file?

 

Thank you,

Bodo

2 REPLIES

Re: C++: delete feature from part

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Here is the code:

HRESULT DeleteFeature(IDispatchPtr pFeature)
{
  if (pFeature == NULL) return E_POINTER;

  HRESULT  hr = S_OK;
  DISPID   dispId;
  LPOLESTR names[1] = { L"Delete" };
  hr = pFeature->GetIDsOfNames(IID_NULL, names, 1, LOCALE_USER_DEFAULT, &dispId);
  if (SUCCEEDED(hr))
  {
    try
    {
      hr = _com_dispatch_method(pFeature, dispId, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
    }
    catch (_com_error &e)
    {
      hr = e.Error();
    }
  }

  return hr;
}

Re: C++: delete feature from part

Pioneer
Pioneer
Works at once like a charm!
Thank's a lot!