Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

VC++ addin to create a ClientFeature

Anonymous

VC++ addin to create a ClientFeature

Anonymous
Not applicable

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

 

Reply
656 Views
3 Replies
Replies (3)

Anonymous
Not applicable

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...

0 Likes

Anonymous
Not applicable

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 ?

0 Likes

Anonymous
Not applicable

Up

Anyone knows if ClientFeatures.CreateDefinition works in C++, or can give a workaround if it's not the case ?

0 Likes