Monday, September 14, 2015

iLogic Authoring Tools

Autodesk Inventor comes with a built-in iLogic rule editor.  The iLogic rule editor, (Integrated Development Environment), can be very useful when learning to write iLogic code.  The IDE provides a built-in Snippet library as well as instant access to model parameters, etc.

But as iLogic rules become more complex or lengthy you may find waiting for the rule editor to open tedious an inefficient.  Those who know me will say I'm not a terribly patient person.  Come on already, I've got code to write!!

Additionally, as you begin to integrate more complex Inventor API calls and general .NET functions you'll find that the native rule editor does nothing to help in terms of Itelli-sense or syntax warning such as parenthesis matching.  It doesn't hurt your development efforts, but it doesn't help either.  The old adage, "If you're not helping, you're in the way", comes to mind.

In previous lives many of us used Windows Notepad to write AutoCAD LISP code.  This same simple workflow can apply to iLogic rule code as well.

Given the fact that iLogic code is not compiled and is in fact a simple ascii text file, you can virtually use any text editor you wish.  My favorite is Notepad++.  Notepad++ is an open-source text editor, is distributed free of charge. NOTEPAD++ DOWNLOAD

One of the things that makes Notepad++ such a great authoring tool for iLogic is that while it does a great job of editing text files, it can be configured to recognize the programming language format you're using and provide really nice features like color formatting, auto-complete, etc.

Additionally, there are numerous plug-ins for Notepad++ available, also free of charge. One of my favorite plug-ins is 

The following is a step-by-step process to configure Notepad++ to recognize the .iLogicVb file format.

1)  Navigate to Notepad++'s Settings>Style Configurator menu.
2) Scroll down the Language list selecting VB/VBS.
3) Add iLogigVb as a recognized user extension.
4) Adjust your color settings as desired for Comments, Numbers, Keywords, etc.
5) Add any special iLogic keywords that you wish, (keywords should be entered in lowercase only, regardless of how they're typed in the code)


This configuration gives you this:

Instead of this:

I should have added the disclaimer at the beginning of this article that to really make this workflow shine you should be using external rules.  When using external rules simple make edits in Notepad++, jump over to Inventor and run the rule.  No more waiting for the native rule editor to load the code.

Notepad++ has the added benefit of line numbers, and natively collapsible code due to the association to the VB file type.

If you're doing serious iLogic development you really owe it to yourself to check out the benefits of using Notepad++ as your iLogic development platform.


5 comments:

  1. Come on TIM, the suspense is killing me. What is your favorite plugin?

    "Additionally, there are numerous plug-ins for Notepad++ available, also free of charge. One of my favorite plug-ins is
    "

    making it invisible?

    Great post, I love Notepad++

    ReplyDelete
    Replies
    1. Adrian,
      Sorry to take so long to get back, but my fav of all time is FingerText. Allows you to create shortcuts to insert smart snippets

      Delete
  2. We've got to stop meeting like this Adrian. ;-)

    I would argue that if you are contemplating serious development with iLogic that you should abandon iLogic altogether and use Visual Studio Express (free) and turn your code into an add-in. My reasoning for this is that since you'll likely be reading the API documentation anyway, iLogic will only get you so far with its included methods and is horrendous to try and debug after the fact.

    Otherwise you can find yourself in the situation I did last week where someone had written an iLogic rule that was ~4000 lines long.

    If however the iLogic you are writing is something simple; less than 100 lines for arguments-sake then Notepad++ is absolutely the way to go.

    A tip I always use with Notepad++ is the Preferences -> Backup -> verbose backup option. This gives you a folder containing a copy of every file you save inside of Notepad++ local to the file you have open.

    Cheers,

    Alex.

    ReplyDelete
    Replies
    1. edgecrusher,

      I see your point about serious development, but working for an Autodesk VAR one of the most common client requests is that they want code they can manage...meaning they want clear text that they can edit within the iLogic IDE.

      I don't like 4000 line rules anymore than anyone else and would recommend a code structure that splits codes into manageable, reusable smaller rules.

      Delete
  3. I wonder whether it is possible to setup Notepad++ in sush a way that it can collapse code between line strting markers "'[","']" and "'''" (consequent lines starting with tripple "'")?
    Those are built-in native iLgic Editor advanced formatting.

    ReplyDelete