Change parameters in a part occurrence which is inside an assembly

Change parameters in a part occurrence which is inside an assembly

oransen
Collaborator Collaborator
964 Views
6 Replies
Message 1 of 7

Change parameters in a part occurrence which is inside an assembly

oransen
Collaborator
Collaborator

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 ?

 

 

 

0 Likes
Accepted solutions (1)
965 Views
6 Replies
Replies (6)
Message 2 of 7

oransen
Collaborator
Collaborator

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.

0 Likes
Message 3 of 7

Vladimir.Ananyev
Alumni
Alumni

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

0 Likes
Message 4 of 7

oransen
Collaborator
Collaborator

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

 

 

0 Likes
Message 5 of 7

oransen
Collaborator
Collaborator

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

 

 

0 Likes
Message 6 of 7

adam.nagy
Autodesk Support
Autodesk Support
Accepted solution

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
Collaborator
Collaborator
Thanks!
0 Likes