I am missing something very obvious here because I am new.
All I am trying to do is get the FaceIDs from a Solidworks model using a Face Traversal as shown below.
1. I am not certain why faceid = swFace.GetFaceId() does not seem to work.
'
' ==========================================================
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swPart As SldWorks.PartDoc
Dim retval As Variant
Dim i As Integer
Dim swFace As SldWorks.face2
Dim matProps(8) As Double
Dim faceid As Integer
Sub main()
Set swApp = Application.SldWorks
If Not swApp Is Nothing Then
Set swModel = swApp.ActiveDoc
If Not swModel Is Nothing Then
'Notice the Explicit Type Casting
Set swPart = swModel
If Not swPart Is Nothing Then
retval = swPart.GetBodies2(SwConst.swSolidBody, True)
For i = 0 To UBound(retval)
Set swFace = retval(i).GetFirstFace
matProps(0) = 1
matProps(1) = 0
matProps(2) = 0
matProps(3) = 1
matProps(4) = 1
matProps(5) = 0.3
matProps(6) = 0.3
matProps(7) = 0
matProps(8) = 0
Do While Not swFace Is Nothing
swFace.MaterialPropertyValues = ((matProps))
faceid = swFace.GetFaceId()
Debug.Print faceid
swModel.ActiveView.GraphicsRedraw Nothing
Set swFace = swFace.GetNextFace
Loop
Next i
End If
Set swPart = Nothing
End If
Set swModel = Nothing
End If
Set swApp = Nothing
End Sub