Get Line Parameters Example (VBA)
This example shows how to get a line's parameters.
'-----------------------------------------
'
' Preconditions: Model document is open and an edge is
selected.
'
' Postconditions: None
'
'------------------------------------------
Option Explicit
Sub main()
Dim
swApp As
SldWorks.SldWorks
Dim
swModel As
SldWorks.ModelDoc2
Dim
swSelMgr As
SldWorks.SelectionMgr
Dim
swEdge As
SldWorks.Edge
Dim
swCurve As
SldWorks.curve
Dim
vLineParam As
Variant
Set
swApp = CreateObject("SldWorks.Application")
Set
swModel = swApp.ActiveDoc
Set
swSelMgr = swModel.SelectionManager
Set
swEdge = swSelMgr.GetSelectedObject5(1)
Set
swCurve = swEdge.GetCurve
vLineParam
= swCurve.LineParams
Debug.Print
"Root Pt =
(" & vLineParam(0) * 1000# & ", " & vLineParam(1)
* 1000# & ", " & vLineParam(2) * 1000# & ")
mm"
Debug.Print
"Direction =
(" & vLineParam(3) & ", " & vLineParam(4) &
", " & vLineParam(5) & ")"
End Sub