Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)) from iLogic code

Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)) from iLogic code

Jeff_Morovich
Contributor Contributor
1,255 Views
2 Replies
Message 1 of 3

Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)) from iLogic code

Jeff_Morovich
Contributor
Contributor

I have a snippet of code that I found to help  sum up the costs of parts in an assembly and places the total into the estimated cost in the assembly's Estimated cost iProperty. This code works fine in some assemblies. When I try it in a larger upper level assembly, I get the Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)) error. 

 

I've seen emails that say this is related to LOD. But have not seen a clear solution for this.

 

Code below:

 

SyntaxEditor Code Snippet

'clear the custom property in the assembly 
iProperties.Value("Project", "Estimated Cost") = 0

'set a reference to the assembly component definintion.'This assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
'check for and skip virtual components'(in case a virtual component trips things up)
If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then
'custom property in the assembly 
xNumber = iProperties.Value("Project", "Estimated Cost")
'custom property in the parts
yNumber = iProperties.Value(oOccurrence.Name, "Project", "Estimated Cost")
sumNumber = xNumber + yNumber
'set custom property values
iProperties.Value("Project", "Estimated Cost") = sumNumber 
Else
End If
Next

 

 

0 Likes
1,256 Views
2 Replies
Replies (2)
Message 2 of 3

MechMachineMan
Advisor
Advisor

If you use the weldment .iam for anything, they all have a default occurrence in them called "Weld" (or something similar) that would likely cause issues. You will need to add an exception for these like you did for virtual components.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 3

Maxim-CADman77
Advisor
Advisor

Is it solved or not?

Please vote for Inventor-Idea Text Search within Option Names

0 Likes