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
Solved! Go to Solution.
Solved by rjay75. Go to Solution.
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
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"
Here you go.
Component.InventorComponent("default_name").Name = "new_name"