Thursday, October 12, 2017

Saving a PDF of a Drawing Using iLogic

As you probably have noticed, Inventor iLogic rules are a frequent topic in this blog.  Sharing some ways I have used iLogic in the past is a subject I like sharing with others.  One of my first rules, that I was pretty proud of, was the ability to have iLogic save a PDF of Inventor drawings.  I tackled this because it is a task a large number of Inventor users need to perform.  I was able to figure out the code and I shared it in a YouTube video and in an Autodesk University class in 2012.  With the updated Event Triggers in Inventor 2018.1, I figured it might be time to updated the rule and share it with all of you.

The most popular question I got about the previous version was, "How do it get it to print all the sheets?"  By default, Inventor uses the last settings for one sheet or all sheets.  I had not figured out how to do that programmatically.  So I wanted to figure that out for this go round.

Like any other coder, I went to the web for help.  I pretty quickly found Curtis Waguespack's post.  So I used this code and my code to create what I call Franken-code (i.e. Frankenstein Code).

If you are interested in the code, you can download it from here.

The code is documented, but here is an explanation and demonstration of the code.


Happy Coding!!!

Using The New iLogic Event Triggers

I have been using iLogic since it was acquired by Autodesk and one of the biggest headaches with iLogic rules was setting event triggers for legacy files.  For example, I could write an iLogic rule that would save a PDF of a drawing.  It was simple to add the right event triggers to your template, but what about all the legacy files, those need the same event triggers.

I would typically show people how to added the triggers and told them to add the event triggers to the legacy files as they worked on them.  I didn't like that answer, but that is the way it had to be.  The Autodesk programming gurus, that run the Being Inventive blog, created the iLogic Code Injector, which would add rules to selected files.  You can find a write up on that here.  The biggest draw back there was that you were putting stand-alone rules in each of the files and not adding Event Triggers to External Rules.

In my last post, I mentioned an idea that was posted to the Inventor Idea Station, which I had offered feedback on, has been implemented.  The idea was for what I call Global Event Triggers.  In the case of the old Event Triggers, you were embedding in a file a trigger to run a rule on a certain event.  Now the Event Triggers have been reformulated in the Inventor 2018.1 Update.  Starting in the updated release, you can set Event Triggers for all files, or files of certain types.  For example, if you created a rule that created a PDF of the file, you most likely would not want that for your 3D model files.  So the new Event Trigger Dialog box allows you to set an event trigger for that rule when certain events occur on Drawing files.  


I really like the redesign of the iLogic Event Triggers, especially for rules that you want run on all files, or at least of all files of a specific type.  And setting them up could not be any easier.

1.  Open the Event Triggers dialog box
2.  Select the Tab for the file category
3.  Drag the iLogic rule from the left pane to the correct Event in the right pane

Here is a video I created that shows how to set up an Event Trigger using the new Event Trigger dialog.



I really like this new feature works.  I hope you do to.  Happy coding.