Get Edge Curve Parameterization Example (VBA)
This example shows how to get the edge curve parameterization for the
selected edge using IEdge::GetCurveParams2.
'-----------------------------------------------
'
' Preconditions:
' (1)
Part or assembly is open.
' (2)
If an assembly, it is fully resolved.
' (3)
An edge is selected in the SolidWorks graphics area.
'
' Postconditions: None
'
'-----------------------------------------------
Option Explicit
Public Const LINE_TYPE As
Integer = 3001
Public Const CIRCLE_TYPE As
Integer = 3002
Public Const ELLIPSE_TYPE As
Integer = 3003
Public Const INTERSECTION_TYPE As
Integer = 3004
Public Const BCURVE_TYPE As
Integer = 3005
Public Const SPCURVE_TYPE As
Integer = 3006
Public Const CONSTPARAM_TYPE As
Integer = 3008
Public Const TRIMMED_TYPE As
Integer = 3009
' Define two types
Type DoubleRec
dValue
As Double
End Type
Type Long2Rec
iLower
As Long
iUpper
As Long
End Type
' Extract two integer values out of a single double value,
' by assigning a DoubleRec to the double value and
' copying the value over an Long2Rec and
' extracting the integer values.
Function ExtractFields _
( _
ByVal
dValue As Double, _
iLower
As Long, _
iUpper
As Long _
)
Dim
dr As
DoubleRec
Dim
i2r As
Long2Rec
'
Set the double value
dr.dValue
= dValue
'
Copy the values
LSet
i2r = dr
'
Extract the values
iLower
= i2r.iLower
iUpper
= i2r.iUpper
End Function
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
vCurveParam As
Variant
Dim
nDummy As
Long
Dim
nIdentity As
Long
Dim
nTag As
Long
Dim
nSense As
Long
Set
swApp = CreateObject("SldWorks.Application")
Set
swModel = swApp.ActiveDoc
Set
swSelMgr = swModel.SelectionManager
Set
swEdge = swSelMgr.GetSelectedObject5(1)
Set
swCurve = swEdge.GetCurve
vCurveParam
= swEdge.GetCurveParams2
ExtractFields
vCurveParam(8), nDummy, nIdentity
ExtractFields
vCurveParam(9), nDummy, nTag
ExtractFields
vCurveParam(10), nDummy, nSense
Debug.Print
"Start =
(" & vCurveParam(0) * 1000# & ", " & vCurveParam(1)
* 1000# & ", " & vCurveParam(2) * 1000# & ")
mm "
Debug.Print
"End =
(" & vCurveParam(3) * 1000# & ", " & vCurveParam(4)
* 1000# & ", " & vCurveParam(5) * 1000# & ")
mm "
Debug.Print
"Uparam =
[" & vCurveParam(6) & ", " & vCurveParam(7)
& "]"
Debug.Print
"Identity =
" & nIdentity
Debug.Print
"Tag =
" & nTag
Debug.Print
"Sense =
" & nSense
'
Derived quantity
Debug.Print
"Length =
" & swCurve.GetLength2(vCurveParam(6),
vCurveParam(7)) * 1000# & " mm "
End Sub
'-------------------------------------------