<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic VC++ addin to create a ClientFeature in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/vc-addin-to-create-a-clientfeature/m-p/8404194#M91451</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I've been trying to create a ClientFeature with a c++ addin for a few hours, without success.&lt;/P&gt;&lt;P&gt;Here is a sample of my code :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Document * doc = m_pApp-&amp;gt;GetActiveDocument();
PartDocument * partDoc;
HRESULT hr = doc-&amp;gt;QueryInterface(__uuidof(PartDocument), (void**)&amp;amp;partDoc);
if (!SUCCEEDED(hr) || !partDoc) return E_FAIL;
PartComponentDefinition * oCompDef = partDoc-&amp;gt;ComponentDefinition;
if(!oCompDef) return E_FAIL;
PartFeatures * partFeatures = oCompDef-&amp;gt;GetFeatures();
if (!partFeatures) return E_FAIL;
ClientFeatures * clientFeatures = partFeatures-&amp;gt;ClientFeatures;
if (!clientFeatures) return E_FAIL;
CComPtr&amp;lt;ClientFeatureDefinition&amp;gt; clientFeatureDef;
CComBSTR featType = "FeatName";&lt;BR /&gt;VARIANT nothing;
hr = clientFeatures-&amp;gt;CreateDefinition(featType, &lt;SPAN&gt;nothing&lt;/SPAN&gt;, &lt;SPAN&gt;nothing&lt;/SPAN&gt;, &lt;SPAN&gt;nothing&lt;/SPAN&gt;, &amp;amp;clientFeatureDef); // crash&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When trying to execute this code, Inventor throw an exception and crash at the "CreateDefinition" line.&lt;/P&gt;&lt;P&gt;I also tried with&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;_bstr_t featTypebstr = "FeatName";
clientFeatureDef = clientFeatures-&amp;gt;MethodCreateDefinition(featTypebstr);&lt;/PRE&gt;&lt;P&gt;and got the same result (crash).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone could tell me what I am doing wrong that would be really helpful.&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Nov 2018 14:26:39 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-11-15T14:26:39Z</dc:date>
    <item>
      <title>VC++ addin to create a ClientFeature</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/vc-addin-to-create-a-clientfeature/m-p/8404194#M91451</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I've been trying to create a ClientFeature with a c++ addin for a few hours, without success.&lt;/P&gt;&lt;P&gt;Here is a sample of my code :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Document * doc = m_pApp-&amp;gt;GetActiveDocument();
PartDocument * partDoc;
HRESULT hr = doc-&amp;gt;QueryInterface(__uuidof(PartDocument), (void**)&amp;amp;partDoc);
if (!SUCCEEDED(hr) || !partDoc) return E_FAIL;
PartComponentDefinition * oCompDef = partDoc-&amp;gt;ComponentDefinition;
if(!oCompDef) return E_FAIL;
PartFeatures * partFeatures = oCompDef-&amp;gt;GetFeatures();
if (!partFeatures) return E_FAIL;
ClientFeatures * clientFeatures = partFeatures-&amp;gt;ClientFeatures;
if (!clientFeatures) return E_FAIL;
CComPtr&amp;lt;ClientFeatureDefinition&amp;gt; clientFeatureDef;
CComBSTR featType = "FeatName";&lt;BR /&gt;VARIANT nothing;
hr = clientFeatures-&amp;gt;CreateDefinition(featType, &lt;SPAN&gt;nothing&lt;/SPAN&gt;, &lt;SPAN&gt;nothing&lt;/SPAN&gt;, &lt;SPAN&gt;nothing&lt;/SPAN&gt;, &amp;amp;clientFeatureDef); // crash&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When trying to execute this code, Inventor throw an exception and crash at the "CreateDefinition" line.&lt;/P&gt;&lt;P&gt;I also tried with&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;_bstr_t featTypebstr = "FeatName";
clientFeatureDef = clientFeatures-&amp;gt;MethodCreateDefinition(featTypebstr);&lt;/PRE&gt;&lt;P&gt;and got the same result (crash).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone could tell me what I am doing wrong that would be really helpful.&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 14:26:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/vc-addin-to-create-a-clientfeature/m-p/8404194#M91451</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-15T14:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: VC++ addin to create a ClientFeature</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/vc-addin-to-create-a-clientfeature/m-p/8404454#M91456</link>
      <description>&lt;P&gt;Little update :&lt;/P&gt;&lt;P&gt;I tried to do the exact same thing with C# and it worked first try. Here is the code (very simple) :&lt;/P&gt;&lt;PRE&gt;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");&lt;/PRE&gt;&lt;P&gt;To me it looks like the C++ API is not workink properly...&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 15:59:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/vc-addin-to-create-a-clientfeature/m-p/8404454#M91456</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-15T15:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: VC++ addin to create a ClientFeature</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/vc-addin-to-create-a-clientfeature/m-p/8405974#M91477</link>
      <description>&lt;P&gt;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 ?&lt;/P&gt;</description>
      <pubDate>Fri, 16 Nov 2018 08:51:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/vc-addin-to-create-a-clientfeature/m-p/8405974#M91477</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-16T08:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: VC++ addin to create a ClientFeature</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/vc-addin-to-create-a-clientfeature/m-p/8410043#M91542</link>
      <description>&lt;P&gt;Up&lt;/P&gt;&lt;P&gt;Anyone knows if ClientFeatures.CreateDefinition works in C++, or can give a workaround if it's not the case ?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 09:44:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/vc-addin-to-create-a-clientfeature/m-p/8410043#M91542</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-19T09:44:01Z</dc:date>
    </item>
  </channel>
</rss>

