MerolaAlba
Automotive
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, 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, 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