<?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 Simple question, or is it? in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/simple-question-or-is-it/m-p/756944#M170912</link>
    <description>How can I get the full filename of a part from an Occurance object?&lt;BR /&gt;
I need to do this in C++ using Inventor Application object (not Apprentice,&lt;BR /&gt;
but if this can be done differently using Apprentice, by all means tell me&lt;BR /&gt;
that also &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
I have a recursive function(basically same as the GetOccurancesDispatch from&lt;BR /&gt;
the SDK samples)&lt;BR /&gt;
In some cases I need to get the Filename of a part 'behind' the occurance.&lt;BR /&gt;
How would I do this?&lt;BR /&gt;
&lt;BR /&gt;
Here is a stripped version of my recursive function...&lt;BR /&gt;
&lt;BR /&gt;
HRESULT CTree::FillTree(HTREEITEM ParentItem, CTreeCtrl* pTreeToFill,&lt;BR /&gt;
ComponentOccurrences* pIncomingOccurances)&lt;BR /&gt;
&lt;BR /&gt;
Result = pIncomingOccurances-&amp;gt;get_Count(&amp;amp;nOccMax);&lt;BR /&gt;
&lt;BR /&gt;
for(long nOccuCount = 1; nOccuCount &amp;lt;= nOccMax;++nOccuCount){&lt;BR /&gt;
&lt;BR /&gt;
    CComPtr&lt;COMPONENTOCCURRENCE&gt; pOccu;&lt;BR /&gt;
    CComPtr&lt;COMPONENTOCCURRENCESENUMERATOR&gt; pOcEn;&lt;BR /&gt;
&lt;BR /&gt;
    HTREEITEM LocalItem;&lt;BR /&gt;
    pOccu = pIncomingOccurances-&amp;gt;GetItem(nOccuCount);&lt;BR /&gt;
    strName = (LPCSTR)pOccu-&amp;gt;Get_DisplayName();&lt;BR /&gt;
&lt;BR /&gt;
    if(pOccu-&amp;gt;GetDefinitionDocumentType() == kAssemblyDocumentObject)&lt;BR /&gt;
     LocalItem = pTreeToFill-&amp;gt;InsertItem(strName,0,0,ParentItem);&lt;BR /&gt;
    else&lt;BR /&gt;
     LocalItem = pTreeToFill-&amp;gt;InsertItem(strName,1,1,ParentItem);&lt;BR /&gt;
&lt;BR /&gt;
    Result = pOccu-&amp;gt;get_SubOccurrences(&amp;amp;pOcEn);&lt;BR /&gt;
    CComQIPtr&lt;COMPONENTOCCURRENCES&gt; pOccs(pOcEn);&lt;BR /&gt;
&lt;BR /&gt;
    Result = FillTree(LocalItem, pTreeToFill, pOccs);&lt;BR /&gt;
}&lt;BR /&gt;
return Result;&lt;BR /&gt;
}&lt;/COMPONENTOCCURRENCES&gt;&lt;/COMPONENTOCCURRENCESENUMERATOR&gt;&lt;/COMPONENTOCCURRENCE&gt;</description>
    <pubDate>Thu, 06 Mar 2003 00:40:07 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2003-03-06T00:40:07Z</dc:date>
    <item>
      <title>Simple question, or is it?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/simple-question-or-is-it/m-p/756944#M170912</link>
      <description>How can I get the full filename of a part from an Occurance object?&lt;BR /&gt;
I need to do this in C++ using Inventor Application object (not Apprentice,&lt;BR /&gt;
but if this can be done differently using Apprentice, by all means tell me&lt;BR /&gt;
that also &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
I have a recursive function(basically same as the GetOccurancesDispatch from&lt;BR /&gt;
the SDK samples)&lt;BR /&gt;
In some cases I need to get the Filename of a part 'behind' the occurance.&lt;BR /&gt;
How would I do this?&lt;BR /&gt;
&lt;BR /&gt;
Here is a stripped version of my recursive function...&lt;BR /&gt;
&lt;BR /&gt;
HRESULT CTree::FillTree(HTREEITEM ParentItem, CTreeCtrl* pTreeToFill,&lt;BR /&gt;
ComponentOccurrences* pIncomingOccurances)&lt;BR /&gt;
&lt;BR /&gt;
Result = pIncomingOccurances-&amp;gt;get_Count(&amp;amp;nOccMax);&lt;BR /&gt;
&lt;BR /&gt;
for(long nOccuCount = 1; nOccuCount &amp;lt;= nOccMax;++nOccuCount){&lt;BR /&gt;
&lt;BR /&gt;
    CComPtr&lt;COMPONENTOCCURRENCE&gt; pOccu;&lt;BR /&gt;
    CComPtr&lt;COMPONENTOCCURRENCESENUMERATOR&gt; pOcEn;&lt;BR /&gt;
&lt;BR /&gt;
    HTREEITEM LocalItem;&lt;BR /&gt;
    pOccu = pIncomingOccurances-&amp;gt;GetItem(nOccuCount);&lt;BR /&gt;
    strName = (LPCSTR)pOccu-&amp;gt;Get_DisplayName();&lt;BR /&gt;
&lt;BR /&gt;
    if(pOccu-&amp;gt;GetDefinitionDocumentType() == kAssemblyDocumentObject)&lt;BR /&gt;
     LocalItem = pTreeToFill-&amp;gt;InsertItem(strName,0,0,ParentItem);&lt;BR /&gt;
    else&lt;BR /&gt;
     LocalItem = pTreeToFill-&amp;gt;InsertItem(strName,1,1,ParentItem);&lt;BR /&gt;
&lt;BR /&gt;
    Result = pOccu-&amp;gt;get_SubOccurrences(&amp;amp;pOcEn);&lt;BR /&gt;
    CComQIPtr&lt;COMPONENTOCCURRENCES&gt; pOccs(pOcEn);&lt;BR /&gt;
&lt;BR /&gt;
    Result = FillTree(LocalItem, pTreeToFill, pOccs);&lt;BR /&gt;
}&lt;BR /&gt;
return Result;&lt;BR /&gt;
}&lt;/COMPONENTOCCURRENCES&gt;&lt;/COMPONENTOCCURRENCESENUMERATOR&gt;&lt;/COMPONENTOCCURRENCE&gt;</description>
      <pubDate>Thu, 06 Mar 2003 00:40:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/simple-question-or-is-it/m-p/756944#M170912</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-03-06T00:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: Simple question, or is it?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/simple-question-or-is-it/m-p/756945#M170913</link>
      <description>Answering to my myself, I found one way by try/error method &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Here it is...&lt;BR /&gt;
&lt;BR /&gt;
    CComPtr&lt;COMPONENTOCCURRENCE&gt; pOccu&lt;BR /&gt;
&lt;BR /&gt;
   IDispatch* pIDisp=NULL;&lt;BR /&gt;
   pOccu-&amp;gt;GetDefinition()-&amp;gt;get_Document(&amp;amp;pIDisp);&lt;BR /&gt;
   DocumentPtr pDocFromOcc(pIDisp);&lt;BR /&gt;
   CString strFullFileName = (LPCSTR)pDocFromOcc-&amp;gt;GetFullFileName();&lt;BR /&gt;
&lt;BR /&gt;
As I'm relatively new to COM programmnig especially with C++ I would&lt;BR /&gt;
appreciate any comments you might have. Is this the 'right' way of doing&lt;BR /&gt;
this?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
"ML" &lt;MLA&gt; wrote in message&lt;BR /&gt;
news:7BCC25B5FBE714BCF1647937F04FEC8A@in.WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; How can I get the full filename of a part from an Occurance object?&lt;BR /&gt;
&amp;gt; I need to do this in C++ using Inventor Application object (not&lt;BR /&gt;
Apprentice,&lt;BR /&gt;
&amp;gt; but if this can be done differently using Apprentice, by all means tell me&lt;BR /&gt;
&amp;gt; that also &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; I have a recursive function(basically same as the GetOccurancesDispatch&lt;BR /&gt;
from&lt;BR /&gt;
&amp;gt; the SDK samples)&lt;BR /&gt;
&amp;gt; In some cases I need to get the Filename of a part 'behind' the occurance.&lt;BR /&gt;
&amp;gt; How would I do this?&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Here is a stripped version of my recursive function...&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; HRESULT CTree::FillTree(HTREEITEM ParentItem, CTreeCtrl* pTreeToFill,&lt;BR /&gt;
&amp;gt; ComponentOccurrences* pIncomingOccurances)&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Result = pIncomingOccurances-&amp;gt;get_Count(&amp;amp;nOccMax);&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; for(long nOccuCount = 1; nOccuCount &amp;lt;= nOccMax;++nOccuCount){&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     CComPtr&lt;COMPONENTOCCURRENCE&gt; pOccu;&lt;BR /&gt;
&amp;gt;     CComPtr&lt;COMPONENTOCCURRENCESENUMERATOR&gt; pOcEn;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     HTREEITEM LocalItem;&lt;BR /&gt;
&amp;gt;     pOccu = pIncomingOccurances-&amp;gt;GetItem(nOccuCount);&lt;BR /&gt;
&amp;gt;     strName = (LPCSTR)pOccu-&amp;gt;Get_DisplayName();&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     if(pOccu-&amp;gt;GetDefinitionDocumentType() == kAssemblyDocumentObject)&lt;BR /&gt;
&amp;gt;      LocalItem = pTreeToFill-&amp;gt;InsertItem(strName,0,0,ParentItem);&lt;BR /&gt;
&amp;gt;     else&lt;BR /&gt;
&amp;gt;      LocalItem = pTreeToFill-&amp;gt;InsertItem(strName,1,1,ParentItem);&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     Result = pOccu-&amp;gt;get_SubOccurrences(&amp;amp;pOcEn);&lt;BR /&gt;
&amp;gt;     CComQIPtr&lt;COMPONENTOCCURRENCES&gt; pOccs(pOcEn);&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;     Result = FillTree(LocalItem, pTreeToFill, pOccs);&lt;BR /&gt;
&amp;gt; }&lt;BR /&gt;
&amp;gt; return Result;&lt;BR /&gt;
&amp;gt; }&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt;&lt;/COMPONENTOCCURRENCES&gt;&lt;/COMPONENTOCCURRENCESENUMERATOR&gt;&lt;/COMPONENTOCCURRENCE&gt;&lt;/MLA&gt;&lt;/COMPONENTOCCURRENCE&gt;</description>
      <pubDate>Thu, 06 Mar 2003 05:09:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/simple-question-or-is-it/m-p/756945#M170913</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-03-06T05:09:33Z</dc:date>
    </item>
  </channel>
</rss>

