iLogic, run rule twice to work

iLogic, run rule twice to work

Anonymous
Not applicable
4,651 Views
12 Replies
Message 1 of 13

iLogic, run rule twice to work

Anonymous
Not applicable

Hi all,

 

I stumbled upon a problem within my parametric model. (see pictures)

 

SyntaxEditor Code Snippet

Select Case Omgevingstemperatuur 

Case = "=> -5�C" 
Feature.IsActive("24AW304-P03:1", "Gat olieverwarming") = False
Component.IsActive("A50001.01.0020:1") = False
Component.IsActive("Olieverwarmer:1") = False

Case = "< -5�C" 
Feature.IsActive("24AW304-P03:1", "Gat olieverwarming") = True
Component.IsActive("A50001.01.0020:1") = True
Component.IsActive("Olieverwarmer:1") = True

End Select

RuleParametersOutput()
InventorVb.DocumentUpdate()

 

I'm suppressing two parts (one within first level and one in sub-assembly (3rd level)) and a hole with the iLogic code.

It runs fine up until I want to unsuppress them.

As you can see in the pictures, one part (1st level) and the hole will show up but the other part (3rd level) will not and still is suppressed in the design tree. And when I run the same rule again, without doing anything else, the part will get unsuppressed and show up. What is the problem here?? As you can see I already tried something with the update and rule patamters output.

 

0 Likes
4,652 Views
12 Replies
Replies (12)
Message 2 of 13

Anonymous
Not applicable

Someone?

0 Likes
Message 3 of 13

Anonymous
Not applicable

Hello,

 

Try to add this at the end :

iLogicVb.UpdateWhenDone = True 
ThisApplication.ActiveView.Update()
0 Likes
Message 4 of 13

Anonymous
Not applicable

Actually found a workaround by myself.

I now run the suppression rule within the sub-assembly itself.

Don't how, but it works for me.

0 Likes
Message 5 of 13

Anonymous
Not applicable

You could also try using different event triggers to run the rule. I've had to do this with code that affects non standard variables, especially those for iProperties.

0 Likes
Message 6 of 13

Anonymous
Not applicable

I know this is an old tread, but I am facing the same problem for which no solution seems to be found yet.

 

This probleem appears when setting component patterns to (in)visible, combined with an increase of the number of instances of the pattern. I tried to work with Event Triggers, RunRule("..."), UpdateWhenDone and UpdateAfterChange, and combinations of them, but noting changes.

 

Example: Pattern A exists of part B, patterned 2, 3, 4 or 5 times. A can be set to visible or invisible.

When I set the visibility of A to invisible, and I change the number of instances from a lower to a higher number, the added instances are visible instead of invisible.


When I manually run the rule which sets the visibility of the pattern - without any parameter changes - the pattern immidiatly changes all it's instances to invisible, as how it should have been the first time.

 

Does anyone have a well working example for me?

 

 

0 Likes
Message 7 of 13

Anonymous
Not applicable

Is it a global or a local ilogic rule?
Because in global rules ilogic dont react the same. Example for parameter in local it is enough to say

MyParameter = Option1

to change it.


In global rules, it needs to be in

Parameter("MyParameter") = Option1

If not, the rule doesnt work.

0 Likes
Message 8 of 13

Anonymous
Not applicable

I use only one kind of rule, I guess they are local as it is a rule inside an asset.

 

The rule works for various other functions, so I don't think the local/global thing is the problem.

The only problem is that the visibility of pattern instances does not update properly.

 

0 Likes
Message 9 of 13

Anonymous
Not applicable

I'm currently working on some Ilogic code.  I must run the code twice to make it work.  I cant found any solution or work around.  Really annoying...  I get some parameters from an XML file, based on these parameters i compose a filename.  Subsequently I open the document with the filename.  BUt, as said, I must run the rule twice.  First time the previous file is opent.  Second time I run the rule the good file is opent. 

0 Likes
Message 10 of 13

bradeneuropeArthur
Mentor
Mentor

 Hi,

can you please explain what the problem is

 

 

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 11 of 13

Anonymous
Not applicable

I found a solution:

 

make two rules

 in the first rule:

 

SyntaxEditor Code Snippet

ThisApplication.Documents.Open(CStr(file_location))
doc = ThisApplication.Documents.ItemByName(CStr(file_location))
doc.Close

iLogicVb.RunRule("<name of the second rule>")

in the second rule:

 SyntaxEditor Code Snippet

ThisApplication.Documents.Open(CStr(file_location)) 

 

not an elegant solution, but it works

0 Likes
Message 12 of 13

rob
Advocate
Advocate

Old thread but my two cents worth. 

 

I have a single rule in an assembly using True/False parameters to suppress and unsuppress components; I had to run the rule twice in order for things to update properly.  After digging around here and finding no real answers, I ticked the 'fire dependent rules immediately' box on the rule's options.  That sorted it...the rule now only runs once and updates as expected.

 

rob_0-1678408725853.png

 

IV Pro 2020.2
Message 13 of 13

jchaisson2H9RZ
Contributor
Contributor

Hello All, 

 

I have been battling with this myself off and on for a while now and this morning I figured out why this happens, and I can't help but laugh as to why. Like most code errors it's the simplest fix staring at you in the face. you need to pay attention to what you are saying what parameter equals what and that the code is in the correct order.

 

Example: 

Parameter("MidRail", "d23") = Parameter("ToePlate", "TP_MPA")
Parameter("ToePlate", "TP_MPA") = 75

 the order of this code will result in needing to run the code twice, even though it will run without errors the value you are trying to pass is established after the passing of the value and is why when running twice it updates.

 

now if you reverse the code order....

Parameter("ToePlate", "TP_MPA") = 75
Parameter("MidRail", "d23") = Parameter("ToePlate", "TP_MPA")

 now my code runs and updates properly without needing to be ran twice.

 

there's no code, tricks or any fix to make something update if your code is out of sequence. 

 

Hope this helps everyone. please mark as Solution if this helps.

0 Likes