Rename component in model browser with ilogic after placing component

Rename component in model browser with ilogic after placing component

waynehelley
Collaborator Collaborator
1,151 Views
3 Replies
Message 1 of 4

Rename component in model browser with ilogic after placing component

waynehelley
Collaborator
Collaborator

Does anybody know how to do this??

 

I'm using the following code to place the component with imates and I just need the code to rename components in the model browser.

 

oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oOccEnumerator As ComponentOccurrencesEnumerator
oOccEnumerator = oAsmCompDef.Occurrences.AddUsingiMates("C:\Work\Designs\Products\IEC Switchgear\Low Voltage\09090 IEC Type 439 EuroCentre\"&location & "\" & Busbars & ".iam", False)

 

My part numbers correspond to files names so i know the default name in the browser will be the property 'Busbars' + ":1". for example 09090G00106432:1

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
Accepted solutions (1)
1,152 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

I believe you will need to reference the document to get the browsername (DisplayName). I´m not sure if there is another way but I did it with the document reference.

 

Dim refDocs As DocumentsEnumerator = oInvDoc.AllReferencedDocuments

 

Dim refDoc As Document

 

For Each refDoc In refDocs

     Dim oldDisplayName As String = refDoc.DisplayName

 

oldDisplayName now holds the browsername.

I´m pretty sure that you can get a reference to the document over the ComponentOccurence, take a look at the programming help in Inventor.

 

In my case I´m copying referenced documents in an assembly to a new assembly file with Save As, but I want to keep the old browsernames for iLogic rules so these keep working.

 

refDoc.SaveAs(Path & NewFileName &".iam", False)  / path just leads to the folder where all contents should be saved

                                                                                 / NewFileName is done by User

refDoc.DisplayName = oldDisplayName

 

I copy the whole assembly first and then iterate through all component Occurances. The preceding lines are for component occurances that are assemblies.

For parts it´s pretty much the same.

 

Hope that helps

 

Cheers Falk

0 Likes
Message 3 of 4

waynehelley
Collaborator
Collaborator

Hi falkmassmann,

 

Thanks for you reply but I'm a little lost.

 

I just simply need to rename on instace in the model browser.  I was hoping something simple like this would do it...

 

Component.Name("Old_Component_Name")="New_Component_Name"

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
0 Likes
Message 4 of 4

rjay75
Collaborator
Collaborator
Accepted solution