Hi,
I am very new to Solidworks. I would like to find the coordinates of a 3D sketch point and have found t
his macro:'--------------------------------------------------------------- Option Explicit Dim swApp As SldWorks.SldWorks Dim Part As SldWorks.ModelDoc2 Dim theSketch As SldWorks.Sketch Dim sketchPointArray As Variant Dim pointCount As Long Dim i As Long Dim xValue As Double Dim yValue As Double Dim zValue As Double Sub main() Set swApp = Application.SldWorks Set Part = swApp.ActiveDoc Set theSketch = Part.GetActiveSketch2 sketchPointArray = theSketch.GetSketchPoints2 pointCount = UBound(sketchPointArray) For i = 0 To pointCount ' Get the coordinates xValue = sketchPointArray(i).X yValue = sketchPointArray(i).Y zValue = sketchPointArray(i).Z Debug.Print i, xValue, yValue, zValue Next i End Sub '----------------------------------------------------------------------
What I did was simple. I just sketch a 3Dsketch point and wanted to run this macro. But no matter what I select and do, there will always be this Run-time error '91' stating object variable or With block variable not set. The debug highlights the line "sketchPointArray = theSketch.GetSketchPoints2".
I am not too sure what it means. I would appreciate any help or advice.
Thank you!
SolidworksApi macros