2. 'Preconditions: You have to have a part document open and you can't have a sketch open already.
  4. Dim swApp As Object
  5. Dim part As Object
  6. Dim boolstatus As Boolean
  8. Sub main()
  9. Set swApp = Application.SldWorks
  10. Set part = swApp.ActiveDoc
  11. boolstatus = part.Extension.SelectByID2("Top Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
  12. part.SketchManager.InsertSketch True
  13. part.SetPickMode
  14. part.ClearSelection2 True
  15. 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.