Stepping Through the Features of a Model

A recent question came in about a way to make it easy to step through the features in the browser.  Of course you can do this manually by dragging the stop node feature-by-feature in the tree, but that quickly becomes tedious.  Here’s my answer to problem.  It’s a small VBA program that displays a form as shown below.

FeatureStep

Pressing the buttons let’s you move the stop node to the top, to the bottom, or advanced it one step at a time, either up or down the tree.  A utility like this can be useful when you’ve received a model from someone else and want to understand how it was built.

I think the trickiest part about using this program will be adding it to your VBA project.  Fortunately you only have to do that once.  Below is the step-by-step process to add it to your default VBA project and create a button in the ribbon to execute it.

  1. Download and unzip the code files.  You can unzip them anywhere on your computer.
  2. Run Inventor and open the VBA development environment, (Alt-F11).
  3. Right-click on the “ApplicationProject” node in the Project window and select “Import File…”, as shown below.

    FeatureStep VBA1

  4. Select the “FeatureStep.frm” file that you unpacked previously from the zip file.
    FeatureStep VBA3
  5. In the VBA project window, double-click on Module1, within the Modules folder.  This will open up the code window. 

    FeatureStep VBA4

  6. Copy and paste the code below into that window, as shown above.

    ‘ Macro to reposition stop node in browser.
    Public Sub FeatureStep()
        Dim featureStepForm As New frmFeatureStep
        If featureStepForm.Init Then
            featureStepForm.Show vbModeless
        End If
    End Sub  

  7. The following steps will create a button on the ribbon to run the macro.  Have a part open, making sure you’re in the modeling environment and a sketch is not active.  Right-click anywhere on the ribbon and select the “Custom User Commands…” command from the context menu, as shown below.

    FeatureStep VBA5

  8. In the Customize dialog, first choose “Macros” in the “Choose commands from” drop-down.  Next, select the “FeatureStep” macro from the list.  (If it’s not in the list, double-check that you followed the previous steps correctly.)  Finally, click the “>>” button to move that macro the to the right side of the dialog.

    FeatureStep VBA6

  9. Edit the settings on the button to display text.

    FeatureStep VBA7

    You should see the following in the ribbon.  If you want the command available on the Sheet Metal modeling ribbon, you’ll need to repeat steps 6 through 8 while a sheet metal document is open.
    FeatureStep VBA8


Comments

3 responses to “Stepping Through the Features of a Model”

  1. With Inventor Professional 2011 I get a run-time error 9; subscript out of range.
    Can you help me solve this?
    Thank you!

  2. (here I’m again)
    Thanks a lot! Thanks for the code and for the fast correction.
    It works great for me in a part file.
    It’s very usefull.
    Keep it up!

  3. Falgun Avatar
    Falgun

    It’s really handy, especially for other’s part to work on. Can it possible to create macro for assembly environment?
    Thanks

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading