balloon renumbering across sheets

balloon renumbering across sheets

cmines
Enthusiast Enthusiast
843 Views
3 Replies
Message 1 of 4

balloon renumbering across sheets

cmines
Enthusiast
Enthusiast

I am trying to modify the code Brian Ekins posted on Mod the Machine to renumber balloons across sheets. 

 

http://modthemachine.typepad.com/my_weblog/2011/02/index.html

 

It works great unless the item on the additional sheet is a sub-assembly.  I believe it is because PartDef is declared as a PartComponentDefinition and there is nothing in the code to handle an assembly. 

 

Dim partDef As PartComponentDefinition      

Set partDef = drawBOMRow.BOMRow.ComponentDefinitions.Item(1)      

partInfo(I - 1).ReferencedFile = partDef.Document.FullFileName

 

The Set partDef line was giving me a runtime error when it came to an assembly in the BOM until I added

"On Error Resume Next" at the start of the loop.

 

I tried changing the declaration to ComponentDefinition.  It compiled fine, but didn't do anything.  I think I'll have to add some duplicate code to handle an assembly in the BOM.  Is there a better way to do this?  Am I even on the right track?

 

Thanks for your help!

 

 

0 Likes
844 Views
3 Replies
Replies (3)
Message 2 of 4

rhasell
Advisor
Advisor

Hi

 

I can't help you directly, but I managed to scrounge an iLogic snippet which works realy well, You don't need multiple pages anymore, It also renumbers correctly after changing parts, which the macro did not do.

 

The reason for sending this, is that maybe you can see what was done differently?

Hope this helps.

 

I take no credit for the code, but I can't remember who wrote it.

 

Public Structure udtPartInfo
        Public udNumber As String
        Public ReferencedFile As String
    End Structure

    Sub Main()
        Dim drawDoc As DrawingDocument
        drawDoc = ThisApplication.ActiveDocument

        Dim baseSheet As Sheet
        baseSheet = drawDoc.Sheets.Item(1)

		If (baseSheet.Balloons.Count = 0) Then Return  ' There are no balloons on the drawing.
		
        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 = PropertyTypeEnum.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
				If (checkBalloon.BalloonValueSets.Count = 0) Then
				  Continue For
				End If
                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
					'	   Trace.WriteLine(" -- Overriding value: " &  valueSet.ItemNumber)
                           valueSet.OverrideValue = partInfo(j).udNumber
                        End If
                        Exit For
                    End If
                Next
            Next
        Next
    End Sub 

 

Reg
2026.1
0 Likes
Message 3 of 4

cmines
Enthusiast
Enthusiast

Reg,

Thanks for your response.  The code you posted seems to be Brian's code modified for iLogic.  The only difference I could find, other than a variable name (udNumber instead of Number) was it's declaration (String instead of Integer).  I changed my declaration to a string, and it ran, but I got the same results.    It worked great on parts, but didn't know what to do with a sub-assembly.  Did you try this on a sub-assembly as well as parts? 

Thanks for your help!

0 Likes
Message 4 of 4

rhasell
Advisor
Advisor

Hi

 

No sorry, I have not tried it on sub assemblies, I normally only use it when I have more than one assembly on one drawing sheet.

 

I create a dummy detailing assembly off sheet, this used to be on sheet1, which I don't have to do anymore.

 

I will test the sub assembly option today and let you know, I guess with a structured BOM.

 

Reg
2026.1
0 Likes