Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

CATIA V5 macro, how to get the current activate sketch

Status
Not open for further replies.

Arichzhy

Automotive
Aug 20, 2016
8
CN
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 ?
 
Replies continue below

Recommended for you

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
 
Thanks for your suggestion, But I use inworkobject only get the hybridbody under the part,still not get the opened sketch.
 
or without user interaction:

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top