Instance name alteration Macro in CATIA V5
Instance name alteration Macro in CATIA V5
(OP)
Hi everyone,
I need to make a macro to alter the instance name of selected accessories in several assemblies and sub assemblies using input boxes in CATIA V5. i'm fairly new to CATIA and CATScript and need help with this macro because it doesn't work in sub assemblies.
Can someone please help me?
I've gotten this far using the internet and several macros that i found and tweaked. and this thread really helped me thread560-340850: Macro to Change Part Number and Instance Name to File Name, but i can't go any further on my own.
The macro is written in CATScript.
Thanks in advance.
Sub CATMain()
Dim oSelection As Selection
Set oSelection = CATIA.ActiveDocument.Selection
If oSelection.Count < 1 then
MsgBox "Pick some ejectors using cad selection."
Else
'****** Inputbox for Instance name alteration *****
Dim NewIName As String
NewIName = InputBox("Please input the desired Instance Name. Example: E","Instance name alteration","E")
'****** Inputbox for instance number increment *****
Dim NewINumber As Integer
NewINumber = InputBox("Please input the initial number for the 1st ejector. Example: 1","Instance numbering alteration","1")
Dim oBody
Dim InstName As Body
For oBody = 1 to oSelection.Count
Set InstName = oSelection.Item(oBody).Value
'****** Instance name alteration *****
InstName.Name= NewIName & NewINumber
NewINumber=NewINumber+1
Next
End if
End Sub
I need to make a macro to alter the instance name of selected accessories in several assemblies and sub assemblies using input boxes in CATIA V5. i'm fairly new to CATIA and CATScript and need help with this macro because it doesn't work in sub assemblies.
Can someone please help me?
I've gotten this far using the internet and several macros that i found and tweaked. and this thread really helped me thread560-340850: Macro to Change Part Number and Instance Name to File Name, but i can't go any further on my own.
The macro is written in CATScript.
Thanks in advance.
Sub CATMain()
Dim oSelection As Selection
Set oSelection = CATIA.ActiveDocument.Selection
If oSelection.Count < 1 then
MsgBox "Pick some ejectors using cad selection."
Else
'****** Inputbox for Instance name alteration *****
Dim NewIName As String
NewIName = InputBox("Please input the desired Instance Name. Example: E","Instance name alteration","E")
'****** Inputbox for instance number increment *****
Dim NewINumber As Integer
NewINumber = InputBox("Please input the initial number for the 1st ejector. Example: 1","Instance numbering alteration","1")
Dim oBody
Dim InstName As Body
For oBody = 1 to oSelection.Count
Set InstName = oSelection.Item(oBody).Value
'****** Instance name alteration *****
InstName.Name= NewIName & NewINumber
NewINumber=NewINumber+1
Next
End if
End Sub





RE: Instance name alteration Macro in CATIA V5
inside your
CODE --> code
indocti discant et ament meminisse periti
RE: Instance name alteration Macro in CATIA V5
Take a look at my macro here for using a recursive function to change instance names in sub assemblies:
thread560-365400: [Macro Catia ] Rename all instances and references
Drew Mumaw
https://textsketcher.com/
https://drewmumaw.com/
RE: Instance name alteration Macro in CATIA V5
thanks for your reply.
I've tried to include the recursive more recursive code, but i can't seem to work it out.
Can you help me with this?
RE: Instance name alteration Macro in CATIA V5
I've looked at your thread but as i mentioned in my original post i don't know where or even what to include in my code.
Can you please help me?