Get Sketch Points Example (VBA)
This example shows how to loop through the
active sketch and extract the X,Y values of every sketch point.
'------------------------------------------------------------
Dim swApp As
Object
Dim Part As
Object
Dim sketchPointArray
As Variant
' Optional
Dim theSketchPoint
As Object
Dim pointCount
As Integer
Dim xValue As
Double
Dim yValue As
Double
Dim zValue As
Double
Set swApp =
CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
Set theSketch
= Part.GetActiveSketch2
sketchPointArray
= theSketch.GetSketchPoints2
pointCount =
UBound(sketchPointArray) + 1
For i = 0 To
(pointCount - 1)
' Set theSketchPoint
= sketchPointArray(i)
xValue = sketchPointArray(i).X
yValue = sketchPointArray(i).Y
zValue = sketchPointArray(i).Z
Next i
End Sub