Wednesday, December 19, 2018

iParts and iAssemblies with the Inventor API

I stumbled upon this inconsistency in the Inventor API the other day.  I have method that finds an iAssembly row based on certain parameter values, much like the iLogic snippet that does the same.  In the method I have to find the columns I am looking for based on the parameter name.  I am able to find it by using the name property in the Column object.  It works great.

I then wanted to make a method that does the same thing but for iParts.  I figured that since they are very similar in how they work when using Inventor that the API would be the same.  I found that iPart Column objects do not have a "Name" property.  So I had to figure out a different way to find the column I needed.  I found there is a column called "Heading" that contains the parameter name so I was able to loop through all the columns and find the index number of the column I wanted.

This doesn't sound like a huge deal but what happens when there isn't a "Name" property is that you are unable to just use code like, Columns[ColumnName], to get the Column object.  You need to do like I did above to find the column which requires more code and depending on how many columns are in the table, it could affect processing time.

I have submitted this to the Inventor Ideastation, please vote up this idea so Autodesk can be made aware of this and fix it.

Idea on Inventor Ideastation