Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IN C++ : Given a component occurrence how to get the part document. IN C++

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
oransen
698 Views, 2 Replies

IN C++ : Given a component occurrence how to get the part document. IN C++

It must be because it is Monday morning, but given a component occurrence how to get the part document of that occurrence.

 

VB examples will NOT help me.

 

In other words I have this:

 

CComPtr<ComponentOccurrence> pCompOcc = ...

 

and I would like to get one of these:

 

CComQIPtr<PartDocument> pPartDoc = ...

 

I've searched, even "advanced exact" searched, and I can't find an example of how to do it.

 

VB examples will NOT help me.

 

A C++ example would be ideal.

 

 

 

 

 

2 REPLIES 2
Message 2 of 3
philippe.leefsma
in reply to: oransen

Hi

 

Try this:

 

CComPtr<Document> pDoc;
HRESULT hr = pInventorApp->get_ActiveDocument(&pDoc);

CComPtr<AssemblyDocument> pAsmDoc;
pAsmDoc = CComQIPtr<AssemblyDocument>(pDoc);

CComPtr<AssemblyComponentDefinition> pAsmCompDef;
pAsmCompDef = CComQIPtr<AssemblyComponentDefinition>(pAsmDoc->ComponentDefinition);

CComPtr<ComponentOccurrences> pOccurrences = pAsmCompDef->Occurrences;

int i = 1;

CComPtr<ComponentOccurrence> pCompOcc;
pOccurrences->get_Item(i, &pCompOcc);

CComPtr<PartComponentDefinition> pCompDef;
pCompDef = CComQIPtr<PartComponentDefinition>(pCompOcc->Definition);

CComPtr<PartDocument> pPartDoc = CComQIPtr<PartDocument>(pCompDef->Document);

BSTR bstrFileName = NULL;
hr = pPartDoc->get_FullFileName(&bstrFileName);

Between, I strongly suggest you take time to understand how to convert VB.Net / VBA / C# into C++ because the API is the same and most of our samples are written in those languages. Once you got it, it's pretty straightforward to translate fom those to C++ syntax.

 

Regards,

Philippe.

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
oransen
in reply to: philippe.leefsma

Thanks for the reply. I can normally do the conversion from VB to C++, but for some reason this time I couldn't!

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report