Having to run rule twice to get subassemblies parameters to update

Having to run rule twice to get subassemblies parameters to update

JamesMeBoi
Enthusiast Enthusiast
588 Views
7 Replies
Message 1 of 8

Having to run rule twice to get subassemblies parameters to update

JamesMeBoi
Enthusiast
Enthusiast

Still having an issue with my subassembly rule which is being recalled in the top level to update the size of a tool I've designed. Essentially I have a rule in the top level that runs a rule in the sub assembly to allow you to edit the form (which lets you set the size of the tooling in the subassembly). The rule works, and changes the parameters in the part files present in subassembly, but once I've changed and okayed the form the updates don't happen. The only way I've found to get it to update is to run the rule twice, then in the background I will see the subassembly update.

 

Here is my rule in the Top Level:

iLogicVb.RunRule("Tooling Assembly:1", "Tool Configuration")

Here is my rule in my Subassembly:

 

iLogicForm.Show("Tooling Configuration")



Parameter("BackplateThickness") = Parameter("BackplateThickness")
Parameter("Kanga Tooling Template Gasket Side:1", "BackplateThickness") = Parameter("BackplateThickness")
Parameter("Kanga Tooling Template:1", "BackplateThickness") = Parameter("BackplateThickness")
Parameter("Kanga Tooling Gasket Template:1", "BackplateThickness") = Parameter("BackplateThickness")

Parameter("ChevronAngle") = Parameter("ChevronAngle")
Parameter("Kanga Tooling Template Gasket Side:1", "ChevronAngle") = Parameter("ChevronAngle")
Parameter("Kanga Tooling Template:1", "ChevronAngle") = Parameter("ChevronAngle")
Parameter("Kanga Tooling Gasket Template:1", "ChevronAngle") = Parameter("ChevronAngle")

Parameter("ProductLength") = Parameter("ProductLength")
Parameter("Kanga Tooling Template Gasket Side:1", "ProductLength") = Parameter("ProductLength")
Parameter("Kanga Tooling Template:1", "ProductLength") = Parameter("ProductLength")
Parameter("Kanga Tooling Gasket Template:1", "ProductLength") = Parameter("ProductLength")

Parameter("ProductThickness") = Parameter("ProductThickness")
Parameter("Kanga Tooling Template Gasket Side:1", "ProductThickness") = Parameter("ProductThickness")
Parameter("Kanga Tooling Template:1", "ProductThickness") = Parameter("ProductThickness")
Parameter("Kanga Tooling Gasket Template:1", "ProductThickness") = Parameter("ProductThickness")

Parameter("ProductWidth") = Parameter("ProductWidth")
Parameter("Kanga Tooling Template Gasket Side:1", "ProductWidth") = Parameter("ProductWidth")
Parameter("Kanga Tooling Template:1", "ProductWidth") = Parameter("ProductWidth")
Parameter("Kanga Tooling Gasket Template:1", "ProductWidth") = Parameter("ProductWidth")

Parameter("SealSpacing") = Parameter("SealSpacing")
Parameter("Kanga Tooling Template Gasket Side:1", "SealSpacing") = Parameter("SealSpacing")
Parameter("Kanga Tooling Template:1", "SealSpacing") = Parameter("SealSpacing")
Parameter("Kanga Tooling Gasket Template:1", "SealSpacing") = Parameter("SealSpacing")

Parameter("SealWidth") = Parameter("SealWidth")
Parameter("Kanga Tooling Template Gasket Side:1", "SealWidth") = Parameter("SealWidth")
Parameter("Kanga Tooling Template:1", "SealWidth") = Parameter("SealWidth")
Parameter("Kanga Tooling Gasket Template:1", "SealWidth") = Parameter("SealWidth")

Parameter("TabLength") = Parameter("TabLength")
Parameter("Kanga Tooling Template Gasket Side:1", "TabLength") = Parameter("TabLength")
Parameter("Kanga Tooling Template:1", "TabLength") = Parameter("TabLength")
Parameter("Kanga Tooling Gasket Template:1", "TabLength") = Parameter("TabLength")

Parameter("TopAndBottomPercentage") = Parameter("TopAndBottomPercentage")
Parameter("Kanga Tooling Template Gasket Side:1", "TopAndBottomPercentage") = Parameter("TopAndBottomPercentage")
Parameter("Kanga Tooling Template:1", "TopAndBottomPercentage") = Parameter("TopAndBottomPercentage")
Parameter("Kanga Tooling Gasket Template:1", "TopAndBottomPercentage") = Parameter("TopAndBottomPercentage")

Parameter("TopAndBottomSpacing") = Parameter("TopAndBottomSpacing")
Parameter("Kanga Tooling Template Gasket Side:1", "TopAndBottomSpacing") = Parameter("TopAndBottomSpacing")
Parameter("Kanga Tooling Template:1", "TopAndBottomSpacing") = Parameter("TopAndBottomSpacing")
Parameter("Kanga Tooling Gasket Template:1", "TopAndBottomSpacing") = Parameter("TopAndBottomSpacing")

Parameter("GasketThickness") = Parameter("GasketThickness")
Parameter("Kanga Tooling Gasket Template:1", "GasketThickness") = Parameter("GasketThickness")



'update all
iLogicVb.UpdateWhenDone = True

 I had a few responses on my initial post but I couldn't really understand how to get it to work.

 

Any help would be appreciated thank you!

589 Views
7 Replies
Replies (7)
Message 2 of 8

Curtis_Waguespack
Consultant
Consultant

Hi @JamesMeBoi 

 

This is often resolved by adding an update to the top of the rule, and/or adding a RulesParameterOutput line at the bottom.

 

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

 

InventorVb.DocumentUpdate() 'update the rule before the form is shown

iLogicForm.Show("Tooling Configuration")

Parameter("BackplateThickness") = Parameter("BackplateThickness")
'''the rest of your code...
'''the rest of your code...
'''the rest of your code...
'''the rest of your code...
'''the rest of your code...

'update all
RuleParametersOutput() 'push parameter values before update
iLogicVb.UpdateWhenDone = True

 

EESignature

0 Likes
Message 3 of 8

WCrihfield
Mentor
Mentor

Just a couple more notes too.

You can actually put that 'UpdateWhenDone' line at the top of your rule, because that's what its for.  This sets an instruction that when the rule finishes, update the document, so it doesn't need to be at the end, like the 'DocumentUpdate' line does.

And here is a custom iLogic snippet (made up of other standard snippets) I often drop into the top of some of my iLogic rules, when that rule is going to be dealing with parameters.  In includes another couple of good snippets that are best placed at or near the top of the rule, instead of at the bottom.

 

'Update the current document when this rule finishes running.
iLogicVb.UpdateWhenDone = True
'The model will be updated after every Parameter change within the current rule.
Parameter.UpdateAfterChange = True
'The model will be updated after every MultiValue Parameter is changed within the current rule.
MultiValue.UpdateAfterChange = True

 

 Then that 'RuleParametesOutput' is the first snippet within my finishing combination snippet for ensuring everything is updated, followed by the 'iLogicVb.DocumentUpdate' snippet at the end.  (You don't really need both the 'UpdateWhenDone' at the beginning and the 'DocumentUpdate' at the end, because they will both do the same thing.)

 

Also, I'm curious about why you have lines of code that seem to be setting a parameter to itself, with no component mentioned.  Is this maybe to trigger some sort of Event Trigger setting or to trigger local rules using unquoted parameter names within to run?  If not, I would say you can delete them, because they won't be doing anything.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 8

JamesMeBoi
Enthusiast
Enthusiast
Unfortunately this did not work, Still requires me to run the rule twice
Message 5 of 8

JamesMeBoi
Enthusiast
Enthusiast
This did not work for some reason still requires me to run the code twice
Message 6 of 8

WCrihfield
Mentor
Mentor

If you run your rule once, then use something like the Rebuild All tool, does that make the updates happen and show?  The Rebuild All tool is in the upper left of the Manage tab.  (Manage tab > Update panel > Rebuild All)

WCrihfield_1-1634313395177.png

If that works, we can include that little command at the end of your rule.

If not, we may have to include code to update then save each of those components that you are changing the parameters of.  Then update the assembly afterwards.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 8

JamesMeBoi
Enthusiast
Enthusiast

Tried using the Rebuild All feature in both the Top level and the subassembly and it did not work. The three tooling parts that are being edited in this rule/form will need to each be saved as new part, because this will be a template file once I have all this ILogic done.

 

Message 8 of 8

A.Acheson
Mentor
Mentor

Here is the original posting.

https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/i-want-to-run-a-subassembly-ilogic-rule...

 

Please avoid duplicate posts  as it misses information that people have all-ready worked on, you have all ready included and it also gets confusing especially if one gets solved and the other doesn't even thou they are the same topic. 

 

Can you show how you have the internal form set up with an image ( what buttons are in use done, ok cancel apply ) etc. 

If possible please supply a simple sample assembly and the structure you are using. It only needs to contain a simple part that fails to update in the way you expect. 

 

A work around for your situation is to place the rule as a button in the form this way you can see the update happening before you exit the form. 

 

Here is a link to access forms inside the sub assembly from the main assembly it may be helpful. 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes