- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
VC++ addin to create a ClientFeature
Hi,
I've been trying to create a ClientFeature with a c++ addin for a few hours, without success.
Here is a sample of my code :
Document * doc = m_pApp->GetActiveDocument(); PartDocument * partDoc; HRESULT hr = doc->QueryInterface(__uuidof(PartDocument), (void**)&partDoc); if (!SUCCEEDED(hr) || !partDoc) return E_FAIL; PartComponentDefinition * oCompDef = partDoc->ComponentDefinition; if(!oCompDef) return E_FAIL; PartFeatures * partFeatures = oCompDef->GetFeatures(); if (!partFeatures) return E_FAIL; ClientFeatures * clientFeatures = partFeatures->ClientFeatures; if (!clientFeatures) return E_FAIL; CComPtr<ClientFeatureDefinition> clientFeatureDef; CComBSTR featType = "FeatName";
VARIANT nothing; hr = clientFeatures->CreateDefinition(featType, nothing, nothing, nothing, &clientFeatureDef); // crash
I use "nothing" because these arguments are optional but as the C++ function return the result in the last argument I have to provid the previous arguments.
When trying to execute this code, Inventor throw an exception and crash at the "CreateDefinition" line.
I also tried with
_bstr_t featTypebstr = "FeatName"; clientFeatureDef = clientFeatures->MethodCreateDefinition(featTypebstr);
and got the same result (crash).
If anyone could tell me what I am doing wrong that would be really helpful.
Thank you,
Thomas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Little update :
I tried to do the exact same thing with C# and it worked first try. Here is the code (very simple) :
app = AddInServer.InventorApplication; var activePart = (PartDocument) app.ActiveDocument; PartComponentDefinition compDef = activePart.ComponentDefinition; PartFeatures pFeats = compDef.Features; ClientFeatures cFeatures = pFeats.ClientFeatures; ClientFeatureDefinition featDef = cFeatures.CreateDefinition(); ClientFeature cFeat = cFeatures.Add(featDef, "testClientFeatID");
To me it looks like the C++ API is not workink properly...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have the same problem and C# or VB isn't an option for me, can anyone help me before I switch to another product than Inventor ?