×
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

Recording a Macro with Renaming

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.

RE: Recording a Macro with Renaming

Option Explicit
'
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

(OP)
Hello AKCalixto,

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

That means you have standard GeoSets in a CATPart and you want to create them with specific names....please try to be a bit more explicit when asking something. I would suggest you to try to modify the AKCalixto code (which is very good, by the way) according to your needs, looking also to the code bellow (is longer but is giving you a clear idea).


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 Sub 

Regards
Fernando

https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU

RE: Recording a Macro with Renaming

(OP)
Hello Ferdo,

Thank you very much.

It works perfect.

RE: Recording a Macro with Renaming

(OP)
I know what you want to say, I am new to VBScript. Not much of a knowledge of programming, that's why i am sorting things out here.

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.

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