Recording a Macro with Renaming
Recording a Macro with Renaming
(OP)
Hi all,
I am trying to generate a macro with renaming feature in CATIA but it seems like macro skips the part of renaming and moves on.
Is there any way to do it?
example what i am doing :
I generate different Geometrical Sets, I rename them to A, B and C and record the macro. When i run the macro it works fine but it creates Geo Sets with Geometrical Set 1, 2 and so on.
Can any body tell me how to overcome this problem ?
Your help is of great importance to me.
I am trying to generate a macro with renaming feature in CATIA but it seems like macro skips the part of renaming and moves on.
Is there any way to do it?
example what i am doing :
I generate different Geometrical Sets, I rename them to A, B and C and record the macro. When i run the macro it works fine but it creates Geo Sets with Geometrical Set 1, 2 and so on.
Can any body tell me how to overcome this problem ?
Your help is of great importance to me.





RE: Recording a Macro with Renaming
'
Sub CATMain()
'
Dim CatPart As Part, CatHybridBodies As HybridBodies, CatHybridBody As HybridBody, i As Integer
'
Set CatPart = CATIA.ActiveDocument.Part
Set CatHybridBodies = CatPart.HybridBodies
'
For i = 1 To 10
Set CatHybridBody = CatHybridBodies.Add()
CatHybridBody.Name = Chr(64 + i)
Next i
'
CatPart.Update
'
End Sub
RE: Recording a Macro with Renaming
Thank you so much for you kind reply.
I am stiff confused because what if I want to rename the geometrical sets to something like From Boss, Part Geometry and Cutting Direction ?
RE: Recording a Macro with Renaming
CODE --> CATSCript
Language="VBSCRIPT" Sub CATMain() 'Works in an active CATPart, create new specific named geometrical sets Dim oPartDoc As Part On Error Resume Next Set oPartDoc = CATIA.ActiveDocument.Part If Err.Number <> 0 Then Message = MsgBox("Sorry, This script works with a CATPart as Active document, so please open CATPart in a new window", vbCritical, "Error") Exit Sub End If Dim partDocument1 As Document Set partDocument1 = CATIA.ActiveDocument Dim part1 As Part Set part1 = partDocument1.Part Dim HB0,HB1,HB2 As HybridBodies Set HB0 = CATIA.ActiveDocument.part.HybridBodies Set HB1 = CATIA.ActiveDocument.part.HybridBodies Set HB2 = CATIA.ActiveDocument.part.HybridBodies Set HB0 = HB0.Add() Set HB1 = HB1.Add() Set HB2 = HB2.Add() HB0.Name = "From Boss" HB1.Name = "Part Geometry" HB2.Name = "Cutting Direction" Dim bodies1 As Bodies Set bodies1 = part1.Bodies Dim body1 As Body Set body1 = bodies1.Item("PartBody") part1.InWorkObject = body1 part1.Update End SubRegards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Recording a Macro with Renaming
Thank you very much.
It works perfect.
RE: Recording a Macro with Renaming
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Recording a Macro with Renaming
You might wanna give a reply on the following thread also.
http://www.eng-tips.com/viewthread.cfm?qid=381425
I would really appreciate ur input.