Model States cause calling rules in subassemblies to throw errors

Model States cause calling rules in subassemblies to throw errors

KenPalAlt
Contributor Contributor
414 Views
4 Replies
Message 1 of 5

Model States cause calling rules in subassemblies to throw errors

KenPalAlt
Contributor
Contributor

After my office migrated to Inventor 2023 (from 2021), I've started getting weird errors.

We discovered that it was related to a known bug with Model States. Removing model states from the affected assemblies does resolve the problem, however it does mean that we will not be able to utilize functionality of Model States. Is there any workaround that allows us to continue using Model States?

 

General Description of the problem:

Parent Assembly (ComponentAdd.iam and ConstraintOffset.iam) contains a subassembly and code that runs a rule in the subassembly:

 

 

iLogicVb.RunRule("SubAssy", "Rule0")

 

 

 

Subassembly (ComponentAdd-SubAssy.iam and ConstraintOffset-SubAssy.iam) has a rule that performs some operation inside that assembly.

 

If I run the rule in the subassembly, it works fine. If I run the rule in the parent assembly (which just calls the rule in the subassembly), I get an error like:

 

 

Error on line 9 in rule: Rule0, in document: ConstraintOffset-SubAssy.iam
Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

 

 

The error seems to occur specifically on lines that modify the subassembly (in my examples adding a component or modifying offset of a constraint).

Merely doing calculations, string operations, getting references to components, etc works fine though.

 

Edit: title and text changed after discovering the issue being related to a known bug.

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

CGBenner
Community Manager
Community Manager

@KenPalAlt 

Welcome to the family!  Is there anything you can tell us about the assembly/sub-assembly you are trying this on?  Some features change or are added from year to year so it is possible that you may be running into a hold up because of something in Inventor that changed and may require a tweak to your code.  I defer to those who actually know what they're talking about to help you (hopefully) solve this.  Good luck!  😂

Did you find a post helpful? Then feel free to give likes to these posts!
Did your question get successfully answered? Then just click on the 'Accept solution' button.  Thanks and Enjoy!


Chris Benner
Community Manager

0 Likes
Message 3 of 5

Curtis_Waguespack
Consultant
Consultant

@KenPalAlt , Welcome to the forum.

 

Are you certain that we could place a component in a sub assembly, by calling a rule in that sub from a top level assembly with 2021?

 

I think this has always been a limitation, but I could be wrong.

 

In any case you can do it like this:

Dim oOcc = Component.InventorComponent("SubAssy")
oDoc = ThisApplication.Documents.Open(oOcc.Definition.Document.fullfilename, False)
iLogicVb.RunRule("SubAssy", "Rule0")
oDoc.close

 

Hope that helps,

Curtis

 

EESignature

Message 4 of 5

KenPalAlt
Contributor
Contributor
Accepted solution

@CGBenner 
Cheers! Not much info to add about the assemblies other than what I already wrote, and the assemblies were attached to the post. We did discover a bug that causes this issue though, which I added to the main (first) post. ☝

0 Likes
Message 5 of 5

KenPalAlt
Contributor
Contributor
@Curtis_Waguespack
It definitely worked before the update.
We have discovered that the error was caused by known bug related to Model States, and after removing Model States from the affected assemblies, the code works one again. I've updated the post after discovering this.

It would be preferable though to find a solution that doesn't require us to remove Model States, as they can be useful.