So I have this component in an assembly and run the following code:
Sub main()
Dim swApp As Object
Dim AssyDoc As Object
Dim SelMgr As Object
Dim SelData As SldWorks.SelectData
Dim comp As Object
Dim Body As Object
Dim Face As Object
Dim CurFaceName As String
Dim boolstatus As Boolean
Set swApp = CreateObject("SldWorks.Application")
Set AssyDoc = swApp.ActiveDoc()
Set SelMgr = AssyDoc.SelectionManager()
Set SelData = SelMgr.CreateSelectData
Set comp = AssyDoc.GetComponentByName("HH63A200371- head-1")
Set Body = comp.GetBody() ' Get the Component Body
If (Body Is Nothing) Then
swApp.SendMsgToUser "Component Body Unavailable."
swApp.SendMsgToUser "Make sure not lightweight or suppressed"
Exit Sub
End If
Debug.Print Body.GetFaceCount
Set Face = Body.GetFirstFace
' Traverse thru all body faces
Do While Not Face Is Nothing
CurFaceName = AssyDoc.GetEntityName(Face)
If (CurFaceName = "HolderDistance1") Then
boolstatus = Face.Select4(True, SelData)
Exit Sub
End If
Set Face = Face.GetNextFace
Loop
End Sub
I am trying to select a face that is called "HolderDistance1". When I run this code I get a face count of 4 from the debug line. How come I am only getting 4 faces? Clearly there are more then 4 in that component.
Thanks,
Denis
SolidworksApi/macros