Message 1 of 8

Not applicable
09-01-2011
03:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.