Simple question, or is it?

Simple question, or is it?

Anonymous
Not applicable
250 Views
1 Reply
Message 1 of 2

Simple question, or is it?

Anonymous
Not applicable
How can I get the full filename of a part from an Occurance object?
I need to do this in C++ using Inventor Application object (not Apprentice,
but if this can be done differently using Apprentice, by all means tell me
that also 🙂

I have a recursive function(basically same as the GetOccurancesDispatch from
the SDK samples)
In some cases I need to get the Filename of a part 'behind' the occurance.
How would I do this?

Here is a stripped version of my recursive function...

HRESULT CTree::FillTree(HTREEITEM ParentItem, CTreeCtrl* pTreeToFill,
ComponentOccurrences* pIncomingOccurances)

Result = pIncomingOccurances->get_Count(&nOccMax);

for(long nOccuCount = 1; nOccuCount <= nOccMax;++nOccuCount){

CComPtr pOccu;
CComPtr pOcEn;

HTREEITEM LocalItem;
pOccu = pIncomingOccurances->GetItem(nOccuCount);
strName = (LPCSTR)pOccu->Get_DisplayName();

if(pOccu->GetDefinitionDocumentType() == kAssemblyDocumentObject)
LocalItem = pTreeToFill->InsertItem(strName,0,0,ParentItem);
else
LocalItem = pTreeToFill->InsertItem(strName,1,1,ParentItem);

Result = pOccu->get_SubOccurrences(&pOcEn);
CComQIPtr pOccs(pOcEn);

Result = FillTree(LocalItem, pTreeToFill, pOccs);
}
return Result;
}
0 Likes
251 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Answering to my myself, I found one way by try/error method 🙂 Here it is...

CComPtr pOccu

IDispatch* pIDisp=NULL;
pOccu->GetDefinition()->get_Document(&pIDisp);
DocumentPtr pDocFromOcc(pIDisp);
CString strFullFileName = (LPCSTR)pDocFromOcc->GetFullFileName();

As I'm relatively new to COM programmnig especially with C++ I would
appreciate any comments you might have. Is this the 'right' way of doing
this?



"ML" wrote in message
news:7BCC25B5FBE714BCF1647937F04FEC8A@in.WebX.maYIadrTaRb...
> How can I get the full filename of a part from an Occurance object?
> I need to do this in C++ using Inventor Application object (not
Apprentice,
> but if this can be done differently using Apprentice, by all means tell me
> that also 🙂
>
> I have a recursive function(basically same as the GetOccurancesDispatch
from
> the SDK samples)
> In some cases I need to get the Filename of a part 'behind' the occurance.
> How would I do this?
>
> Here is a stripped version of my recursive function...
>
> HRESULT CTree::FillTree(HTREEITEM ParentItem, CTreeCtrl* pTreeToFill,
> ComponentOccurrences* pIncomingOccurances)
>
> Result = pIncomingOccurances->get_Count(&nOccMax);
>
> for(long nOccuCount = 1; nOccuCount <= nOccMax;++nOccuCount){
>
> CComPtr pOccu;
> CComPtr pOcEn;
>
> HTREEITEM LocalItem;
> pOccu = pIncomingOccurances->GetItem(nOccuCount);
> strName = (LPCSTR)pOccu->Get_DisplayName();
>
> if(pOccu->GetDefinitionDocumentType() == kAssemblyDocumentObject)
> LocalItem = pTreeToFill->InsertItem(strName,0,0,ParentItem);
> else
> LocalItem = pTreeToFill->InsertItem(strName,1,1,ParentItem);
>
> Result = pOccu->get_SubOccurrences(&pOcEn);
> CComQIPtr pOccs(pOcEn);
>
> Result = FillTree(LocalItem, pTreeToFill, pOccs);
> }
> return Result;
> }
>
>
0 Likes