Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Run rule in subassembly

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
Anonymous
2371 Views, 8 Replies

Run rule in subassembly

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

 

8 REPLIES 8
Message 2 of 9
Sergio.D.Suárez
in reply to: Anonymous

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

Message 3 of 9

Your code working-👌 Nice solution
Message 4 of 9
t_fransman
in reply to: Anonymous

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

Message 5 of 9
t_fransman
in reply to: Anonymous

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. 

Message 7 of 9

This works great!

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

Message 8 of 9

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

Message 9 of 9

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?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report