Change iAssembly member of AssemblyDocument Not ComponentOccurrence

Change iAssembly member of AssemblyDocument Not ComponentOccurrence

TylerWarner33
Contributor Contributor
187 Views
4 Replies
Message 1 of 5

Change iAssembly member of AssemblyDocument Not ComponentOccurrence

TylerWarner33
Contributor
Contributor

Is there a way to change the active iAssemblyMember of an AssemblyDocument using the API?

AssemblyDocument.ComponentDefinition.iAssemblyFactory has a method 'CreateMember' but it is a void return type even though it says it should return the member.

AssemblyDocument.ComponentDefinition.iAssemblyMember has a method 'Row' but it is read-only.


iPartFactory has a method 'CreateMember' that actually returns the member but I don't know how to get to the object from the AssemblyDocument.

iPartFactory has a method 'ChangeRow' but I don't know how to get to the object from the AssemblyDocument.


This post shows the result but using an iLogic snippet.

0 Likes
Accepted solutions (2)
188 Views
4 Replies
Replies (4)
Message 2 of 5

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @TylerWarner33,

 

Hope you're doing well!

 

ChangeRowOfiAssemblyMember is a method of ComponenOccurrence, so we just need to get the occurrence of the placed iAssembly and then we can change the member row.

 

Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oOccs As ComponentOccurrences = oDoc.ComponentDefinition.Occurrences
Dim oOcc As ComponentOccurrence = oOccs.ItemByName("Frame_iAssembly")
oOcc.ChangeRowOfiAssemblyMember(2)

 

Hope that helps,

Curtis

EESignature

Message 3 of 5

TylerWarner33
Contributor
Contributor

Hey @Curtis_Waguespack, thanks, I hope you're doing well, too!

Cool, I'm using a similar method (AssemblyDocument.ComponentDefinition.Occurrences.AddiAssemblyMember()) in other parts of the application.


But, if the active document is "MainAssembly" which is the iAssembly, when I go through the occurrences in the component definition of that document, the "MainAssembly" is not listed. It seems like I would have to add the iAssembly to a different AssemblyDocument as an occurrence. Looking back at the post above using iLogic, that is what the iLogic snippet is doing.

This workflow is possible, just wanted to see if I could skip a few steps & work with the iAssembly AssemblyDocument directly.

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor
Accepted solution

I believe you would just need to set the iAssemblyFactory.DefaultRow property value to a new value, then that will change which 'member' is the active member in the active iAssembly.  It sounds like you already know how to get there, but it is right under the AssemblyComponentDefinition.iAssemblyFactory property.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 5

TylerWarner33
Contributor
Contributor

Thanks @WCrihfield, that looks like it will do it, not sure how I missed that one haha!

0 Likes