- 'Preconditions: You have to have a part document open and you can't have a sketch open already.
- Dim swApp As Object
- Dim part As Object
- Dim boolstatus As Boolean
- Sub main()
- Set swApp = Application.SldWorks
- Set part = swApp.ActiveDoc
- boolstatus = part.Extension.SelectByID2("Top Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
- part.SketchManager.InsertSketch True
- part.SetPickMode
- part.ClearSelection2 True
- End Sub
This is a very simple macro for creating a sketch on the Top Plane. So long as you have a part document open, this macro will select the Top Plane
and insert a sketch. It's most useful when the Top Plane is not visible in either the Graphics Area (design space) nor the Feature Manager Design Tree (left pane).
If you want this macro to create a sketch on the Front or Right plane simply change line 11 in the code. Change the word Top in "Top Plane" to Front or Right.
For more simple macro examples check out the DeleteRelations
and DeleteRelations2 macros. They demonstrate how to remove sketch constraints
from inside and outside a sketch respectively.