Unspecified error in Part File (API) (Exception from HRESULT: 0x80004005 (E_FAIL))

Unspecified error in Part File (API) (Exception from HRESULT: 0x80004005 (E_FAIL))

llorden4
Collaborator Collaborator
715 Views
4 Replies
Message 1 of 5

Unspecified error in Part File (API) (Exception from HRESULT: 0x80004005 (E_FAIL))

llorden4
Collaborator
Collaborator

A few searches on this error does have some hits but none appear to match my conditions.  I have a a part file I'm developing using ilogic/API and it works great except for an initial run of the iLogic code where it always fails with this unspecified error.  After which it works great, I can't figure this one out and am reaching out for help.  Including the part file and a video demonstrating my issue.  I suspect you may have additional issues since part of this ilogic refers to some custom sheet metal rules that you likely do not have, REM out as needed.  Inventor Pro 2021.1

Autodesk Inventor Certified Professional
0 Likes
Accepted solutions (1)
716 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

I doubt this will fix the main problem, but I found something that might need to be fixed in your rule's code.

About line # 119 to line # 125 you have the following code:

'delete any previous features
Try
	For Each oFeature In oFeatures
		If oFeature.Name = "Doubler Plate" Then oFeature.Delete
	Next
Catch
End Try

but the variable 'oFeatures' doesn't appear to have been defined, or a value given to it before that point (or anywhere) within your code.

 

It's a very long and involved code, so it's a little hard to follow when trying to quickly proofread, but I'm thinking that, based on the one line in the error, since it is having trouble getting the edges of a surfacebody, take a look at around line 381 to 386 (where your "If GoodModel" block of code starts).  There is a  bit of code there before your Try block that is attempting to work with surfacebody edges in a somewhat complicated way.  Try putting a Try block around just that little section, with a message in the Catch, and see if that catches anything in that first run scenario.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

llorden4
Collaborator
Collaborator

I appreciate the look and can understand the desire not to deep dive.  I've added the code here as you suggested and it had no effect...

 

	'Store Faces/Edges (positions as viewed from back of doubler)
	Dim GoodModel As Boolean
	If oCompDef.SurfaceBodies.Count = 1 Then
		GoodModel = True
	Else
		GoodModel = False
		ErrorDet = True
	End If
	If GoodModel Then																			'ensure valid model to process
'Added per WCrihfield suggestion
	Try
		oSurfaceBody = oCompDef.SurfaceBodies.Item(1)											'get body extrusion
		BackFaces(1) = oSurfaceBody.Faces.Item(1)												'get face on left back of doubler face
		BackFaces(2) = oSurfaceBody.Faces.Item(oDbF + (oDbF - 1))								'get face on right back of doubler face
		CornerEdge(1) = oSurfaceBody.Edges.Item(((oDbF * 2) + ((oDbF - 1) * 4) + 2) * 2 + 1)	'get top left corner edge
		CornerEdge(2) = oSurfaceBody.Edges.Item(((oDbF * 2) + ((oDbF - 1) * 4) + 2) * 2 + 3)	'get bottom left corner edge
	Catch
		MsgBox("error found here")
	End Try
'End Add

 

To address some of your comments, the deletion of the "Doubler Plate" feature just handles the removal of the shape ran previously to ensure its removal while allowing any user added features to remain without deleting their added feature.  Probably will still cause an error, but I expect that can be recovered by moving the added user feature below the re-created "Doubler Plate".

Autodesk Inventor Certified Professional
0 Likes
Message 4 of 5

llorden4
Collaborator
Collaborator

Some additional testing to see where things are going awry has yielded the issue, I think.  I've added some code directly after the variable declarations to verify that the surface body and edges are present; my first instict was that the edges may have been loading in random order instead of a developed order.

Dim Xdir As Integer
Dim Ydir As Integer
Dim oHoleCenters As ObjectCollection
Dim oPnt As SketchPoint
Dim EdgeAdj As Integer = 0

MsgBox(oCompDef.SurfaceBodies.Count)		'This works
MsgBox(oCompDef.SurfaceBodies.Edges.Count)	'This Fails

It would appear that the property for edges does not exist on initial load.  Suggestions on a resolution? 

Autodesk Inventor Certified Professional
0 Likes
Message 5 of 5

llorden4
Collaborator
Collaborator
Accepted solution

I found my solution in process calls.  After declarations, I just temporarily assigned the surface bodies, face count, and then an edge count to a variable to get them loaded.  It appears you must call faces before you can call edges; weird but it provided the solution.

Autodesk Inventor Certified Professional
0 Likes