AnsweredAssumed Answered

Sketch defaults to Front Plane (VBA)

Question asked by Benjamin Danard on Aug 24, 2016
Latest reply on Aug 24, 2016 by Benjamin Danard

Hello everyone,

 

I'm writing a program in VBA that takes an XYZ table, draws lines in Solidworks, adds a radius and extrudes a circle over the path.

I've programmed everything, but I am running into an issue with sketch orientation.

 

I need to change which plane the profile circle is drawn on depending on the orientation of my path. Every time I try to use a Macro the sketch defaults to the front plane. Even when I record the Macro it will only draw the circles on the front plane. I've tried using 3D sketches as well, but that doesn't work.

 

Am I missing something?

 

Below is the macro I recorded. When I run it I get both circles on the front plane.

 

Dim swApp As Object

Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long

 

Sub main()

Set swApp = _
Application.SldWorks

Set Part = swApp.ActiveDoc
Part.SketchManager.Insert3DSketch True
Dim skSegment As Object
Set skSegment = Part.SketchManager.CreateCircle(0#, 0#, 0#, -0.030076, -0.049493, 0#)
Part.ClearSelection2 True
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
Part.SketchManager.Insert3DSketch True
Part.SketchManager.InsertSketch True
boolstatus = Part.Extension.SelectByID2("Right Plane", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
Set skSegment = Part.SketchManager.CreateCircle(-0#, 0#, 0#, -0.125438, 0.0187, 0#)
Part.ClearSelection2 True
Part.SketchManager.InsertSketch True
Part.ClearSelection2 True
End Sub

Outcomes