Autodesk Inventor – iLogic to API

  • Updated

By Scott Cunliffe

The iLogic interface has everything you could possibly need to know right there within the confines of its IDE, but this cosy world is not reflected in the VB Editor nor Visual Studio IDE.  It can be hard to find the objects you need to use, and even harder to know how to use them.

You may be familiar with googling code and mashing it up into the rudimentary form you need to accomplish the task at hand, but lack the knowledge or experience to get something off the ground yourself.  Being lost in the dark like this can be quite a confidence shaker, so this may be of use.

To set the scenario, imagine you want to do something with Design View Reps, but aren’t sure how to access them.

Firstly, open up the VB Editor and paste in the following code:

Sub DetectObject()

Debug.Print ThisApplication.Caption


End Sub

Next, highlight the text for “ThisApplication”, right-click and select Add Watch

With an Inventor model open, select a View Rep in the browser, then run the code in the VB Editor.

If the Watch Window is not visible in the VB Editor, open it from the View menu.

The top level of the Watch Window will display the ThisApplication object.  In this context, ThisApplication is the entire Inventor application and so everything contained within it must be a subset in object hierarchy.

Expand the node through to ActiveDocument, and then SelectSet.  If you have tried the My First Plug-in tutorial, you’ll be familiar with SelectSet and how useful it is.  Item1 is the object you have selected:

Here we can see it is of Type DesignViewRepresentation which is from the pluralised collection DesignViewRepresentations.

Expanding through Item1 to Parent, we find RepresentationsManager, and similarly its parent AssemblyComponentDefinition, and so on.

We now have a route to this object.  By tracing back through the Object Browser, we can get the correct nomenclature.  We also need a little bit of experience to know that we need oDoc as in the following, but if you are reading this with interest this should already be familiar.

Dim oDoc As AssemblyDocument

Set oDoc = ThisApplication.ActiveDocument



The trail stops at Item, but we can use Intellisense to determine the actions we can carry out on it:


For example, I may wish to Activate this View Rep if it is not already activated.

I hope this helps in your coding endeavours. 

Credit for this great tip comes from Brian Ekins at Autodesk.  It was discussed during his presentation at AU this year, and I felt it needed to take a front seat rather than living halfway through his recorded presentation.  Tune in to Brian’s AU presentation for more top tips.

Was this article helpful?

1 out of 1 found this helpful

Have more questions? Submit a request



Please sign in to leave a comment.