Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to obtain original face from a faceproxy of a part that has been edited inside assembly context?

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Bert_Bimmel
228 Views, 4 Replies

How to obtain original face from a faceproxy of a part that has been edited inside assembly context?

When I select a face of a part in an assembly context, what i actually select is not the original Face-Object, but a FaceProxy- Object instead, i.e. a surrogate of that Face on a particular Occurrence.
The "NativeObject"-property of that FaceProxy returns the original Face of the Part: 

Bert_Bimmel_1-1711539919841.png

 

So far, so good.

--------------------------------------------------------------------------------

Now I have drilled a hole into my part inside the Assemblies context.

When I pick a Face on that edited Body, again, in fact I am picking a FaceProxy, am I?

Well, I'd say "no!":

In case of the cylinder face, that has been newly created by the hole-feature, the face does only exist on the local copy of the SurfaceBody from "Bauteil4".

So what I am picking is the actual Face, not a Proxy, as the Face does not exist inside the Part. The other Occurrence of "Bauteil4" does not have this Face. Anyway, Inventor tells different.

And what about the front face? Is this still a Proxy of the original Face-Object? Again, I'd say "no!"

What I am shown as "Bauteil4:1" in my graphics window is the edited local copy of the Body, not a Proxy (in contrast to "Bauteil4:2 "where I am actually seeing an uneditet Body-Proxy), so the Front-Face I pick on "Bauteil4:1" is unique too. At least, Inventor consequently insists on  "What you have picked is a FaceProxy!"

I disagree, but I shrug my shoulders and accept the answer.

So I ask him: "Give me the NativeObject, please!"

When I then examine the FaceObject that Inventor has returned to me (no matter wether i have selected the front face or the cylinder), I realize, that the SurfaceBody that the returned Face belongs to, is in fact part of the Assembly Document, not of the PartDocument.

Despite the fact that in my opinion the Face and the FaceProxy in this case are the same thing, it makes sence, that the SurfaceBody is declared as part of the Assembly.

Now my actual Problem: I want to get hold of the original Face Object inside the PartDocument which has served as a source for my edited body-copy. 

In case of the cylinder, I can't, because it does not exist. That makes sense.

But in case of the front face, it should be possible somehow, but I can't figure out how.

 

Bert_Bimmel_0-1711543361746.png

 

 

 

4 REPLIES 4
Message 2 of 5

I had the same problem but I'm not sure if it was solved successfully.

Today I look at this again and below is possible solution. this sample omits error handling and the code fail if you select the hole face, because the hole has no SurfaceBody.

 

Thank you for great challenge and I hope it helps.

Sub Main()
    Dim pick = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Pick face")
    Dim asmFaceProxy As FaceProxy = pick
    Dim asmFace As Face = asmFaceProxy.NativeObject

    Dim associativeId As Integer = asmFace.AssociativeID

    Dim originalBodyInPart = asmFace.CreatedByFeature.SurfaceBody

    For Each partFace As Face In originalBodyInPart.Faces
        If partFace.AssociativeID = associativeId Then
            'This partFace is the original face
            Logger.Debug("Found")
            DoSomethingWithPartFace(partFace)
            Return
        End If
    Next
    Logger.Debug("Nothing here")

End Sub

Private Sub DoSomethingWithPartFace(partFace As Face)
    Dim sk as PlanarSketch = partFace.Parent.ComponentDefinition.Sketches.Add(partFace)
    sk.TextBoxes.AddFitted(ThisApplication.TransientGeometry.CreatePoint2d(), "here")
End Sub

 

Message 3 of 5

Thank you for understanding the problem and proposing a working solution.

Anyway, I think that Autodesk has some homework to do, to make this more straigth forward.

Message 4 of 5
Bert_Bimmel
in reply to: Bert_Bimmel

Dear Lord, sometimes I can't see the forest for the trees:

Bert_Bimmel_0-1715842058227.png

 

Message 5 of 5
Bert_Bimmel
in reply to: Bert_Bimmel

Ok, next Question: Might the Argument "GetLeafSource" be documented, but not implemented, or am I getting something wrong:

When I create a part, put it into an assembly, drill a hole into it inside the assembly, and then call that method, it works quite fine. The described argument makes no difference as supposed:

Bert_Bimmel_0-1715853521762.png

 

 

Now i put that Assembly into another Assembly and drill another hole into that override body. Now the Method returns nothing, no matter if GetLeafSource is true or false:

Bert_Bimmel_1-1715853659025.png

According to the description in the help, I would have expected that the first call would return the face of the override body in "3Kaese.iam" and the second call returning the original face in "3Kaese.ipt"

Ok, third attempt: Remove the hole in the intermediate assembly, so there is no override in that assembly:

Now, I get the original face in the part for both calls again:

Bert_Bimmel_2-1715854006547.png

Well, that makes sense somehow - although it may also be considered reasonable, if the call with GetLeafSource=false would return the face's proxy on the affected occurrence of "3Kaese.iam".

Thus, I neither get the point what this argument is supposed for, nor how to obtain the original face in case of multiple-level-overrides.

🤔

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report