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:
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.
Solved! Go to Solution.
Solved by Bert_Bimmel. Go to Solution.
Solved by Michael.Navara. Go to Solution.
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
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.
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:
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:
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:
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.