Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
ndillner343SKL
151 Views, 1 Reply

Find Matching Surface

Hello,

I'm taking a system com object "Entity" from the assembly level. I'm then opening up the part document and within the part document. I'm trying to find the corresponding surface for "Entity". Currently I'm evaluating the surface areas. The issue is there are multiple surfaces with the same area. And its mixing them up. Is there a better way to find the matching surface for "Entity"?

 

"face.Evaluator.Area = Entity.Evaluator.Area"

 

Sub NameEntity(Entity As Face, Name As String)
Dim doc As PartDocument = ThisApplication.ActiveDocument

Dim FaceEval = doc.ComponentDefinition.SurfaceBodies.
    Cast(Of SurfaceBody).
    SelectMany(Of Face)(Function(f) f.Faces.Cast(Of Face)).
    Aggregate(Function(face, nextFace) If(face.Evaluator.Area = Entity.Evaluator.Area, face, nextFace))

 

WCrihfield
in reply to: ndillner343SKL

Hi @ndillner343SKL.  One thing you could try would be to use 'Is' instead of '=', then just compare the Face object directly to the Entity object.

For example:

If face Is Entity

The next thing you could try, if it is a Face, is the Face.IntenalName property.  If those two match, then you have the same Face.  However, the Edge object does not have an 'InternalName' property, so it would not work for all possible types of entities.  Beyond that, the next step is a bit more complex, but you could try using the GetReferenceKey method, which all 3 usual objects (Face, Edge, Vertex) have.  Then you would also need to work with the Document.ReferenceKeyManager object, and its methods to compare the two results.  I have not used that process that much, but you can find examples of its use here on this forum.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)