×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Renaming the instances in CATIA using macro

Renaming the instances in CATIA using macro

Renaming the instances in CATIA using macro

(OP)
Hi,

I have a requirement where in, I want to rename the instances automatically using MACRO, when I replace a part in Assembly.
Can anyone please provide a code or programme for it. Below is one code I got in this website itself, Does it serve my purpose?

Sub CATMain()

Dim documentlist
Dim MainProduct As Product
Dim MainDocument As ProductDocument

Set documentlist = CATIA.Documents
Set MainDocument = CATIA.ActiveDocument
Set oTopProduct = MainDocument.Product

If (InStr(MainDocument.Name, "CATProduct") <> 0) Then
Call RenameSingleLevelProduct(oTopProduct)
Else
MsgBox "Active document should be a Product"
Exit Sub
End If

End Sub

Sub RenameSingleLevelProduct(oTopProduct)

Dim ItemToRename As Product
Dim ItemToRenamePartNumber As String
Dim lNumberOfItems As Long
Dim myArray(4000) As String
Dim i, j, k As Integer

lNumberOfItems = oTopProduct.Products.Count
For i = 1 to lNumberOfItems
myArray(i) = ""
Next
For i = 1 to lNumberOfItems
Set ItemToRename = oTopProduct.Products.Item(i)
k = 0
'Rename Instance
ItemToRenamePartNumber = ItemToRename.PartNumber
myArray(i) = ItemToRenamePartNumber
For j = 1 to i
If myArray(j) = ItemToRenamePartNumber Then
k = k + 1
End If
Next
ItemToRename.Name = ItemToRenamePartNumber & "." & k
If (ItemToRename.Products.Count <> 0) Then
Call RenameSingleLevelProduct(ItemToRename.ReferenceProduct)
End If
Next
End Sub

How to incorporate the code into catia in the form of macro ?

RE: Renaming the instances in CATIA using macro

Hi,

First you should look at the thread where you copied this code and see what is written there, is a code for catvba or for CATScript, there are limitations or not. If you will point us with a link to that thread we could help more, no one will give an answer loosing time to try different solutions for you.

We can help but you need to give us as much details you can.

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources