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: 

Rename component in model browser with ilogic after placing component

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
waynehelley
1015 Views, 3 Replies

Rename component in model browser with ilogic after placing component

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
Tags (1)
3 REPLIES 3
Message 2 of 4
falkmassmann
in reply to: waynehelley

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

Message 3 of 4
waynehelley
in reply to: falkmassmann

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
Message 4 of 4
rjay75
in reply to: waynehelley

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

Post to forums