- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Everyone,
I am a new to iLogic and Inventor API, I have an .iam file which include two occurrences, and I want to add a constraint by using below codes. However, an error was found and I can not figure out. Thanks if you can help.
Dim oADoc As AssemblyDocument oADoc = ThisApplication.ActiveDocument Dim oCompDef As AssemblyComponentDefinition oCompDef = oADoc.ComponentDefinition Dim oOcc As ComponentOccurrences oOcc = oCompDef.Occurrences oOcc1 = oOcc.Item(1) oOcc2 = oOcc.Item(2) Dim oOcc1Def As PartComponentDefinition oOcc1Def = oOcc1.Definition Dim oOcc2Def As PartComponentDefinition oOcc2Def = oOcc2.Definition Dim oPartPlane1 As WorkPlane oPartPlane1 = oOcc1Def.WorkPlanes.Item(3) Dim oPartPlane2 As WorkPlane oPartPlane2 = oOcc2Def.WorkPlanes.Item(3) Dim oAsmPlane1 As WorkPlaneProxy Call oOcc1.CreateGeometryProxy(oPartPlane1, oAsmPlane1) Dim oAsmPlane2 As WorkPlaneProxy Call oOcc2.CreateGeometryProxy(oPartPlane2, oAsmPlane2) Dim oMate As MateConstraint oMate = oCompDef.Constraints.AddMateConstraint(oAsmPlane1, oAsmPlane2, 0)
Also, below is the error message.
Error on line 26 in rule: Constraints, in document: oOcc.iam
Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))
System.Runtime.InteropServices.COMException (0x80020005): Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))
at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
at ThisRule.Main() in rule: Constraints, in document oOcc.iam:line 26
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
Solved! Go to Solution.