I have posted about a similar subject a while ago. The idea is to copy and paste an existing iLogic rule in a series of Inventor files.
In the solution that I offered originally I was able to accomplish this but there was a missing link.
What good would an iLogic rule be that was created in an automatic way when at the same time you cannot decide when the rule will run?
This kind of defeated the whole purpose of automatically adding AND running rules on certain events throughout multiple files.
One of the loyal readers of the blog came to the rescue.
Megajerk has graciously provided the source code and the executable for a VB.NET tool that completely automates the process. So I decided to post this tool on the Inventor support blog on behalf of him.
The tool is called "Code Injector" and can be downloaded from here.
After unzipping the tool to any location on your disk drive and when you start the file …\Code Injector\Code Injector\bin\Debug\Code Injector.exe, you will see following dialog:
Fig 1: Code Injector in action ( (click here to see a full size screenshot)
Note that I have selected two part files in the dialog, defined an iLogic rule that displays the name of the active document and the rule gets triggered on open.
From the way the buttons in the dialog are labeled you can easily figure out most of the other tool options:
- Open multiple files from the types ipt, iam and idw from a folder
- Either copy and paste the rule text or import it from an existing text file
- Overwrite rules with duplicate names or not
- Run rules on creation or not
Once the tool has finished , you will se an Operation complete dialog that you can dismiss.
One small quirk is that rules that get added and that are set to trigger before or after save, ignore the setting of the "Run rules on creation" checkbox.
Such rules will automatically run while the Inventor files get saved by the tool. It is a sort of chicken and egg thing which is difficult to avoid.
Rules that trigger on open obviously obey the checkbox. Thanks again to Megajerk for sharing his tool with all of us.
Bob



Subscribe
Hi Bob - this is exactly what I am looking for. However, when I download the .zip file and unzip it, my Bin folder is completely empty...
Posted by: Cory McConnell | 02/28/2012 at 05:29 AM
You should be able to find the compiled .exe in : \Code Injector\Code Injector\obj\x86\Release
folder.
Hope that helps!
- MegaJerk
Posted by: MegaJerk | 02/28/2012 at 09:13 AM
Corey,
The code that I originally posted was compiled as debug code. Please re-download the zip file. I compiled as a release version and as megajerk explained, you can find the exe in ...\Code Injector\Code Injector\obj\x86\Release but also in the location you would normally expect it at ...\Code Injector\Code Injector\bin\Release
Bob
Posted by: Bob Van der Donck | 02/28/2012 at 10:44 AM
I uploaded yet another version.
The change is on the “Run rule” checkbox. By using the “Delete rule after run” radio button, you can now add a rule, run it and immediately remove the rule.This is an option if you want to perform a one time operation on your files via iLogic without keeping the iLogic rule around permanently.
I also made another change that when you prefer to add the rule without running it, I now prevent the rule from running automatically when the event trigger is set to Before or After save.
Enjoy
Bob
Posted by: Bob Van der Donck | 03/21/2012 at 05:44 PM
Hi,
I'm impressed with your code.
However, I run IV2011 and your program will only run on IV2012.
Can you compile a version that will run with Autodesk Inventor 2011?
Regards,
Yoni
Gaia
Posted by: Yoni - Gaia | 05/22/2012 at 02:22 AM
Hi Yoni,
You can download the 2011 version from here:
http://beinginventive.typepad.com/files/CodeInjector/Code%20Injector%20-%202011.exe
If I am not mistaken this version will run on the 3 latest versions of Inventor (2011, 2012 and 2013).
Bob
Posted by: Bob Van der Donck | 05/24/2012 at 04:50 PM
Hi guys! Great little utility here and it has helped save a ton of time for me. However would it be possible to add the capability of running this on Inventor DWG files and not just the IDW files? That would be the cats meow!!
Regards,
Kenny
Posted by: Kenny | 06/20/2012 at 01:13 PM
I am working on it Kenny.
Once I have figured out how to programmatically distinguish between a DWG generated by Inventor and one created by AutoCAD, I'll post a new version of the tool.
Bob
Posted by: Bob Van der Donck | 06/21/2012 at 05:34 PM
The tool now also works on files with extension DWG. I decided to not filter out the AutoCAD DWG and uploaded the new code that you can find in the regular spot:
http://beinginventive.typepad.com/files/CodeInjector/Code%20Injector.zip
Bob
Posted by: Bob Van der Donck | 06/22/2012 at 04:54 PM
Wow thanks for the fast response Bob and for implementing DWG capability!
Posted by: Kenny | 06/24/2012 at 11:22 AM