Component.IsActive causes Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

Component.IsActive causes Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

florescu.d95
Enthusiast Enthusiast
567 Views
4 Replies
Message 1 of 5

Component.IsActive causes Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

florescu.d95
Enthusiast
Enthusiast

I've been having the following issue with Inventor 2024 iLogic:

Assembly is comprised of 2 sub assemblies, each with it's own ilogic rule.

When the sub assembly rule is ran from main assembly using iLogicVb.RunRule the Unspecified error appears. 

When ran directly from the sub assembly everything works fine

Line 14 is:

Component.IsActive("FacePlate1_85_DOWN:1") = True

florescud95_0-1710778577056.png

 

 

 

 

0 Likes
Accepted solutions (2)
568 Views
4 Replies
Replies (4)
Message 2 of 5

daltonNYAW9
Advocate
Advocate

I couldn't recreate this. 

 

Does this part use model states? It used to require you to create a LOD when you would suppress components. Maybe some of this is still hard coded with model states? Worst case you will have to create a new model state for suppressing that component.

Component.ActiveModelState("Part1:1") = "ModelState1"

 

Another option is to try changing the objectProvider for the ilogic functions. This is a far-shot b/c it should already be like this.

iLogicVb.CreateObjectProvider(ThisDoc.Document).Component.IsActive("FacePlate1_85_DOWN:1") = True

 

Also, you could try to suppress the component from the top level assembly and use the "MakePath" function.

Component.IsActive(MakePath("SubAssem1:1", "Part2:1")) = True


 

Message 3 of 5

WCrihfield
Mentor
Mentor
Accepted solution

Hi guys.  @daltonNYAW9 was on the right path, but there is still another irritating detail you may need to keep in mind.  The 'Component' term is a 'Rule Object', and it does not document clearly which document it will be targeting when it attempts to work with some specific component within that document.  I believe that if that term is used in an internal (saved within the document) iLogic rule, it will target the document that the rule is saved within, by default, but could potentially target another document in certain rarer conditions.  However, if used in an external iLogic rule, it will most likely target the document that was 'active' (visible on your screen) when the rule started.  So, if that rule was in a sub assembly, and it ran while the main assembly was 'active', it may be looking or that component directly in the main assembly (as one of its top level components), instead of looking within that sub assembly.  To avoid that problem, you may need to use more specific code, such as the Inventor API way of suppressing or un-suppressing a component.  The Inventor API way is to get a reference to the actual ComponentOccurrence object you want to control, then use one of the following.

ComponentOccurrence.Suppress (a method to suppress it)

ComponentOccurrence.Unsuppress (a method to unsuppress it)

ComponentOccurrence.Suppressed (a ReadOnly property to check its current suppression status)

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 5

florescu.d95
Enthusiast
Enthusiast

@WCrihfield  Thanks for explaining this! Will try implementing your suggestions but it makes sense to me.

0 Likes
Message 5 of 5

WCrihfield
Mentor
Mentor
Accepted solution

Hi @florescu.d95.  Just in case you are not familiar with the Inventor API way I mentioned, here is a very short example iLogic rule showing how to get a reference to that one specific component, by its name, then toggle its suppression.

Dim oADoc As AssemblyDocument = TryCast(ThisDoc.Document, Inventor.AssemblyDocument)
If oADoc Is Nothing Then Return
Dim oOccs As ComponentOccurrences = oADoc.ComponentDefinition.Occurrences
Dim oFP1_81_Down1 As ComponentOccurrence = oOccs.ItemByName("FacePlate1_85_DOWN:1")
'toggle its suppression each time
If oFP1_81_Down1.Suppressed Then
	oFP1_81_Down1.Suppress
Else
	oFP1_81_Down1.Unsuppress
End If

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes