×
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

CATIA V5 macro, how to get the current activate sketch

CATIA V5 macro, how to get the current activate sketch

CATIA V5 macro, how to get the current activate sketch

(OP)
Before a macro program begin running, a sketch has be opened. My problem is that how can I get the name of the sketch, and its parent object? In many examples, we use sketch.add(),or a certain name of sketch. But in different situations the opened sketches may have different names.

Any one have faced such problem ?

RE: CATIA V5 macro, how to get the current activate sketch

When then OpenEdition method is called on a Sketch object, it is made the InWorkObject. You can use the InWorkObject property of Part object to retrieve the Sketch feature and access it's Name property.

--Doug

RE: CATIA V5 macro, how to get the current activate sketch

(OP)
Thanks for your suggestion, But I use inworkobject only get the hybridbody under the part,still not get the opened sketch.

RE: CATIA V5 macro, how to get the current activate sketch

or without user interaction:

CODE --> code

Sub CATMain()

CATIA.StartCommand ("No 3D Background")

CATIA.StartCommand ("Fit All In")

Set oSel = CATIA.ActiveDocument.Selection

oSel.Search ("Sketcher.Origin,scr")

Set oSketch = oSel.Item(1).Value.Parent.Parent.Parent

oSel.Clear

MsgBox ("the sketch is " & oSketch.Name)

End Sub 


I'm searching for the Origin so it should be quick, but it should be visible, if not, then search for element type you know is visible then get parent until you get sketch.

Eric N.
indocti discant et ament meminisse periti

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