Get Section Properties for Planar Faces Example (VBA)
This example shows how to get section properties for planar faces.
'----------------------------------------------------
'
' Preconditions: A part is open that has at least three
planar faces.
'
' Postconditions: None
'
'-----------------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModelDoc As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swSelMgr As SldWorks.SelectionMgr
Dim boolstatus As Boolean
Sub main()
Set swApp = Application.SldWorks
Set swModelDoc = swApp.ActiveDoc
Set swModelDocExt = swModelDoc.Extension
Set swSelMgr = swModelDoc.SelectionManager
boolstatus = swModelDocExt.SelectByID2("",
"FACE", 0.01003412456834, -0.004066490524281, 0.009999999999877,
False, 0, Nothing, swSelectOptionDefault)
Dim face1(0 To 0) As Object
Set face1(0) = swSelMgr.GetSelectedObject5(1)
swModelDoc.ClearSelection2
True
Dim vFace1 As Variant
vFace1 = face1
Dim v1 As Variant
' Get the section properties for the selected face
v1 = swModelDocExt.GetSectionProperties2((vFace1))
Dim i As Integer
For i = 0 To UBound(v1)
Debug.Print
v1(i)
Next i
boolstatus = swModelDocExt.SelectByID2("",
"FACE", 0.06206582466552, -0.001327173848324, 0.003390017181914,
False, 0, Nothing, swSelectOptionDefault)
Dim face2(0 To 0) As Object
Set face2(0) = swSelMgr.GetSelectedObject5(1)
swModelDoc.ClearSelection2
True
Dim vFace2 As Variant
vFace2 = face2
Dim v2 As Variant
' Get the section properties for the selected face
v2 = swModelDocExt.GetSectionProperties2((vFace2))
For i = 0 To UBound(v1)
Debug.Print
v1(i)
Next i
boolstatus = swModelDocExt.SelectByID2("",
"FACE", 0.001167899978725, 0.01888959881109, 0.005119132501591,
False, 0, Nothing, swSelectOptionDefault)
Dim face3(0 To 0) As Object
Set face3(0) = swSelMgr.GetSelectedObject5(1)
swModelDoc.ClearSelection2
True
Dim vFace3 As Variant
vFace3 = face3
Dim v3 As Variant
' Get the section properties for the selected face
v3 = swModelDocExt.GetSectionProperties2((vFace3))
For i = 0 To UBound(v1)
Debug.Print
v1(i)
Next i
End Sub