Learning to write iLogic Code

Learning to write iLogic Code

Anonymous
Not applicable
4,812 Views
2 Replies
Message 1 of 3

Learning to write iLogic Code

Anonymous
Not applicable

Hello,

I have been slowly implementing iLogic rules into our drafting department. However, my method for developing these rules consists mostly of finding something very similar that someone else has written and modifying it in very basic ways to fit my needs. If there is an issue with the code (which there usually is), my only option is to tweak one thing at a time with barely educated guesses until I get it to work... or give up. This is rather limiting and very time consuming. What would be the best way for me to learn how to actually write the codes myself (AKA, starting with a blank rule and typing). I understand that the internet is still going to be a valuable tool for ideas and diagnostics, however it would be very helpful to have a good foundation of understanding and some knowledge. Suggestions?

Accepted solutions (1)
4,813 Views
2 Replies
Replies (2)
Message 2 of 3

MechMachineMan
Advisor
Advisor
Accepted solution

I would say that learning programming in general and getting a good grasp of how it works is going to be more beneficial than simply trying to piece together iLogic. The documentation on iLogic is spotty, but there are many, many resources available for learning programming languages like vb.net and vba.

 

VBA is used in the Inventor macro environment (as well as in Excel!), and vb.net can pretty much be used directly in the rule environment in Inventor.

 

The programming help resources has lots of resources there.

 

Some peoples signatures (like mine) have links to resources.

 

The best way to is to first learn what the API is and how it works - by looking at the API overview and object model.

 

Then I would start with basic rules and slowly add functionality so you can understand how things work. Before you get to far in, read about CODE encapsulation and DRY methodology. If you get stuck, spend a reasonable amount of time trying to solve it yourself - by searching the internet or simply using trial and error techniques - and then if you are still stuck after over an hour, then ask on the forums. The grit will teach you more than "cheating".

 

Make sure you read up about vb.net too and the available libraries and such to begin with as they are all heavily related with iLogic.

 

Books that I used and enjoyed:
"Becoming a Better Programmer" - O'Reilly

"Excel VBA and Macros YYYY" - Mr. Excel Library


--------------------------------------
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
Message 3 of 3

AlexFielder
Advisor
Advisor

I agree with everything @MechMachineMan says; all too often people will post something like "Help me Obi-wan, you're my only hope" without giving us any idea what effort they have put in themselves.

 

I've been writing iLogic rules for around a decade now and a lot of the most useful have (in all honesty) been cobbled together from other sources. I'm of the opinion that, barring some pretty niché use-cases, most of the things that can be accomplished with iLogic have already been done in some way.

 

One tip I do have when searching online (using google etc.) is to be specific: "autodesk inventor ilogic {your query}" or "autodesk inventor API {your query}" are excellent starting points.

 

It'll help you massively if you create a shortcut to the Inventor API documentation on your desktop. 2019 help is located here:

 

C:\Users\Public\Documents\Autodesk\Inventor 2019\Local Help\admapi_23_0.chm

 

Using the api help online is a good idea too - @MechMachineMan has a link to the post I put up a while back (and updated recently for 2019!) that allows you to set up an Inventor API-help search shortcut inside of Google Chrome:

 

https://forums.autodesk.com/t5/inventor-customization/searching-the-online-api-help-without-having-t...

 

Here also, is an article I wrote for Design and Motion detailing my top ten tips for iLogic which still (I believe) hold water:

 

https://designandmotion.net/autodesk/inventor/inventor-top-ten-ilogic-api-tips/

 

Incidentally, the Commenting section of that article details creating Visual Studio-style summary header comments for methods; this is something I recently discovered you can now do natively inside of the iLogic rule window!

 

My best advice is to keep plugging away at it, and don't be afraid to ask questions on here (so long as you show your "working out")

 

🙂

 

PS. When you do invariably go searching for solutions using my Google suggestion above it helps to put the object or objectcollection that you want help with i.e. DrawingView or AssemblyDocument or DrawingDimension etc. in the {Your query} part.

0 Likes