Preview only show first 10 pages with watermark. For full document please download

Au09 Cp318-1 Inventor Api Intro Assemblies

Introduction to Autodesk® Inventor® API and Assemblies Wayne Brill – Autodesk CP318-1 This session will introduce you to the Inventor API with a particular emphasis on Assemblies. Topics covered will include how to control the placement of components in an assembly using a 3D matrix and how proxy objects are used to represent components in the assembly space. You will also see how Level of Detail is supported programmatically. VB.NET and VBA will be used to demonstrate the power of the API.

   EMBED


Share

Transcript

    Introduction to Autodesk® Inventor® API andAssemblies   Wayne Brill  – Autodesk CP318-1 This session will introduce you to the Inventor API with a particular emphasis on Assemblies.Topics covered will include how to control the placement of components in an assembly using a 3Dmatrix and how proxy objects are used to represent components in the assembly space. You will alsosee how Level of Detail is supported programmatically. VB.NET and VBA will be used to demonstratethe power of the API. About the Speaker: Wayne has been a member of Autodesk Developer Technical services supporting ADN (AutodeskDeveloper Network) for nine years. Currently, Wayne provides API support for AutoCAD, Autodesk Inventor®, AutoCAD® Mechanical, AutoCAD OEM, and RealDWG™.  [email protected]  Introduction to Autodesk® Inventor® API and Assemblies  2 Introduction Learning how to customize Inventor can be fun. A large Application Programming Interface(API) like this, with a lot of details to understand can also be challenging. I see this in my role asa support engineer for ADN (Autodesk Developer Network) where I often have the opportunityto help developers who are just starting with the Inventor API.In this session I will help you quickly get up to speed with Inventor customization by focusing onthe API objects for automating assemblies. I believe that if you are going to be automatingInventor you will probably want to know at least the basics of using the API for assemblies. Afteryou gain a basic understanding you can branch out and master other areas of the API as well.This document is intended to be a supplement to the power point slide and examples usedduring the session and will be a resource after the class. There are four main sections. The firsttwo are intended to be an introduction to the API. The last sections are detailed discussions onVectors, Matrices and the B-Rep API that you can use to gain a better understanding of thesemore complex objects.   Overview of the API and VBA    API for Assemblies.    Vectors, Matrices    B-Rep API  Note:   This is not a beginner’s class on programming. I do review simple concepts of using a COM API. However this class may get too complicated if you do not have some experience withCOM programming. Also the discussion will make a lot more sense if you already know thebasics of using Inventor to create assemblies. Overview of the Inventor API and VBA If you take a look at the Inventor API object model you will see that many of the objects in theInventor API are organized to follow the main document types in Inventor. (Parts, Assemblies,Drawings). Other sections in the API are used to create user interfaces and other objects thatare not related to a specific document type. You can download a PDF that contains a diagram ofthe Inventor API Object Model from this URL-  http://www.autodesk.com/developinventor  (You will find other resources available for the Inventor API as well)    Introduction to Autodesk® Inventor® API and Assemblies  3The Object Model PDF is also available from the Inventor SDK. (Software Development Kit) TheSDK will be in a directory similar to this:C:\Program Files\Autodesk\Inventor 2010\SDK\DeveloperTools\DocsThe SDK ships with Inventor however separate msi files need to be run to install it. These areDeveloperTools.msi and UserTools.msi. The location of the installer is different for Windows XPand Windows Vista or Windows 7.Windows XP: C:\Program Files\Autodesk\Inventor 2010\SDK\DeveloperTools.msiWindows Vista or 7: C:\Users\Public\Documents\Autodesk\Inventor2010\SDK\DeveloperTools.msiFor more information on the SDK see this file:C:\Program Files\Autodesk\Inventor 2010\SDK\SDK_Readme.htmYou can use any language that supports COM automation such as Visual Basic, VB.NET, C#and C++ to automate Inventor. You will probably find that the easiest way to get started with theInventor API is to use Visual Basic for Applications (VBA) which is included with Inventor (Theexamples in this handout are VBA examples). You can open the VBA editor from the Tools tabas seen in the following screenshot. (or Alt+F11)  Introduction to Autodesk® Inventor® API and Assemblies  4 VBA Example If you are new to COM programming you may not be aware that API objects are availablethrough a type library. In the VBA Editor you can see the referenced libraries by going toTools>References. The Autodesk Inventor Object Library (RxInventor.tlb) is automaticallyreferenced in the Inventor VBA editor so you can start using the API without adding otherreferences. Now let’s go ahead and add a procedure and do some simple things with the Inventor API.Copy and paste the code below to the VBA editor. When this VBA procedure is run a variablenamed invApp  is instantiated as an Object of the Inventor.Application  type. In VBA (and VB6)use the Dim  and Set  keywords to instantiate objects (In VB.NET you do not use the Set  statement). Once the object is instantiated you can use properties and methods of the object toaccess Inventor. Notice that ThisApplication  is used to return the Inventor Application.