Add macro to User Commands panel on ribbon

Before you begin

Click Application Options File, and in Default VBA Project, note the name and location of the IVB file.

Default.ivb is an empty macro file (IVB) that is created the first time that you access the Visual Basic Editor. Any macro placed into this file loads on startup.

Create custom macro

  1. To begin, in Microsoft Windows Explorer, navigate to the location specified in the Application Options, File tab, default VBA project, and copy and extract Rotate.ivb.
    Note: If needed, create the folder as specified in the Application Options, File tab, for the default VBA project.
  2. In Autodesk Inventor, click Tools tab Options panel VBA Editor .
  3. In the Visual Basic Editor (VBE), select File Load Project, and browse to the previously mentioned location. Select Rotate.ivb, and click Open.

    Next, copy the Rotate.ivb code into the default.ivb.

  4. In the VBE, expand the plus sign (+) next to Rotate.
  5. Drag the icon next to Module1 (in the Rotate folder), and drop it on top of the default.ivb project.
    Note: You can also copy the Rotate code and paste it into the default.ivb window.

    The Rotate code copies into the default.ivb file.

  6. Remove the redundant code by selecting the Rotate.ivb that loaded in Step 3, and then click File Unload Project.
  7. Click Save to save the changes to default.ivb and close the VBE.

You can also create icons to run macros that exist in your default.ivb.

Run Macro command

  1. Open a part (.ipt) or an assembly (.iam) file containing graphical data.
  2. On the ribbon, click Tools tab Options panel Macros .
  3. In the Macros dialog box, click Rotate Camera, and click Run.

Create a macro command

  1. You can make icons for your macros to display on the User Defined panel on the ribbon. First, create a BMP image of the icon using a graphic program such as Microsoft Paint. Create small icons 16 high x 16 wide pixels and large icons (if applicable) 32 x 32 pixels.
  2. Save the icons to the same location as the ivb. file (as specified in Application Options).
  3. Name the icons using the following naming scheme: ModuleName.SubName.Size.bmp.

    ModuleName is the name of the module in the macro, SubName is the subroutine name, and size is either Small or Large. For example, the .bmp file that is used for the Rotate macro is: Module1.RotateCamera.Small.bmp.

    Next, assign the .bmp file to a user-defined panel in Autodesk Inventor.

  4. Right-click the ribbon, and choose Customize User Commands.
  5. In the Customize User Commands dialog box, click the drop-down arrow, and click Choose commands, Macro. The Macros that are in your default.ivbfile display in the left pane.
  6. Select the macro to add to the User Defined panel, and click Add.
  7. The macro displays in the User Defined panel on the ribbon.

    Note: If the macro displays as an infinity symbol, then the BMP is either in the wrong location, named incorrectly, or is not sized correctly.
  8. Click OK.
  9. To run the macro, in the graphics window, select an object, and click RotateCamera.