iLogic run sub-assembly rule from top assembly

iLogic run sub-assembly rule from top assembly

Anonymous
Not applicable
3,947 Views
5 Replies
Message 1 of 6

iLogic run sub-assembly rule from top assembly

Anonymous
Not applicable

Is there a way I can command certain rules to run within sub-assemblies and parts from my top level assembly? I am controlling the dimensions of my design from my top level where I have a rule that is passing parameters to all my sub parts and assemblies, and this works fine.

 

The issue is that I am also running another top level rule that component replaces various sub-assemblies, and even although the parameters update in all my assemblies (those existing in my top-level and those yet to be swapped in) the rules in the assemblies that I am bringing in don't run automatically. I would like to be able to trigger them once they have been swapped in. I've tried using the 'After Open Document' event trigger on these assemblies, hoping that they are 'opened' when they are brought in by the component replace, but this isn't working.

 

I've alo tried restructuring my top-level rules so that the component replace rule runs first and the parameter update rule runs second, in the expectation that this will trigger the rules to run on the newly brought in assemblies as the parameters within them change after they become a sub-assembly of the active document (top-level assembly), but this doesn't work either which really surprised me 😞

 

Any help would be much appreciated!

0 Likes
3,948 Views
5 Replies
Replies (5)
Message 2 of 6

Jef_E
Collaborator
Collaborator

Hi!

 

This code sample will activate the rule with the name "show form" in all occurrences if they have a rule with that name. ofcourse, you can change the name on line 6.

 

Sub Main
auto = iLogicVb.Automation

' Set Rule name
Dim ruleName As String
ruleName = "Show Form"

' Get the active assembly. 
Dim oAsmDoc As AssemblyDocument 
oAsmDoc = ThisApplication.ActiveDocument 

' Get all of the referenced documents. 
Dim oRefDocs As DocumentsEnumerator 
oRefDocs = oAsmDoc.AllReferencedDocuments 

' Iterate through the list of documents. 
Dim oRefDoc As Document 

For Each oRefDoc In oRefDocs
	Dim rule As Object
	rule = auto.GetRule(oRefDoc, ruleName)
	If (rule Is Nothing) Then
	'Call MsgBox("No rule named " & ruleName & " was found in the document.")
	Else
	'MessageBox.Show(rule.Name, oRefdoc.displayname)
	
	Dim i As Integer
	i = auto.RunRuleDirect(rule)
	
	End If

Next 
End Sub


Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
Message 3 of 6

Anonymous
Not applicable

This worked for what i needed it to do. Thanks for the post

0 Likes
Message 4 of 6

vkulikajevas
Advocate
Advocate

Can This rule be rewritten to apply for External rule? I want to run an External Rule from a sub-assembly level.

Reference question here:

https://forums.autodesk.com/t5/inventor-customization/external-rule-executed-for-all-components-in-t...

0 Likes
Message 5 of 6

MechMachineMan
Advisor
Advisor

@vkulikajevas

 

Very possible... And already well discussed and discoverable with a bit of googling.

 

http://lmgtfy.com/?q=inventor+customization+%2B+run+external+rule+%2B+vba


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 6 of 6

vkulikajevas
Advocate
Advocate

Thank you 🙂

0 Likes