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: 

Change parameters in a part occurrence which is inside an assembly

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
oransen
668 Views, 6 Replies

Change parameters in a part occurrence which is inside an assembly

I have an assembly which contains a CComPtr<ComponentOccurrence> pThisCompOcc , and I'd like to do two things.

 

  1. Get the name of the "base" object, not the display name of the occurence
  2. Change the model and user parameter values of the occurrence

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 ?

 

 

 

6 REPLIES 6
Message 2 of 7
oransen
in reply to: oransen

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.

Message 3 of 7
Vladimir.Ananyev
in reply to: oransen

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.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 4 of 7
oransen
in reply to: Vladimir.Ananyev

Thanks for that, I'll have to see if I can translate it properly into C++!

 

 

Message 5 of 7
oransen
in reply to: Vladimir.Ananyev

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...

 

 

Message 6 of 7
adam.nagy
in reply to: oransen

Hi,

 

Have just written a blog post about this: http://adndevblog.typepad.com/manufacturing/2013/09/cast-between-com-types-in-c.html

 

Cheers,



Adam Nagy
Autodesk Platform Services
Message 7 of 7
oransen
in reply to: adam.nagy

Thanks!

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

Post to forums  

Autodesk Design & Make Report