by Jonathan D. Kriek, March 23, 2015

Capture Autodesk Inventor Version in an iProperty with iLogic

Back to Blog

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

Back to Blog

Leave a Reply

Your email address will not be published. Required fields are marked *

More stories from KETIV

Blog

KETIV Technologies and ANSYS Partner to Bring Advanced Simulation Solutions to the Manufacturing Industry

               FOR IMMEDIATE RELEASE: BREA, CA, September 19, 2018 – KETIV, a premier engineering solutions provider and expert manufacturing consultant since 1983, has announced its partnership with ANSYS. KETIV and ANSYS, a global leader…

Read post
Blog

Your Parts Made to Order with Autodesk Fusion 360 and Proto Labs

Free quote and design analysis in a matter of hours and custom parts manufactured to your specifications in three days standard? All driven for a single CAD program? Sounds unbelievable, but that’s exactly what Autodesk Fusion 360 is offering…

Read post