Batch delete BOM balloons in Autodesk Inventor via iLogic

ChatGPT Image Jun 26, 2026, 12_54_25 PM.png

Introduction

 

Autodesk Inventor, like other 3D CAD software, allows for component numbering in assembly and layout drawings. These numbered references, which indicate the position of a given component in the parts list, are commonly referred to as BOM (Bill of Materials) balloons. In Inventor, BOM balloons can be added in two ways: manually and automatically.

The manual method involves selecting each component to create a reference and defining where that reference will appear. This workflow is suitable when you have few components or want precise control over their positioning.
The automatic method, on the other hand, involves selecting an area (view) and defining balloon positioning rules (vertical/horizontal/frame/along a line), which saves time and ensures that nothing visible in a given view is missed.

The difficulty begins when we want to label many components, but not all. Auto-numbering items is very helpful in this case, but manually finding and deleting unnecessary balloons is also time-consuming and labor-intensive. This can happen if:

🟢 You divide a long list of parts across multiple sheets,

🟢 You filter the parts list (e.g., only steel profiles or everything except standard parts),

🟢 You come across any other scenario that will force such a process in your work.

This is where iLogic comes in - an internal Inventor module that allows you to create conditional rules and scripts that automate workflows based on the API. With iLogic, you can create a rule that acts like a plug-in, creating a new tool according to a freely defined (programmed) process. This allows you to automatically filter and remove selected BOM balloons in seconds.

The video below shows an example of how an iLogic rule can accomplish such a task.

 

 

 

Removing BOM balloons

 

Value range

 

The basic way to create a batch delete in iLogic is to define a range of item number values. Using a rule, Inventor will automatically search for all balloons containing numbers within the specified range and delete them in one fell swoop.

Such a rule can be created using the following code:

' ===== SETTINGS =====
Dim minItem As Integer = 10
Dim maxItem As Integer = 20
' ====================

' Get active drawing document
Dim drawingDocument As DrawingDocument = ThisApplication.ActiveDocument

' Get active sheet
Dim activeSheet As Sheet = drawingDocument.ActiveSheet

' Loop through all balloons on active sheet
For Each balloon As Balloon In activeSheet.Balloons

    ' Skip balloons without values
    If balloon.BalloonValueSets.Count = 0 Then Continue For

    ' Get first balloon value set
    Dim balloonValueSet As BalloonValueSet = balloon.BalloonValueSets.Item(1)

    ' Get item value as text
    Dim itemValue As String = balloonValueSet.Value

    ' Variable for numeric item number
    Dim itemNumber As Integer

    ' Try converting value to integer
    If Integer.TryParse(itemValue, itemNumber) Then

        ' Check item range
        If itemNumber >= minItem And itemNumber <= maxItem Then

            ' Delete balloon
            balloon.Delete()

        End If
    End If

Next

 

Such a rule will remove all balloons numbered 10 to 20 in the active sheet, or any other range that is defined in it before it is run.

 

Multiple value ranges

 

Sometimes, the structure of a BOM doesn't quite match how we want to segment our parts list or label a sheet view with balloons. We may need to remove several different balloon value ranges to achieve the desired effect. In this case, we have two options:

  1. Perform operations on the same rule several times, each time changing the position number values ​​in the rule body.
  2. Modify the rule to allow for defining multiple ranges simultaneously.

In the case of the second scenario, you need to modify the SETTINGS fragment in the rule that is responsible for defining the range of balloons to be removed and replace it, for example (in this case for 3 intervals) with the following code:

' ===== SETTINGS =====
Dim minItem1 As Integer = 10
Dim maxItem1 As Integer = 20

Dim minItem2 As Integer = 30
Dim maxItem2 As Integer = 40

Dim minItem3 As Integer = 50
Dim maxItem3 As Integer = 60
' ====================

 

and replace the execution section with the following code:

' Try converting Item value to integer
If Integer.TryParse(itemValue, itemNumber) Then

    ' Check if item is within any of the 3 specified ranges
    If (itemNumber >= minItem1 And itemNumber <= maxItem1) _
    Or (itemNumber >= minItem2 And itemNumber <= maxItem2) _
    Or (itemNumber >= minItem3 And itemNumber <= maxItem3) Then

        ' Delete balloon
        oBalloon.Delete()

    End If

End If

 

Value ranges + single occurrences

 

It's also possible that our parts list will be so convoluted that we need to remove both ranges of values ​​and individual item numbers.

In such a scenario, we'll need to modify the input code area to:

' ===== SETTINGS =====
Dim minItem1 As Integer = 10
Dim maxItem1 As Integer = 20

Dim minItem2 As Integer = 30
Dim maxItem2 As Integer = 40

Dim minItem3 As Integer = 50
Dim maxItem3 As Integer = 60

Dim singleItems As Integer() = {5, 25, 45}
' ====================

 

and the fragment responsible for execution as follows:

' Try converting Item value to integer
If Integer.TryParse(itemValue, itemNumber) Then

    ' Delete flag
    Dim shouldDelete As Boolean = False

    ' Check ranges
    If (itemNumber >= minItem1 And itemNumber <= maxItem1) _
    Or (itemNumber >= minItem2 And itemNumber <= maxItem2) _
    Or (itemNumber >= minItem3 And itemNumber <= maxItem3) Then

        shouldDelete = True
    End If

    ' Check single items
    For Each singleItem As Integer In singleItems
        If itemNumber = singleItem Then
            shouldDelete = True
            Exit For
        End If
    Next

    ' Delete balloon if condition is met
    If shouldDelete Then
        balloon.Delete()
    End If

End If

 

 

Dialog box

 

All the above-mentioned forms of the rule have several disadvantages:

  • They limit the number of possible ranges to a list defined in the code.
  • They require modifying the code each time you want to change the range of item numbers to be deleted.

The solution to these issues is to rebuild the rule to include a pop-up dialog during its execution that allows you to define the ranges of balloons to be removed in a user-friendly interface.

 

In order not to waste space in the article and readers' time, I will present only one longer rule that allows you to specify multiple ranges and single values ​​in the dialog box at the same time:

' ==========================================
' Mini app - delete balloons by ranges/items
' Works only on active sheet
' ==========================================

' Get active drawing document
Dim drawingDocument As DrawingDocument = ThisApplication.ActiveDocument

' Get active sheet
Dim activeSheet As Sheet = drawingDocument.ActiveSheet

' Get user input
Dim inputText As String = InputBox( _
"Enter ranges and/or item numbers." & vbCrLf & _
"Example: 10-20, 24, 26, 30-34", _
"Delete Balloons")

' Stop if cancelled or empty
If String.IsNullOrWhiteSpace(inputText) Then Return

' Remove spaces
inputText = inputText.Replace(" ", "")

' Split input by commas
Dim inputElements() As String = inputText.Split(","c)

' Loop through all balloons
For Each balloon As Balloon In activeSheet.Balloons

    ' Skip balloons without values
    If balloon.BalloonValueSets.Count = 0 Then Continue For

    ' Get first balloon value set
    Dim balloonValueSet As BalloonValueSet = balloon.BalloonValueSets.Item(1)

    ' Get item value
    Dim itemValue As String = balloonValueSet.Value

    ' Variable for numeric item number
    Dim itemNumber As Integer

    ' Skip if conversion fails
    If Not Integer.TryParse(itemValue, itemNumber) Then Continue For

    ' Delete flag
    Dim shouldDelete As Boolean = False

    ' Check all input elements
    For Each inputElement As String In inputElements

        inputElement = inputElement.Trim()

        ' Check if element is range
        If inputElement.Contains("-") Then

            Dim rangeValues() As String = inputElement.Split("-"c)

            If rangeValues.Length = 2 Then

                Dim minValue As Integer
                Dim maxValue As Integer

                If Integer.TryParse(rangeValues(0), minValue) AndAlso _
                   Integer.TryParse(rangeValues(1), maxValue) Then

                    If itemNumber >= minValue AndAlso itemNumber <= maxValue Then
                        shouldDelete = True
                        Exit For
                    End If
                End If
            End If

        Else

            ' Check single value
            Dim singleValue As Integer

            If Integer.TryParse(inputElement, singleValue) Then
                If itemNumber = singleValue Then
                    shouldDelete = True
                    Exit For
                End If
            End If

        End If

    Next

    ' Delete balloon if condition is met
    If shouldDelete Then
        balloon.Delete()
    End If

Next

 

Running the above rule will open this dialog:

Zrzut ekranu 21-06-2026 15.18.56.png

 

 

Report

 

The BOM balloon deletion process also allows you to count all deleted instances and create a report based on that count. The report will appear in a separate dialog box after the operation is complete.

To get a process report, you need to add three lines of code.

 

The first line creates a counter (parameter) that will be used to count the number of removed balloons.

Dim removedCount As Integer = 0

This line should be placed just above the For Each balloon... code.

 

The second code snippet activates the process of counting the removed balloons.

removedCount += 1

and should be placed directly below the balloon deletion command Balloon.Delete().

 

The third line determines the format and content of the message box. It should be placed at the end of the rule and, for example, could be structured like this:

MessageBox.Show("Removed " & removedCount & " balloons.", "Report")

 

An example process report generated based on this code is presented in the graphic below:

BOM balloons report.png

 

 

Personalization

 

In the example code, I've presented the selected customization direction for the BOM batch balloon removal tool. It's worth noting that iLogic allows for a much broader scope of tool customization and process optimization. This command alone allows us to program:

  • Sheets range - the rule can handle the current sheet (current code), all sheets in the active document, or selected sheets (defined in the dialog box). The first mode is useful when splitting a long list of parts across multiple sheets. The second mode is useful when, for example, you want to remove all standard parts from lists on different sheets at once.
  • Supported expressions - from mathematical expressions of type >20 to automatic unification of the interpretation of commas and semicolons when entering individual position values.
  • Final report - can not only communicate the number of balloons removed, but also present them in an inventory or inform how many balloons were analyzed.
  • Cancellation report - it is possible to display a message box if the operation is canceled by the Cancel button or the Esc key.
  • Dialog box appearance - you can create a custom input area using Microsoft Form.
  • Preview - simulation of balloon removal before confirming the operation.
  • Set the rule to work for a specific view (not a sheet).
  • Much more...

 

 

Summary

 

Skillful use of iLogic can reduce the time spent on tedious tasks and allows the designer to focus on creative work by automating repetitive activities.

In this example, I showed how easy it is to save time by programming a script that searches, filters, and removes BOM balloons. The entire operation takes just seconds, regardless of the project's complexity. Furthermore, this command can be freely customized to suit your needs and preferences.

Good luck!

 

 

 

Find me on YouTube, LinkedIn or Instagram

1 Comment
iva.btblan
Advocate

Excellent!