Please see this VBA macro...
I can't figure out how to select the first point by using the ID and sketch name....
This should be simple...
Please someone help.
Thanks... Richard
==========================================
== Copy and past below. Run this macro in a part. Nothing selected
===========================================
Option Explicit
Dim swApp As Object
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swSketchMgr As SldWorks.SketchManager
Dim swSelMgr As SldWorks.SelectionMgr
Dim swSelData As SldWorks.SelectData
Dim skLine As SldWorks.SketchLine
Dim skPoint As Object
Dim vSketchPtID As Variant
'make a storage structure
Public Type PointStore
id0 As Long
id1 As Long
skName As String
X As Double
Y As Double
Z As Double
End Type
Dim mySavedPoint As PointStore
Dim boolstatus As Boolean
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSketchMgr = swModel.SketchManager
' make a new blank Sketch
swSketchMgr.Insert3DSketch True
'make a point in the sketch and add fix relation
Set skPoint = swModel.SketchManager.CreatePoint(2.3, 3.3, 1.25)
swModel.SketchAddConstraints "sgFIXED"
vSketchPtID = skPoint.GetID
mySavedPoint.id0 = vSketchPtID(0)
mySavedPoint.id1 = vSketchPtID(1)
mySavedPoint.skName = swSketchMgr.ActiveSketch.Name
mySavedPoint.X = skPoint.X
mySavedPoint.Y = skPoint.Y
mySavedPoint.Z = skPoint.Z
'close this sketch
swSketchMgr.Insert3DSketch True
swModel.ClearSelection2 True
'create new 3DSketch
swSketchMgr.Insert3DSketch True
Set swSelMgr = swModel.SelectionManager
Set swSelData = swSelMgr.CreateSelectData
' Draw a line ..
Set skLine = swSketchMgr.CreateLine(mySavedPoint.X, mySavedPoint.Y, mySavedPoint.Z, 5#, 5#, 5#)
'select the line just created's endpoint
'
boolstatus = skLine.GetStartPoint2.Select4(False, swSelData)
'Or other end '''boolstatus = skLine.GetEndPoint2.Select4(True, swSelData)
' So now the line endpoint is selected.
' And I have the persistant data from the first sketch's point...
Debug.Print mySavedPoint.skName & vbCrLf & "IDPt = [" & _
mySavedPoint.id0 & ", " & _
mySavedPoint.id1 & "]" & vbCrLf & _
"Cordinate (" & mySavedPoint.X * 1000# & ", " & _
mySavedPoint.Y * 1000# & ", " & _
mySavedPoint.Z * 1000# & ") mm "
''' How to add this point to the selection set and make the 2 coincident??
MsgBox ("How now to select the first sketch point and make coincident?")
swModel.ClearSelection2 True
swSketchMgr.Insert3DSketch True
End Sub
SolidworksApi macros