Run rule in subassembly

Anonymous

Run rule in subassembly

Anonymous
Not applicable

Hi everybody,

There is an assembly with a Rule A (internal rule) in iLogic and a subassembly with a Rule B (internal rule) in the same file.

When I run the rule in assembly (Rule A), the rule in subassembly will not be run so I have to go to the subassembly and run Rule B too.

Is there any way to run AND update all the internal rules in the same file? (including rules in parts or subassemblies)

Thanks

 

0 Likes
Reply
Accepted solutions (1)
2,808 Views
8 Replies
Replies (8)

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Hi, with this rule you will then execute each internal rule of all the reference files called "RuleB".
This rule is executed in your master assembly. It is an example that I think could serve to improve your code in your main assembly.

Dim oDoc As AssemblyDocument = ThisDoc.Document

'define the ilogicAutomation
Dim iLogicAuto As Object 
iLogicAuto = iLogicVb.Automation 

Dim oRuleName As String = "RuleB" 
Dim oRule As Object 

For Each doc As Document In oDoc.AllReferencedDocuments
	On Error Resume Next
	oRule = iLogicAuto.GetRule(doc, oRuleName) 
	'run the rule
	iLogicAuto.RunRuleDirect(oRule) 
Next

 I hope this helps solve your problem. regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

ganesh_omkaar
Contributor
Contributor
Your code working-👌 Nice solution
0 Likes

t_fransman
Advocate
Advocate

Cant seem to get it to work. I have a form and a rule with same name in a sub assembly as the main. I have to open the sub every time I change the true false and run it in the sub. I just hides a version of the same part.. I want the rule to run in the sub assembly and event trigger is set when i properties change . Inveto2021

0 Likes

t_fransman
Advocate
Advocate

I am trying to run it nothing seems to happen . I am trying to get a rule in a sub assembly to fire when i change a true false in my Form. 

0 Likes

myronHBBUW
Contributor
Contributor

This works great!

@Sergio.D.Suárez how would you code this to change multiple rules?

0 Likes

sjoerd.van.der.eerden
Contributor
Contributor

I assume you could just use the same piece of code but with a differend rule name

0 Likes

sjoerd.van.der.eerden
Contributor
Contributor

hi, this code doesn't seem to work when the rule you're trying to update is located in a drawing. 

is there a way to modify it so it does work with drawings?

0 Likes