Finding the native face/edge from proxy face/edge in weldment

Finding the native face/edge from proxy face/edge in weldment

Raider_71
Collaborator Collaborator
1,553 Views
2 Replies
Message 1 of 3

Finding the native face/edge from proxy face/edge in weldment

Raider_71
Collaborator
Collaborator

Hi, I am having an issue finding the native face or edge object from a Weldment assembly if the weldment has machining features present. If no machining features are present then it works fine. It makes sense as the machining would create an alternative body that is represented in the assembly and which is different to the original part surface body. How do I translate the selected face or edge (or any object for that matter) to the relevant part face or edge?

 

In this case, I have the user select a Planar face at assembly level. The app must then find the face in the part document and create a part sketch.

As I said this works in a normal assembly or a Weldment with no machining features on the part. As soon as any features are present the sketch creation fails.

 

My simplified code:

        Dim oAssyDoc As AssemblyDocument = oApp.ActiveDocument

        Dim oFaceProxy As FaceProxy = oApp.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Select Planar Face")

        Dim oOccurrence As ComponentOccurrence = oFaceProxy.ContainingOccurrence

        Dim oPartDoc As Inventor.PartDocument = oOccurrence.ReferencedDocumentDescriptor.ReferencedDocument

        Dim oPartCompdef As Inventor.PartComponentDefinition = oPartDoc.ComponentDefinition

        Dim oSketch As PlanarSketch = oPartCompdef.Sketches.Add(oFaceProxy.NativeObject)
0 Likes
Accepted solutions (1)
1,554 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

Just thinking out loud here...but maybe do it in reverse.  What I mean is get the NativeObject from the FaceProxy object to a variable (As Face) first.  Then get the Face.Parent.Parent (Face.Parent is a SolidBody, SolidBody.Parent or SurfaceBody.ComponentDefinition) to get the ComponentDefinition (which can be set as the value of a PartComponentDefinition type variable).  This route might work, while the other route might fail.  Just a thought. 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

Raider_71
Collaborator
Collaborator
Accepted solution

@WCrihfield  thanks for your reply.

 

I have done some more digging and came across the following which seems to work just fine.

First, do a check to see if the body was overwritten. If it was then you use the GetSorceFace method to get to the part face and then create the sketch.

        If oOccurrence.HasBodyOverride Then
            oFace = oFaceProxy.NativeObject.GetSourceFace
        Else
            oFace = oFaceProxy.NativeObject
        End If