iLogic Mating - Custom Planes

iLogic Mating - Custom Planes

Anonymous
Not applicable
2,598 Views
28 Replies
Message 1 of 29

iLogic Mating - Custom Planes

Anonymous
Not applicable

Hello all,

I am fairly new to Inventor iLogic, but I have been able to piece together a fairly extensive set of codes. I am currently attempting to mate my newly generated assembly via the Component Occurrences.
I have custom named work planes in two different parts which I need to mate. This is the code I have so far on this:

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

Dim comp0cc1 As ComponentOccurrence = Component.InventorComponent("Component_#1")
Dim comp0cc2 As ComponentOccurrence = Component.InventorComponent("Component_#2")

Dim oPlane1 As WorkPlane
oPlane1 = comp0cc1.Definition.WorkPlanes("Work Plane #1")
Dim oPlane2 As WorkPlane
oPlane2 = comp0cc2.Definition.WorkPlanes("Work Plane #2")

Dim oproxyPlane1 As WorkPlaneProxy
comp0cc1.CreateGeometryProxy(oPlane1, oproxyPlane1)
Dim oproxyPlane2 As WorkPlaneProxy
comp0cc2.CreateGeometryProxy(oPlane2, oproxyPlane2)

Dim oConstraint As MateConstraint
oConstraint = oAsmCompDef.Constraints.AddMateConstraint(oproxyPlane1, oproxyPlane2,0)
oConstraint.Name = comp0cc1.Name & ":" & comp0cc2.Name & " mate"

The Error I get when running this code is:
[highlight #CC0000]Error in rule: Pushrod_1_Selection, in document: Assembly Test 2.iam
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

I understand the problem is I don't know the proper way to reference the custom named work plane from the component occurrence. Does anyone know the proper notation for this reference?

Thank you very much for reading this and for your assistance!

-Lance

0 Likes
Accepted solutions (1)
2,599 Views
28 Replies
Replies (28)
Message 21 of 29

Anonymous
Not applicable

This looks good, and I am happy you had luck with it! I have normalized the names of the occurrences within the code in a previous line, but still no success on my end. I am curious, though. I will go through your code and see if there's something I can gleam from it.

Thank you for your help!

0 Likes
Message 22 of 29

AlexFielder
Advisor
Advisor
I didn't change a single thing in your original code except for adding "Option Explicit On" at the top:

https://www.diffchecker.com/4FeK1nrZ (Mine is on the right)

🙂
0 Likes
Message 23 of 29

Anonymous
Not applicable

Would you be able to post a snippet of your code? I am unable to open your 2019 Inventor files. Thanks.

0 Likes
Message 24 of 29

AlexFielder
Advisor
Advisor
Accepted solution

There you go:

Option Explicit on
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

Dim comp0cc1 As ComponentOccurrence = Component.InventorComponent("Component_#1")
Dim comp0cc2 As ComponentOccurrence = Component.InventorComponent("Component_#2")

Dim oPlane1 As WorkPlane
oPlane1 = comp0cc1.Definition.WorkPlanes("Work Plane #1")
Dim oPlane2 As WorkPlane
oPlane2 = comp0cc2.Definition.WorkPlanes("Work Plane #2")

Dim oproxyPlane1 As WorkPlaneProxy
comp0cc1.CreateGeometryProxy(oPlane1, oproxyPlane1)
Dim oproxyPlane2 As WorkPlaneProxy
comp0cc2.CreateGeometryProxy(oPlane2, oproxyPlane2)

Dim oConstraint As MateConstraint
oConstraint = oAsmCompDef.Constraints.AddMateConstraint(oproxyPlane1, oproxyPlane2,0)
oConstraint.Name = comp0cc1.Name & ":" & comp0cc2.Name & " mate"

(Had forgotten you were using 2018!)

0 Likes
Message 25 of 29

Anonymous
Not applicable

I am getting the feeling this ability to reference Work Planes by name from the part file in an assembly is limited to Inventor 2019 right now. I very much appreciate the help and feedback. That's a cool trick about the Option Explicit on by the way! Thank you for your help!

0 Likes
Message 26 of 29

AlexFielder
Advisor
Advisor

Has nothing to do with Inventor 2019. Here are those same files recreated in Inventor 2018:

 

(attached!)

 

Is using exactly the same rule as before. Something is broken with your names in your assembly.

0 Likes
Message 27 of 29

Anonymous
Not applicable

When I run your code on my computer I obtain the error:

 

Error in rule: Rule0, in document: iLogic Mating - Custom Planes.iam

Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))

 

This is similar to those I am getting in my file as well.

 

More Info:

System.Runtime.InteropServices.COMException (0x80020003): Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

0 Likes
Message 28 of 29

Anonymous
Not applicable

It turns out I have to enable the working planes in each iPart with a "Compute" for the plane to populate the assembly space. I believe this may be the solution I needed! Thank you for your help!!

0 Likes
Message 29 of 29

R.Mabery
Advocate
Advocate

Check to see that you included the work plane in the children of the Factory.

 

I'd guess they aren't there.


Thanks,
Randy Mabery
Applications Expert
IMAGINiT Technologies
0 Likes