I have an assembly which contains a CComPtr<ComponentOccurrence> pThisCompOcc , and I'd like to do two things.
I suspect that I need to find the function or method which gives me a CComPtr<PartComponentDefinition> pPartCompDef which the occurrence points to for the Q1, but what about Q2?
Presumably the parameters are associated with the ComponentOccurrence and the "real" name is associated with the PartComponentDefinition?
Anyway, does anyone know how I do 1 and 2 ?
Solved! Go to Solution.
Solved by adam.nagy. Go to Solution.
Ok, rummaging around I've found out how to find the name of the "base part", by using a ReferencedFileDescriptor:
CComPtr<ReferencedFileDescriptor> pRefFileDesc = nullptr ; pThisCompOcc->get_ReferencedFileDescriptor (&pRefFileDesc) ; CComBSTR bstrDisplayName; pRefFileDesc->get_DisplayName (&bstrDisplayName) ; wprintf (L"Component occurence %02d <%s>\n",lOccCount,bstrDisplayName); ::SysFreeString (bstrDisplayName) ;
But I'm still wondering how to change the parameters of that "inserted instance" of the part.
The key object is the occurrence definition. Having definition you may get references to the "base" document, properties, parameters, etc.:
ComponentOccurrence.Definition.Document property returns the reference to the Document object (PartDocument, AssemblyDocument).
ComponentOccurrence.Definition.Parameters property returns the reference to the parameters collection.
Thanks for that, I'll have to see if I can translate it properly into C++!
I've not been able to translate the VB example into C++. I cannot find the get_Parameters function in the ComponentDefinition pointer:
CComPtr<ComponentOccurrence> pCompOcc = ... ; CComPtr<ComponentDefinition> pCompRef = nullptr ; pCompOcc->get_Definition (&pCompRef) ; pCompRef-> // which function do I call here to get the parameters?
So I'm still not able to get the parameters of the Occurrence...
Hi,
Have just written a blog post about this: http://adndevblog.typepad.com/manufacturing/2013/09/cast-between-com-types-in-c.html
Cheers,