Compare Two Faces

Compare Two Faces

Anonymous
Not applicable
998 Views
2 Replies
Message 1 of 3

Compare Two Faces

Anonymous
Not applicable

I would like to compare two faces to see if they are the same face.  I have three faces and a hole feature on one of the three faces.  I am trying to determine what face the hole is on(top, right, left).  I can get the face the hole feature was created on as:

 

Set oHoleFace = oHoleFeature.PlacementDefinition.Parent.Sketch.PlanarEntity

 

I can get the three face objects I need to check for the hole on.

 

Set oTopFace = oExtrudeFeatures.Item(1).Faces.Item(13)
Set oRightFace = oExtrudeFeatures.Item(1).Faces.Item(3)
Set oLeftFace = oExtrudeFeatures.Item(1).Faces.Item(12)

 

Can I compare faces or do I need to use vectors?  I tried comparing the InternalName of the faces but this seems to fail when there is more than 1 hole center within a hole feature.

0 Likes
Accepted solutions (1)
999 Views
2 Replies
Replies (2)
Message 2 of 3

philippe.leefsma
Alumni
Alumni
Accepted solution

Hi There,

 

You could simply compare the object references with the "Is" operator in VBA, did you try something like this:

 

Sub FindFace()

    Dim doc As PartDocument
    Set doc = ThisApplication.ActiveDocument
    
    Dim face As face
    Set face = doc.ComponentDefinition.SurfaceBodies(1).faces(1)
    
    Dim faceItr As face
    For Each faceItr In doc.ComponentDefinition.SurfaceBodies(1).faces
    
        If (face Is faceItr) Then
            Debug.Print "Face found..."
        End If
    
    Next

End Sub

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 3

Anonymous
Not applicable

Thanks for the reply Philippe.  I did not try using the "Is" operator but that is a simple solution which should work well.

0 Likes