Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations SSS148 on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

catia macro: change instance names in selected objects 1

Status
Not open for further replies.

elmundo777

Automotive
Jun 23, 2020
93
Hello. I have been looking for a solution for a long time here and other resources, but I have not found a solution.

Essence of the question:: there are selected objects - parts or products. I need to change their PartNumbers and InstanceNames. The partnumber can be changed. But the instance does not come out. I don't know how to do it if the object is in level 2,3,4, etc.
For example, like the part in the picture below:
multilevel_mpumrm.png


Tried the following code:

Code:
Dim i as Single
dim selection2 as Selection = Catia.ActiveDocument.Selection
 for i = 1 To selection2.count2
  selection2.Item(i).Value.Name= selection2.item(i).Value.PartNumber & "_" & i 
 Next i

And this

Code:
selection2.Item(i).Value.Name= selection2.item(i).LeafProduct.PartNumber & "_" & i
and etc


but did not understand how to change the instance name in distant levels
 
Replies continue below

Recommended for you

Code:
dim Inst_Name = selection2.Item(i).Value.Name
gives me the InstanceName correctly

But when I want to change this name nothing happens
Code:
dim Part_Number_Name = selection2.Item(i).LeafProduct.ReferenceProduct.Name
selection2.Item(i).Value.Name = Part_Number_Name + ".1"

where is the mistake?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor