Select the Midpoint of an Edge Example (VBA)
This example shows how to select the midpoint of an edge.
'----------------------------------------------------------------------------
' Preconditions:
' 1. Open a part document.
' 2. Select an edge.
'
' Postconditions: A midpoint is placed on the selected edge.
'----------------------------------------------------------------------------
Option Explicit
Const swSelEDGES
As Long = 1
Const swSelREFERENCECURVES
As Long = 26
Const swSelPOINTREFS
As Long = 41
Const swSelREFEDGES
As Long = 51
Sub main()
Dim swApp
As SldWorks.SldWorks
Dim swModel
As SldWorks.ModelDoc2
Dim swPart
As SldWorks.PartDoc
Dim swSelMgr
As SldWorks.SelectionMgr
Dim nSelType
As Long
Set swApp = CreateObject("SldWorks.Application")
Set swModel = swApp.ActiveDoc
Set swPart = swModel
Set swSelMgr = swModel.SelectionManager
nSelType = swSelMgr.GetSelectedObjectType3(1,
-1)
Debug.Print "SelType (before) = " + Str(nSelType)
swModel.SelectMidpoint
nSelType = swSelMgr.GetSelectedObjectType3(1,
-1)
Debug.Print "SelType (after ) = " + Str(nSelType)
End Sub