elmundo777
Automotive
- Jun 23, 2020
- 93
Hi all. I have two questions.
First question: there is a macro that renames the product structure in a loop. But if the parts were copied, then the names are duplicated with each step of the loop. Can be seen in the attached picture. How to avoid it?
The second question: how to assign a material to each body in a part in a cycle?
First question: there is a macro that renames the product structure in a loop. But if the parts were copied, then the names are duplicated with each step of the loop. Can be seen in the attached picture. How to avoid it?
Code:
For Each Item In myPrd.Products 'Documents
Nber_Item = myPrd.UserRefProperties.Count
'''' ' MessageBox.Show(Nber_Item)
name = myPrd.Products.Item(Item).PartNumber
'''''MessageBox.Show(name)
iteration = myPrd.Products.Item(Item).ReferenceProduct.UserRefProperties.Item(1).ValueAsString
'' 'MessageBox.Show(iteration)
Status = myPrd.Products.Item(Item).ReferenceProduct.UserRefProperties.Item(3).ValueAsString
WC_number = myPrd.Products.Item(Item).ReferenceProduct.UserRefProperties.Item(5).ValueAsString
revision = myPrd.Products.Item(Item).ReferenceProduct.UserRefProperties.Item(7).ValueAsString
' MessageBox.Show(myPrd.Products.Item(Item).Name)
If (CheckBox_STATUS.Checked = True) Then
rename = WC_number & "_" & revision & "_" & iteration & "_" & Status & "_" & name
Else
rename = WC_number & "_" & revision & "_" & iteration & "_" & name
End If
' renaming of the part
myPrd.Products.Item(Item).PartNumber = rename
myPrd.Products.Item(Item).Name = rename
Next

The second question: how to assign a material to each body in a part in a cycle?
