Get Parameters of Planar Surface Example (VBA)
This example shows how to get the parameters of a planar surface.
'----------------------------------------------
'
' Preconditions:
' (1)
Part, assembly, or drawing document is open.
' (2)
Face of a planar surface is selected.
'
' Postcondition: None
'
'-----------------------------------------------
Option Explicit
Sub main()
Dim
swApp As
SldWorks.SldWorks
Dim
swModel As
SldWorks.ModelDoc2
Dim
swSelMgr As
SldWorks.SelectionMgr
Dim
swFace As
SldWorks.face2
Dim
swSurf As
SldWorks.surface
Dim
vPlane As
Variant
Dim
i As
Long
Dim
bRet As
Boolean
Set
swApp = Application.SldWorks
Set
swModel = swApp.ActiveDoc
Set
swSelMgr = swModel.SelectionManager
Set
swFace = swSelMgr.GetSelectedObject5(1)
Set
swSurf = swFace.GetSurface
If
swSurf.IsPlane Then
vPlane
= swSurf.PlaneParams
Debug.Print
"File = " & swModel.GetPathName
Debug.Print
" normal
=
(" & vPlane(0) & ", " & vPlane(1) & ",
" & vPlane(2) & ")"
Debug.Print
" root
=
(" & vPlane(3) * 1000# & ", " & vPlane(4) *
1000# & ", " & vPlane(5) * 1000# & ") mm"
End
If
End Sub
'----------------------------------------------