Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Error in iLogic Code: Unspecified error (Exception from HRESULT: 0x80004005...)

Scott.Hallmark
Advocate

Error in iLogic Code: Unspecified error (Exception from HRESULT: 0x80004005...)

Scott.Hallmark
Advocate
Advocate

I have this code in an Occurrence_Rule that I have that updates the occurrence names of all parts in the assembly and it works perfectly in the assembly.  This is just part of the code and if I comment this part out, I do not get the error in the master assembly:

 

'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
   	Dim oName As String 
   	oName = oOccurrence.Name
	oName2 = Left(oName, 1)
	oName3 = Left(oName, 3)
	oName4 = Mid(oName, 4)
	If oName2 = "-" Then 
		oOccurrence.Name = FilePrefix & oName
	Else If oName3 <> FilePrefix Then
		oOccurrence.Name = FilePrefix & oName4
	End IfNext

The scenario is that this code belongs to a single assembly that then gets put into a master assembly. While the single assembly is open, it functions as I need it to, updating the occurrence names. Once it is placed into a master assembly, it brings up the following error:

Error in rule: OccurrenceName_Rule, in document: 404-Unit_Assembly.iam
Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
 
It is not corrupting the assembly or causing it to function improperly.  It is just annoying because it does it for every subassembly containing that rule, which could be anywhere from 2 to 500+ of them.

 

 

** If my reply resolves this issue, please choose Accept Solution **
Scott Hallmark, Design Specialist | Fluor Corporation
Inventor and AutoCAD Certified Professional, Autodesk Certified Instructor | My Plant3D Notes | AU Speaker | ROLL TIDE!
0 Likes
Reply
Accepted solutions (1)
1,633 Views
4 Replies
Replies (4)

Curtis_Waguespack
Consultant
Consultant

Hi Scott.Hallmark,

 

It's difficult to know without seeing the whole picture, but try something like this, maybe... it runs without issue for my testing.

 

Edit: Also my guess would be that one or more occurrence name is too short or something, and so the Left or Mid lines are returning an error.

 

Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

FilePrefix = "Test_"
'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
   	Dim oName As String 
   	oName = oOccurrence.Name
	oName2 = Left(oName, 1)
	oName3 = Left(oName, 3)
	oName4 = Mid(oName, 4)
	If oName2 = "-" Then 
		oOccurrence.Name = FilePrefix & oName
	Else If oName3 <> FilePrefix Then
		oOccurrence.Name = FilePrefix & oName4
	End If
Next

 

0 Likes

Curtis_Waguespack
Consultant
Consultant

 

Or maybe the issue is the code is attempting to rename an occurrence the same name as another occurrence... maybe something like this to catch that case.

 

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
i=1
FilePrefix = "Test_"
'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
   	Dim oName As String 
   	oName = oOccurrence.Name
	oName2 = Left(oName, 1)
	oName3 = Left(oName, 3)
	oName4 = Mid(oName, 4)
	
	If oName2 = "-" Then 
		oOccurrence.Name = FilePrefix & oName
	Else If oName3 <> FilePrefix Then
		Try
		oOccurrence.Name = FilePrefix & oName4
		Catch 'error when name exists already
		oOccurrence.Name = FilePrefix & oName4 & ":" & i
		i=i+1 'increment counter
		End Try
	End If

Next

 

0 Likes

Scott.Hallmark
Advocate
Advocate

This is what is happening - I have a Curtain Wall Unit Template that has several parts in it, all with filenames beginning with "-" (i.e. "-MM.ipt" for Male Mullion) and when I do a copy design, I copy it to a folder such as "101".  I open the new assembly and the Occurrences_Rule iLogic code then goes in a renames all of the occurrences to "101-xx" for example.  This part is working great.  Then I complete the customizations to that unit and drop it in a new Master Assembly.  Still, all is working great.  I go to Vault and Copy Design "102" and make the custom changes to it and drop it into the Master Assembly.  It works fine too.  If I close the Master Assembly and reopen it, that is when I get the error.  If there is one Subassembly in the Master, I never get the error, but as soon as I add the 2nd unit subassembly in, that is when the errors start.  Again, the units are fine and nothing breaks, but the error message is annoying because it keeps popping up.

 

I have added a screencast to demonstrate the issue.  I have left out the copy design process as I don't believe it is relevant to the issue.  So I have 2 units that I will open, configure, and then place into the master assembly and then you will see the error.

 

iLogic Error when adding to Master Assembly
https://knowledge.autodesk.com/community/screencast/0a7faa95-6718-4613-8af9-81c98b9f7cae

** If my reply resolves this issue, please choose Accept Solution **
Scott Hallmark, Design Specialist | Fluor Corporation
Inventor and AutoCAD Certified Professional, Autodesk Certified Instructor | My Plant3D Notes | AU Speaker | ROLL TIDE!
0 Likes

Scott.Hallmark
Advocate
Advocate
Accepted solution

I fixed it.  I pulled out part of the rule and put it in it's own rule, then changed the order of my rules and it is working as it should.  Thanks for looking into this.  Hope to see everyone at AU 2018!

** If my reply resolves this issue, please choose Accept Solution **
Scott Hallmark, Design Specialist | Fluor Corporation
Inventor and AutoCAD Certified Professional, Autodesk Certified Instructor | My Plant3D Notes | AU Speaker | ROLL TIDE!
0 Likes