Get Areas of MidSurface Faces (VBA)
This example shows how to get the areas of mid-surface faces.
'--------------------------------
' Preconditions: Part document open, and
' part
contains a mid-surface feature, which
' is
selected.
'
' Postconditions: None.
'--------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim Part As SldWorks.ModelDoc2
Dim Faces As Variant
Dim myFace As SldWorks.Face2
Dim selObj As Feature
Dim midSurface As SldWorks.MidSurface3
Dim count As Integer
Dim index As Integer
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set selObj = Part.SelectionManager.GetSelectedObject6(1,
-1)
Set midSurface = selObj.GetSpecificFeature2
count = midSurface.GetFaceCount
Debug.Print "Number of faces for midsurface feature:
" & count
Faces = midSurface.GetFaces
For index = LBound(Faces) To UBound(Faces)
Set myFace = Faces(index)
Debug.Print "Area of face " &
index & " of midsurface feature: " & myFace.GetArea
Next index
End Sub