Getting “The parameter is incorrect” when AddByPlaneAndOffset is used in assembly

Getting “The parameter is incorrect” when AddByPlaneAndOffset is used in assembly

nagihan.bostan
Enthusiast Enthusiast
423 Views
4 Replies
Message 1 of 5

Getting “The parameter is incorrect” when AddByPlaneAndOffset is used in assembly

nagihan.bostan
Enthusiast
Enthusiast

Hi,

In the assembly file, I want the user to select a part and a face belonging to this part. As a result, I create a workplane on this surface with “AddByPlaneAndOffset”.

So far, my code below was working fine, but recently I started getting the "The parameter is incorrect".

 

I understood that this error was caused by changes made to the selected part in the assembly file. For example, if I drill a hole in part1 during assembly, as in the photo. This prevents me from creating a Workplane on the surface selected in part1.

 

How can I fix this situation? Thanks in advance.

 

nagihanbostan_0-1696502520119.png

 

 var part = (ComponentOccurrence)InventorApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select Part");
            PartComponentDefinition partComponentDefination = (PartComponentDefinition)part.Definition;

            var oFaceProxy = (FaceProxy)InventorApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Select Face");

            Face faceNative = oFaceProxy.NativeObject;

            WorkPlane workPlane = partComponentDefination.WorkPlanes.AddByPlaneAndOffset(faceNative, 0);

 

0 Likes
Accepted solutions (1)
424 Views
4 Replies
Replies (4)
Message 2 of 5

A.Acheson
Mentor
Mentor

Hi @nagihan.bostan 

That method isn't supported in an assembly see help page.

See forum post here to add fixed plane and constrain just like the API is doing. 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 5

nagihan.bostan
Enthusiast
Enthusiast

Hi @A.Acheson ,

 

Thanks for your answer. The code in the post you suggested is not exactly what I want. According to code is added to the workplane assembly file. (As shown in the image on the left)

 

What I want is workplane to be created in the part file according to the part and surface selected in the assembly file. (As shown in the image on the right)

 

Do you have any ideas for this?

 

nagihanbostan_1-1696579055033.png

 

0 Likes
Message 4 of 5

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @nagihan.bostan 

When you use an assemblyfeature (hole in your case) to modify the part face in assembly context, you can't simply use the native object of the face proxy anymore. What you need to do is check if the component has a body override (for example a hole on assembly level) and if so use GetSourceFace to get the face that has been overriden by your assembly features.

 

Here's a quick iLogic example based on your original code:

Dim part As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select Part")
Dim partComponentDefination As PartComponentDefinition = part.Definition
Dim oFaceProxy As FaceProxy = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Select Face")

Dim faceNative As Face
If part.HasBodyOverride Then
	faceNative = oFaceProxy.NativeObject.GetSourceFace
Else
	faceNative = oFaceProxy.NativeObject
End If

Dim workPlane As WorkPlane = partComponentDefination.WorkPlanes.AddByPlaneAndOffset(faceNative, 0)
0 Likes
Message 5 of 5

nagihan.bostan
Enthusiast
Enthusiast

Hi @JhoelForshav,

Thank you for helping. This is the piece of code I was looking for.