Assuming you have the sketch pointer (as a Sketch object),
Cast it to a Feature object and then use Feature.Select2
Dim mySketch as Sketch
Dim myFeat as Feature
...do something to populate mySketch...
Set myFeat = mySketch
myFeat.Select2 False, 0
Here is another way:
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
swModel.Extension.SelectByID2 "Sketch Name Here", "SKETCH", 0, 0, 0, False, 0, Nothing, 0
I have tried this code. But it is not working. Will you please help me on this. I want to select a 2D sketch which is already drawn.
Did you changed the sketch name in the codes above? Also do you to select the sketch in part or assembly?
No. I didn't changed it before. Now it is okay.
Can it be used to made a solid model by adding two sketches? Select one sketch as profile & other as guide curve.
Yes but you need to set mark for the selection so that sweep feature can recognize them correctly. Look in SW API help files for more info.