Get Areas of MidSurface Faces (VB.NET)
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.
'--------------------------------
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System
Imports System.Diagnostics
Partial Class SolidWorksMacro
Dim
swModel As ModelDoc2
Dim
swSelMgr As SelectionMgr
Dim
swFace As Face2
Dim
swFeat As Feature
Dim
swMidSurf As MidSurface3
Dim
faces As Object
Dim
count As Integer
Dim
index As Integer
Public
Sub main()
swModel
= swApp.ActiveDoc
swSelMgr
= swModel.SelectionManager
swFeat
= swSelMgr.GetSelectedObject6(1,
-1)
swMidSurf
= swFeat.GetSpecificFeature2()
count
= swMidSurf.GetFaceCount
Debug.Print("Number
of faces for midsurface feature: " & count)
faces
= swMidSurf.GetFaces
For
index = LBound(faces) To UBound(faces)
swFace
= faces(index)
Debug.Print("Area
of face of midsurface feature" & swFace.GetArea)
Next
index
End
Sub
'''
<summary>
'''
The SldWorks swApp variable is pre-assigned for you.
'''
</summary>
Public
swApp As SldWorks
End Class