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.
Solved! Go to Solution.
Solved by philippe.leefsma. Go to Solution.
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.
Thanks for the reply. I can normally do the conversion from VB to C++, but for some reason this time I couldn't!