Get Parameters of Cylindrical Surface Example (VBA)
This example shows how to get the origin, axis, and radius for the selected
cylindrical surface.
'----------------------------------
'
' Preconditions: Model document is open and a cylindrical
surface is selected.
'
' Postconditions: 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
vCylinder As
Variant
Dim
i As
Long
Dim
bRet As
Boolean
Set
swApp = CreateObject("SldWorks.Application")
Set
swModel = swApp.ActiveDoc
Set
swSelMgr = swModel.SelectionManager
Set
swFace = swSelMgr.GetSelectedObject5(1)
Set
swSurf = swFace.GetSurface
If
swSurf.IsCylinder Then
vCylinder
= swSurf.CylinderParams
Debug.Print
"origin =
(" & vCylinder(0) * 1000# & ", " & vCylinder(1)
* 1000# & ", " & vCylinder(2) * 1000# & ")
mm"
Debug.Print
"axis =
(" & vCylinder(3) & ", " & vCylinder(4) &
", " & vCylinder(5) & ")"
Debug.Print
"radius =
" & vCylinder(6) * 1000# & " mm"
End
If
End Sub