Autodesk Inventor Customization
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Renumber Balloons for iLogic
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I want to add the Balloon Renumbering function to our templates using iLogic, but when I run it I get an error message saying: "The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))". I have narrowed it down and think it has to do with the following line: partInfo(i - 1).Number = drawBOMRow.Item(itemColumn).Value. When I remove that line I don't get an error message, but every balloon is set to item no 0. The function I want to achieve with the code is to renumber separate part files against the assembly BOM. Anyone have a suggestion on what the error might be? Thanks!
Public Structure udtPartInfo
Public udNumber As Integer
Public ReferencedFile As String
End Structure
Sub Main()
Dim drawDoc As DrawingDocument
drawDoc = ThisApplication.ActiveDocument
Dim baseSheet As Sheet
baseSheet = drawDoc.Sheets.Item(1)
Dim valSet As BalloonValueSet
valSet = baseSheet.Balloons.Item(1).BalloonValueSets.Item(1 )
Dim drawBOM As DrawingBOM
drawBOM = valSet.ReferencedRow.Parent
Dim partInfo() As udtPartInfo
ReDim partInfo(drawBOM.DrawingBOMRows.Count - 1)
Dim itemColumn As Integer
Dim i As Integer
For i = 1 To drawBOM.DrawingBOMColumns.Count
If drawBOM.DrawingBOMColumns.Item(i).PropertyType = kItemPartsListProperty Then
itemColumn = i
Exit For
End If
Next
For i = 1 To drawBOM.DrawingBOMRows.Count
Dim drawBOMRow As DrawingBOMRow
drawBOMRow = drawBOM.DrawingBOMRows.Item(i)
Dim partDef As PartComponentDefinition
partDef = drawBOMRow.BOMRow.ComponentDefinitions.Item(1)
partInfo(i - 1).ReferencedFile = partDef.Document.FullFileName
partInfo(i - 1).udNumber = drawBOMRow.Item(itemColumn).Value
Next
For i = 1 To drawDoc.Sheets.Count
Dim currentSheet As Sheet
currentSheet = drawDoc.Sheets.Item(i)
Dim checkBalloon As Balloon
For Each checkBalloon In currentSheet.Balloons
Dim matchFound As Boolean
matchFound = False
Dim valueSet As BalloonValueSet
valueSet = checkBalloon.BalloonValueSets.Item(1)
Dim checkFilename As String
checkFilename = valueSet.ReferencedFiles.Item(1).FullFileName
Dim j As Integer
For j = 0 To UBound(partInfo)
If checkFilename = partInfo(j).ReferencedFile Then
matchFound = True
If valueSet.ItemNumber <> partInfo(j).udNumber Then
valueSet.OverrideValue = partInfo(j).udNumber
End If
Exit For
End If
Next
Next
Next
End Sub
Solved! Go to Solution.
Re: Renumber Balloons for iLogic
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Here's a modified version of your rule in the attached file RenumberBalloons.txt. The main change required was to use PropertyTypeEnum.kItemPartsListProperty instead of just kItemPartsListProperty. When you convert a VBA macro to iLogic (or VB.NET), you have to specify the Enum type for any Inventor API Enum constants.
I also changed the type of udNumber to String instead of Integer. This may not be required for your drawings, but it would help the rule to work with dotted item numbers such as 2.1.

Mike Deck
Software Developer
DLS - Mechanical Design
Autodesk, Inc.
Re: Renumber Balloons for iLogic
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Works great, THANK YOU!
Re: Renumber Balloons for iLogic
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hello,
I tried it on Inventor 2012, I have this error :
Impossible d'effectuer un cast d'un objet COM de type 'System.__ComObject' en type d'interface 'Inventor.PartComponentDefinition'. Cette opération a échoué, car l'appel QueryInterface sur le composant COM pour l'interface avec l'IID '{DA33F1A3-7C3F-11D3-B794-0060B0F159EF}' a échoué en raison de l'erreur suivante : Cette interface n’est pas prise en charge (Exception de HRESULT : 0x80004002 (E_NOINTERFACE)).
The error seems to be from this line :
partDef = drawBOMRow.BOMRow.ComponentDefinitions.Item(1)Perhaps a difference between Inventor versions ?
Re: Renumber Balloons for iLogic
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Try replacing the line:
Dim partDef As PartComponentDefinition
with:
Dim partDef As ComponentDefinition
That should work. There doesn't seem to be a need to work with parts specifically at that point in the code.

Mike Deck
Software Developer
DLS - Mechanical Design
Autodesk, Inc.
Re: Renumber Balloons for iLogic
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Ok, there is is no error any more... but... what it is supposed to do ? I see nothing...
Re: Renumber Balloons for iLogic
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
The rule was converted from the VBA source in this Mod the Machine post:
http://modthemachine.typepad.com/my_weblog/2011/02
In subassembly views, the balloon numbers of components may be different than in the top-level assembly view. This program will renumber a balloon in other views if it finds the same component in the top-level view.

Mike Deck
Software Developer
DLS - Mechanical Design
Autodesk, Inc.

