Autodesk Inventor 2010 is a 3D solid-modeling software package with a lot to offer. In fact, with every release the developer adds a new host of tools and enhancements. An often-overlooked tool is the application-programming interface (API). It lets you write your own programs to interact with Inventor using your favorite flavor of Microsoft Visual Basic (VB) or Microsoft VB.NET. Inventor interacts with the Microsoft Component Object Model (COM), essentially the framework that lets all Microsoft-based products talk to each other and interact with other software.
To get started, use the Visual Basic for Applications (VBA) Editor in Inventor. Access the editor from the Tools tab on the Inventor ribbon panel.
The beauty of Inventor’s talking to VB-based programs is the wealth of free code available on the Web. For example, say you want your application to browse a network folder structure. Just type-in “browse network (VB, C#, or VB.net)” in an Internet search engine such as Google. It lists a number of free code options to place into your application.
In addition, Inventor comes with a rich set of code samples and tutorials. The examples are clearly written and show users how to interact with the Inventor dataset. Just copy-and-paste the code from the samples into your custom application. The samples provide many common routines.
For additional assistance, check out free online resources. One is an Autodesk blog by Brian Ekins at modthemachine.typepad.com. Ekins actually created Inventor’s API. He is also a speaker at Autodesk Univ. and his helpful class handouts are available at au.autodesk.com/?nd=class_listing.
Another good resource is the Autodesk Discussion Group at tiny.cc/VWFiW. It provides community assistance and code examples among peers. This is one of the most helpful and friendly engineering-software communities on the Web, with thousands of helpful code examples. The Inventor API team also monitors the community and provides assistance.
With this basic information in hand, what kinds of things can you do with the Autodesk Inventor API? A few examples follow.
One application I wrote provides A.T. Ferrell’s material standards for use in Inventor Sheet Metal. Our company has several hundred part numbers for raw sheet material. Before v 2009, sheet-metal styles were loaded into a template file. It was not practical to load all our materials in a single template file. As you can imagine, remembering or typing all of these variations was out of the question.
The recent application accesses our materials database and loads the needed material into Inventor to build a sheet-metal style on-the-fly. The application also provides the number of inches the plasma cutter must cut. The program creates a DXF file for the plasma-cutting software based on appropriate software standards. What previously took many steps is now accomplished in just a few clicks. This approach also ensures consistency among all our design engineers.
Another application I wrote called the Feature Rename tool is available at tinyurl.com/l3c2ps. The program runs inside Inventor and renames the tags in the browser panel as they are created or edited. The application renames feature tags based on the actual value of the features in a part file. A dialog interface lets users customize settings. Written for Inventor 2010, the application also works with v 2008 and v 2009. A help file comes with the download.
The Autodesk Inventor API provides nearly endless opportunities to interact with Inventor and create your own applications to accomplish your tasks. The hardest part is probably figuring out what you want to do first.
The software comes from Autodesk Inc., 111 McInnis Pkwy., San Rafael, CA 94903, (415) 507-5000, www.autodesk.com.
— Allen Gager
Allen Gager is a design engineer and CAD manager for A. T. Ferrell Co. Inc. in Bluffton, Ind. He has over 19-yr experience using and customizing Autodesk software in a production environment and has designed products in 3D since 1997. Allen is an Autodesk Inventor Certified Professional and the Manufacturing Solutions Div. Technical Editor for AU Tech Talk. Contact him at [email protected]