<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=217263058604764&amp;ev=PageView&amp;noscript=1">

Capture Autodesk Inventor Version in an iProperty with iLogic

by Jonathan D. Kriek on Mar 23, 2015

AutomationwithKriek

Howdy!

This is Jonathan Kriek for KETIV. I work daily with customers to help them achieve their goals within the PDM, PLM, and automation spaces. A particular passion of mine over the last 17 years has been developing solutions that help automate everyday repetitive tasks. Naturally this overflowed into the design and engineering realm, specifically for Autodesk software. I was overjoyed when I was asked to write for this blog, because if I'm honest, I can talk about this stuff till the cows come home ;)

With the introductions out of the way, let's get to today's topic!

Introduction

Today I'll be showing you how to capture the Inventor Version reserved property that you see in Windows and put it into a iProperty where you can actually use it.

What you see is what you get

Let's take a look at an Inventor file from Windows Explorer


WindowsExplorer_21315

If we right-click the file and choose "Properties" we'll see Window's generic file information details.


WindowsProperties

Now you can see the Inventor "iProperties" tab.


WindowsiPropertyTab

Launch the iProperties by clicking the button. Now we have a read-only look at all the available iProperties inside the Inventor file. If you choose the "Details" tab you'll see some Inventor version information specific to that file.

WindowsVersion_21315

Use Case

You may be thinking "Great Jon, but how do I use it?". Well like you there has been many users on the Autodesk discussion forums over the years asking the same question. The "Created with" and "Last update with" properties are not standard iProperties so you can't just pull that information and use it. It's only available to the Inventor API.

I pinged the API king Brian Enkins at Autodesk and he was kind enough to give an example method: 

"The information is available through the API using the SoftwareVersion object which is returned from the Document object using the SoftwareVersionCreated and SoftwareVersionSaved properties."

I've taken that example and turned it into an iLogic script that also adds that information into a Custom iProperty that you can then use on a drawing for example. Ideally you would then set the iLogic Event triggers to "On Save" so that iProperty can get updated. We'll go into more details on that process as well as a sample part, but for now let's look at the code!

Join the Autodesk Virtual Academy community and never stop learning. 
AVA_CTA.png

 stop(); // Hammertime!

Sorry, code humour...

iLogicCode

Dim doc As Document = ThisDoc.Document
Dim result As String
Dim vers As SoftwareVersion = doc.SoftwareVersionSaved
result = vers.DisplayVersion
Dim propSet As PropertySet 
propset = doc.PropertySets.Item("Inventor User Defined Properties") Dim invProperty As Inventor.Property For Each invProperty In propSet If (invProperty.Name = "DocVersion") Then Return Next invProperty = propSet.Add(result, "DocVersion")

Note: if you are already familiar with iLogic, then you can skip this section or if you'd like you can skip to the bottom to download the example file

The next step is creating the iLogic rule itself. This can be done from the iLogic browser pane. If you don't see it go to the top ribbon menu in Inventor and click "Manage" then click on "iLogic browser" under the iLogic section.

iLogicBrowser

 

  • In the iLogic browser right-click empty white space and choose "Add Rule".
  • (or from the ribbon "Add Rule")
  • Give it the name "InventorVersion" and click ok.
  • Then paste the code into the open window and click ok

As soon as the iLogic window closed it ran the rule. So you can now look at the custom iProperties on the part and see the following:

customiProp

 

You can right-click on the rule and run it *gasp* manually at any time, but this is automation my friend so we're going to MAKE IT SO.

Event Triggers

If you look at the iLogic section on the ribbon you'll see a button called "Event Triggers", go ahead and click on it now.

eventTriggers

 

Once the dialog box comes up click on the "Before Save Document" event text and then click the "Select Rules" button. Then check the box next to the rule "InventorVersion" and click ok.

eventTriggersSelect

For this example, the iLogic rule is inside the test document, however you can create an external rule (not in the document) and apply the event trigger to that rule instead.

I hope you found this useful!


Download the file here

Topics: Autodesk Inventor, Automation, iLogic, v2015

Subscribe to Email Updates

Posts by Topic

see all

Meet the Authors 

Kanwar
Kanwar Anand
 
Jav
Javier Chavez
 
JDK
Jonathan D. Kriek
 
 Rich_S_Pic_for_Web
Rich Sanchez