AnsweredAssumed Answered

Getting all sketch points.

Question asked by Sushil Chaskar on Jun 24, 2014
Latest reply on Jun 28, 2014 by Sushil Chaskar

I am trying to get sketpoints of all the sketches on model doc.  For that I need to select all sketches first and then all sketch points on each sketch.. I am able to get sketch point for one sketch but can not for all sketches. I dont know the general method that will select all sketches. I have tried to some extent. plz help out .. Posting my code..

I am facing problems in the bolded lines as i am not aware how to define them..

 

 

 

Option Explicit

Sub main()

Dim swApp As SldWorks.SldWorks

Dim Part As SldWorks.PartDoc

Dim theSketch As SldWorks.Sketch

Dim sketchPointArray As Variant

Dim sketchArray As Variant

Dim i As Long

Dim swSel As SldWorks.SelectionMgr

Dim pointCount As Long

Dim xValue As Double

Dim yValue As Double

Dim zValue As Double

Dim swModelext As SldWorks.ModelDocExtension

Dim swSketchMgr As SldWorks.SketchManager

Dim bValue As Boolean

Dim v As Variant

Dim Sketch As Variant

' Set swApp = CreateObject("SldWorks.Application")

Set swApp = Application.SldWorks

 

 

Set Part = swApp.ActiveDoc

Set swModelext = Part.Extension

Set swSel = Part.SelectionManager

 

 

' swModelext.SelectAll

 

 

Set swSketchMgr = Part.SketchManager

 

 

 

 

' Part.ClearSelection2 True

'Set theSketch = Part.GetActiveSketch2

' v = Part.GetBodies

' If theSketch Is Nothing Then

 

 

 

Dim j As Integer

For j = o to UBound() 

 

 

bValue = Part.Extension.SelectByID2(Sketch(j), "SKETCH", 0, 0, 0, False, 0, Nothing, 0)

swSketchMgr.InsertSketch False

Set theSketch = Part.GetActiveSketch2

' sketchArray() = theSketch

    ' Activate the sketch

sketchPointArray = theSketch.GetSketchPoints2

pointCount = UBound(sketchPointArray) + 1

' For each SketchPoint

For i = 0 To (pointCount - 1)

    ' Get the coordinates

    xValue = sketchPointArray(i).X

    yValue = sketchPointArray(i).Y

    zValue = sketchPointArray(i).Z

    Debug.Print "Sketch point x ,y and z coordinates: " & xValue; yValue; "and " & zValue

    Debug.Print " "

    ' Do something useful with the data

Next i

Next j

' End If

End Sub

Outcomes