Design and Manufacturing solutions through Digital Prototyping and Interoperability

Tag Archives: Inventor

Autodesk Inventor API: Assembly Document Hierarchy

We will look briefly at raw document references in this article, and then take a bit of time stepping into the Assembly Document container hierarchy in a follow up.

For the scope of this discussion, I will limit that object hierarchy as follows:

Document -> AssemblyDocument -> AssemblyComponentDefinition -> ComponentOccurences -> ComponentOccurence



Assembly Components

This is what cleaned up my code tremendously. I am dividing into parts so that it is (hopefully) easier to digest.

Assembly Component Occurrences are all components in an assembly, which contain Occurrences, or each component. This section will discuss using these, and the functionality associated with extracting each portion.

Assembly Component Definition

The complete component container; similar to the CAD Bill of Materials (BOM), except that the actual BOM definition data is contained separately inside this structure.

Base Object Class: AssemblyDocument

Type: Standard Object

Object Definition: AssemblyComponentDefinition

Returned By: AssemblyDocument.ComponentDefinition Function

Access to the Assembly component structure is performed through this object. We need to declare an ‘AssemblyComponentDefinition’ object, and assign it with data from a call to the Assembly Document’s ‘ComponentDefinition’ function.



Now that the Assembly Component Definition is filled, it is time to do some digging.

Component Occurrences

As you might expect, these are the containers that each component document is present in.

If a part definition occurs 10 times in an assembly, there are 10 Component Occurrences, and all 10 will show up in this container. The benefit here is that skeleton and reference files are not part of the ‘Assembly Component Definition’ structure, so they don’t get in the way here.

Base Object Class: AssemblyComponentDefinition

Type: Collection Object

Object Definition: ComponentOccurrence

Referenced at: AssemblyComponentDefinition.Occurences

The Occurrences collection is the whole enchilada of Component Occurrences, which you can access directly.

Now we can declare a ‘ComponentOccurence’ object, and use it to inspect each ‘ComponentOccurrence’ that exists in our ‘AssemblyComponentDefinition’.

In this example, I used a For Each function to pull each component.


This is a great way to quickly run through the Assembly and get every component. What follows is more functionality when you want to be specific about what you are getting.

Occurrence Enumeration

This object goes hand in hand with the next function. While its complete functionality is still not quite understood by me, this object acts as a container to catch a collection of Component Occurrences, and disseminate them by type into an intelligent object with appropriate functions.

Base Object Class: ComponentOccurences

Type: Collection Object

Object Definition: ComponentOccurrencesEnumerator

Referenced At: itself as dimensioned object

In the last example, we bypassed the need for this and iterated through our Assembly Component Definition’s collection of Components directly, like a book, one page at a time. However when we want the Assembly Component Definition to hand us a big list of components, we need somewhere to put them.  The Inventor API has provided this container for that purpose.

We need to define the ‘ComponentOccurrenceEnumerator’ object for the next section.


‘ Define the Component Occurrence Enumerator 
Dim oLeafOccs As ComponentOccurrencesEnumerator

All Leaf Occurrences

Leaf Occurrences are part files in an assembly, the end of any branching in the structure.

Base Object Class: AssemblyComponentDefinition

Type: Function

Function Call: Occurences.AllLeafOccurrences

Returns: ComponentOccurrence

This function returns the very same Component Occurrences as we iterated through previously, however this function only returns a collection of those components that represent the end of assembly branches, Part or ‘Leaf’ objects.

While we were able to peruse the Assembly Component Definition’s components like reading a book, in this function, the Assembly Component Definition object will dump an appendix in our lap.

Here, we will fill our Component Occurrence Enumerator by a call to the Component Definition’s ‘AllLeafOccurrences’ function. Then define another Component Occurrence to represent and investigate each Leaf Occurrence that is in our filled Enumerator.

Example :

All Referenced Occurrences

The Inventor API will also permit users to extract all occurrences of specific Inventor documents.

Base Object Class: AssemblyComponentDefinition

Type: Function

Function Call: AssemblyComponentDefinition.Occurences.


Returns: ComponentOccurrences

This function will return all instances of the specified document, at any level within a Component Definition.

This example takes a file name, and returns all occurrences of it that exist. It uses a call to opened documents expecting that if it exists, Inventor has it opened. Some good bounds checking could be applied to catch any error associated with an unopened file.


Closing Thoughts

I used this code to automate the production of drawings, running out as many as 20 at a time, right out of an assembly drawing file. I added substantial enhancements so that each drawing contained views, parts lists, as well as automating the population of various key iProperty values as well.

Help Button

I hope this helps you get a jump start on iLogic Assembly code as much as it did for me. If you’d like more information on Inventor, iLogic, or even how we built the drawing generator, stop by Design & Motion.



Mod The Machine article “Accessing Assembly Components” from 2009

The Autodesk Inventor 2014 API chart

Mod the Machine Article “Understanding File References” from 2008

Autodesk Inventor API: General Document Notes

It has been some time since I was regularly programming. My background was C++ and I was moving to C# when, well, I started writing; it appears as though there is only enough time to either research engineering software, or research software API.

Recently I decided I wanted some drawing automation; something to take care of the repetitive tasks beyond a good template. Being quite detail oriented, I like a complete drawing. This requires a lot of copying parent exploded views, parts lists, and so forth. While creating an iLogic drawing iProperties checker, I thought iLogic could help me with the drawing creation as well.

What follows is a collection of key notes that I made during my iLogic Assembly document function research; these are the same functions we used to develop the automated drawing creation tool.

Autodesk Inventor API Chart

We will look briefly at the general Document class in this article, and then take a bit of time stepping into the Assembly Document container hierarchy in a follow up.


It is very important to understand the Inventor assembly document structure and hierarchy. Each component in an assembly is a Document. Each Document is simply a reference to a file that is, or will be upon saving, stored on a file server or local drive.

Documents however can be interpreted in numerous ways. In our case, Documents represent Parts, Assemblies, Spreadsheets, Drawings, etc. Inventor has Class Objects that have intelligence built in to deal with how an Assembly Document, for example, will behave.

Just Give Me Everything

First, we can get all file references by calling for ‘AllReferencedDocuments’. This function is basically a document dump.

Base Object Class: Document

Type: Function Call

Object Function:  AllReferencedDocuments

Returns: Document object

This function does a jam-up job of returning all FILE instances within any Document object. Only one instance per file is returned, regardless of how many times a part is used in an assembly.

This function is not reserved to Assembly files and will work on any Document class based object. This makes it a great, universal front end build for code that needs to work in a broad range of Inventor documents.

Caution should be used to provide significant bounds checking as to what type of Document is being returned, as AllReferencedDocuments will return anything at all; Spreadsheets, Part files, you name it.

Example: (working with only the part files in a document)

‘ Get the active assembly document.
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
‘ Iterate through all of the documents referenced by the assembly.
Dim oDoc As Document
For Each oDoc In oAsmDoc.AllReferencedDocuments

‘ Verify that the document is a part.
If oDoc.DocumentType = kPartDocumentObject Then
Dim oPartDoc As PartDocument
oPartDoc = oDoc

‘Do something with the part document here

End If

This is great when you want everything, but I need to see some structure, and having some refinement would be nice. We’ll return with those details and the Assembly Document container hierarchy in the follow-up article.


Mod The Machine article “Accessing Assembly Components” from 2009

The Autodesk Inventor 2014 API chart

Mod the Machine Article “Understanding File References” from 2008

And they’re off! – The (Great?) Inventor Constraint Race

Ok so this one is a bit silly,  but it has practical implications.

In Inventor these days, there are so many ways of sticking one bit to another bit. Constraints, Joints, the “Assemble” command, iMates, or even no constraints at all in certain skeletal modelling workflows. So which is the most efficient!? Like anything, there is no cut and dried answer to that question, that would apply to all cases. It’s a matter of horses for courses.

Horses RacingCredit: Paul Kehrer“Full Stretch”

Just for fun, I thought I’d put a few of these methods to the test in a somewhat controlled environment. I decided to eliminate some variables by keeping the test to one type of connection, a simple pin in a hole, multiplied a few times.

The “horses” are:

  • #1 – “New-fangled Assemble”   Place and “assemble” one by one. Thanks to Scott Moyse for entering this horse in the race.
  • #2 – “Drag-Connect”   Place all then drag-connect.
  • #3 – “Trusty Old Constraint”  Place all then manually constrain.
  • #4 – “G’day iMate”   Named iMates for automatic connection on placement. Thanks to Peter Crawley for entering this horse in the race.
  • #5 = “All the iMates”   Right-click and select “Place at all Matching iMates.”  Another entry courtesy of Peter Crawley, but it was disqualified from the race for alleged doping after finishing in only 2 seconds.

I thought I’d introduce them first, one by one…

And now…. without further ado, place your bets, and let’s go racing!

Did you make any money?

Feature image credit: A Day At The RacesGary J. Wood

Autodesk Inventor : How to Change Welding Material

I was kicking about the Autodesk Discussion Groups and found this question:

Default Weldment Material [How to change it?]

Your drawing Parts lists show the material for all welded assemblies (weldments) as Welded Aluminum-6061. Using the assembly iProperties in the weldment gets you nowhere, as the material is deactivated. This frustrated me for some time too, and the solution is sadly quite logical: It’s a weld bead, so go to the Welding Bead section!

From the Ribbon, navigate to the Weld tab. Under the Process panel, pick Welds to go to the area that you would add your welds.

In the Assembly Browser, pick Welds -> Beads. From the context menu, pick iProperties.

Inventor 2015 Weldment Bead Material

The Physical tab will now allow you to change the Material. This makes perfect sense since your assembly does not have a material, but you are adding material in the welding process. (You can actually make the change one level up from the Welds collection header.)

After the change, the material will update in your Inventor Assembly Parts Lists.

Back to Basics – 4 Autodesk Inventor Techniques You Should Know

With so much focus given to new features / technologies by CAD bloggers / vendors, it’s easy to forget the little things. I thought I’d start a series of posts that deal with simple, time-saving workflows and tricks that you may have missed along the way while learning to use Inventor.

This first part will demonstrate 4 simple tips / techniques, in a video below:

  1. Two-click Center Workplane
  2. ‘Derive’ Workflow
  3. Convert projected geometry to ‘Construction’
  4. Workplane normal to path for sweep

Two-click Center Workplane

Very often you want to place a workplane exactly halfway between two faces or other planes. By selecting the workplane tool and simply clicking the two faces, you can do just that. In the 2015 release of the product, this workflow was expanded to use any two faces! They no longer have to be parallel, or similar in any way.

‘Derive’ Workflow

I consider this to be one of the most powerful and useful workflows in Inventor. Not only can you use it to maintain adaptive geometry with a source part or assembly, but you can also bring through parameters and work-features, or even use it to mirror or scale a component! Very handy, like these paper towels.

Convert projected geometry to ‘Construction’

I’m sure you’ve all come across that annoying warning: “Cannot constrain or dimension reference or fixed geometry.” This often happens when you think you are clicking on an unconstrained sketch feature, but there’s actually some projected geometry underneath. I find that it helps to project in the geometry you need (within a part only, please don’t use cross-part projection in assemblies!!! Use derive instead) and then turn all of that geometry to construction, before creating your own sketch geometry using the construction features as reference. This will help you to build much more reliable sketches.

Workplane normal to path for sweep

I use this one EVERY time I do a sweep. Often the start of your sweep path is at a point in space with no other reference geometry nearby. This allows you to quickly create a plane on the endpoint that is normal to the path.

Hopefully some of you may find at least one of these tips useful. If you have tips of your own that you’d like to share, please share away in the comments below!

Feature image credit: “Ideal Insurance, Moor Green Lane – 123” by Elliot Brown

Who gives a Flying Function? I do…

Equation Curve in 2D SketchEquation Curve Command in Inventor’s Sketch Environment

The 2D equation curve function has been available in the Inventor sketch environment for a few releases now, but I haven’t seen all that much written about it, and don’t know too many people who are using it. For those reasons, I thought I’d do a quick post with an example of it’s use.


Before it effectively became NASA in 1958, NACA (National Advisory Commitee for Aeonautics) was a U.S. Federal Agency that was set up to undertake, promote and institutionalize aeronautical research. One of the important results of their research was the development of a series of aerofoil profiles, in the 1940s, that are still in use in aircraft and marine design today. A NACA aerofoil is one whose shape is determined by one of a series of mathematical equations. In this example, I used the “4-digit” symmetrical equation to create a non-cambered aerofoil. My next challenge is to create a cambered profile using the relevant equation.

The Math

The following is an excerpt from this wikipedia entry:

Equation for a symmetrical 4-digit NACA airfoil

Plot of a NACA 0015 foil, generated from formula

The formula for the shape of a NACA 00xx foil, with “xx” being replaced by the percentage of thickness to chord, is:[3]

 y_t = \frac{t}{0.2}c\, \left[ 0.2969 \sqrt{\frac{x}{c}} + (-0.1260) \left(\frac{x}{c}\right) + (-0.3516) \left(\frac{x}{c}\right)^2 + 0.2843 \left(\frac{x}{c}\right)^3 + (-0.1015) \left( \frac{x}{c} \right)^4 \right],[4][5]


  • c is the chord length,
  • x is the position along the chord from 0 to c,
  • y is the half thickness at a given value of x (centerline to surface), and
  • t is the maximum thickness as a fraction of the chord (so 100 t gives the last two digits in the NACA 4-digit denomination).

The Model

I created a 2D sketch in Inventor 2015, and used the equation curve tool (hidden in the “Line” dropdown menu) to input the formula above.

Inventor 2D Equation Curve2D Equation Curve in Inventor Sketch Environment

If you’d like to recreate this, here is the formula in a copy-paste-able format:

( ( t / 0.2 ul ) * chord ) * ( ( const1 * sqrt(x / chord) ) – ( const2 * ( x / chord ) ) – ( const3 * ( ( x / chord ) ^ 2 ul ) ) + ( const4 * ( ( x / chord ) ^ 3 ul ) ) – ( const5 * ( ( x / chord ) ^ 4 ul ) ) )

The equation only creates one half of the curve, so I used the mirror tool with the “Self Symmetric” option ticked to get the leading edge. The trailing edge is a very short vertical line.

The iLogic (of course there is iLogic, it’s me, iGav)

It’s all well and good to have a static aerofoil section for an example, but for any practical application, you’d want to be able to adjust the shape and parameters to get exactly the shape you require. An iLogic form provides a really easy-to-use interface for adjusting the chord length and thickness of the section.

A form to adjust the aerofoil modelAerofoil Parameters can be Adjusted with an iLogic Form

While I was there, I thought I’d add a wing plan sketch with some control planes and a series of stations. This turns the aerofoil section into a wing shape and allows me to adjust the leadin and trailing edge taper angles.

If you’re interested, here’s the Inventor 2015 model file: Aerofoil iLogic Model

 If any of you have a particular equation for something interesting, that you’d like to see applied to a model, please get in touch.

Feature image credit: simpleinsomnia – “Students study an equation on a chalk board” – Unedited


Join the Community