Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

CATIA Macro apply materials and rename parts

Status
Not open for further replies.

elmundo777

Automotive
Jun 23, 2020
93
0
0
BY
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?

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

error_rename_hfoo9g.png


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

mats_kjrzih.png
 
Status
Not open for further replies.
Back
Top