Dim oOcc As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select Component")
If oOcc Is Nothing Then Exit Sub
Dim oDoc As Document = oOcc.Definition.Document
Dim oLUCY As String = oDoc.Componentdefinition.Parameters("LUCY").Value
Dim oL_R As String = oDoc.Componentdefinition.Parameters("L_R").Value
oDoc.DisplayName = oLUCY & "/" & oL_R
Hi, if you look at your part code image LUCY and L_R have a bluish color. Because ilogic is identifying that in that part file there is a parameter with that name and associates it directly with it.
When you are in an assembly you do not have those parameters. Those parameters are in the part. Then you have to access the part first and then define the part's parameter.
In the following code I share an example. You take an assembly, then you execute the rule. Now you select the part you want (the part must have the parameters LUCY and L_R respectively, if you do not have the parameters it will give an error because you will not find them) The code will change the display name as you have requested in the code.
Keep in mind that this will change the displayname of the part, it will not change the browser node, that is, its appearance in the browser.
I hope this helps greetings
Please accept as solution and give likes if applicable.
I am attaching my Upwork profile for specific queries.
Sergio Daniel Suarez
Mechanical Designer
| Upwork Profile | LinkedIn