Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
Below is some extract code, a user selects some edges via the commandmanager.pick method, these edge objects are stored in an object collection. A for loop indexes through the edges and places and constrains parts to these edges. The code will inconsistently manage to insert a part and constrain, sometimes failing to insert, sometimes inserting but then failing to constrain.
When it fails to insert a part, "operation aborted" followed by Exception from HRESULT: 0x80004005 (E_FAIL)
When it fails to constrain, Exception from HRESULT: 0x80004005 (E_FAIL)
Any ideas?
Dim assemDoc As AssemblyDocument = g_inventorApplication.ActiveDocument Dim oAsmCompDef As AssemblyComponentDefinition = assemDoc.ComponentDefinition
Dim oCylEdgeA As Edge
Dim userSelection As ObjectCollection = g_inventorApplication.TransientObjects.CreateObjectCollection()
Dim oOcc1 As ComponentOccurrence
Dim oInsert1 As InsertConstraint
While True
oCylEdgeA = g_inventorApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeCircularFilter, "Select Hole(s), ESC to Finish")
If oCylEdgeA Is Nothing Then
If userSelection.Count = 0 Then
Show()
Refresh()
Exit Sub
End If
Exit While
Else
''''' Add selected edges to collection
userSelection.Add(oCylEdgeA)
End If
End While
For Each oCylEdge1 as edge In userSelection
oOcc1 = oAsmCompDef.Occurrences.Add(sFile1, oMatrix)
Dim i = 1
For Each iMateDefinition In oOcc1.iMateDefinitions
If FeatureType = True Then ' non csk
If iMateDefinition.Name = "Insert In1" Then
iMate1 = oOcc1.iMateDefinitions.Item(i)
Exit For
End If
Else 'csk
If iMateDefinition.Name = "Align1" Then
iMate1 = oOcc1.iMateDefinitions.Item(i)
Exit For
End If
End If
i = i + 1
Next
oInsert1 = oAsmCompDef.Constraints.AddInsertConstraint(oCylEdge1, iMate1, True, 0)
next
Solved! Go to Solution.