Assembling with iMates and iParts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, I've encoutered a problem while trying to place iParts with iMates inside of my assembly file.
Relevant code:
Dim oParts(0 To 2)
oParts(0) = "A"
oParts(1) = "B"
oParts(2) = "C"
For Each oOcc As ComponentOccurrence In oACD.Occurrences
oOcc.Delete()
Next
For Each item In oParts
Dim oPartName = item.ToString
Dim oFullLoc As String
oFullLoc = oSourceLoc & oPartName & oExtension
If item = "A"
oiRow = oVar_Size & oVar_Flange
Dim oOcc_1 As ComponentOccurrence = oACD.Occurrences.Add(oFullLoc, oMatrix)
iPart.ChangeRow(oOcc_1.Name, oiRow)
oAsAfstand = Parameter.Value(oOcc_1.Name, "AsAfstand")
Else If item = "B"
oiRow = oVar_Size
Dim oOcc_2 As ComponentOccurrence = oACD.Occurrences.AddUsingiMates(oFullLoc, False)
iPart.ChangeRow(oOcc_2.Name, oiRow)
Parameter.Value(oPartName & oExtension, "AsAfstand") = oAsAfstand
Else If item = "C"
oiRow = oVar_Size
Dim oOcc_3 As ComponentOccurrence = oACD.Occurrences.AddUsingiMates(oFullLoc, False)
iPart.ChangeRow(oOcc_3.Name, oiRow)
End If
For Each oOcc In oACD.Occurrences
oOcc.Grounded = True
Next
On Error Resume Next
Next
Error message (appears on line 26):
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.ComponentOccurrence'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{5DF86020-6B16-11D3-B794-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
at ThisRule.Main() in rule: Assemble, in document Motor assembly.iam:line 45
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
Additional information:
The component DOES get placed inside the assembly, but i want to solve the error message.
Stands out to me that on line 20 there is no error where i use ".Add" instead of ".Addusingimates"
Would appreciate help on this, if more info is needed let me know! Thanks