Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: phankinsTURWH

Hi @phankinsTURWH.  I'm glad my example code was able to help you.  After revisiting the post and seeing your final code, I decided to tweak it slightly for you, to make it a bit more efficient.  In this version, I got the specific BalloonStyle object before the loop, so it doesn't try to find/get it every time within the loop.  Also, since we had already created a variable to represent the drawing document, I eliminated that extra code.  Then I commented out the two messages, because you do not seem to really need them.  The main purpose of the code was just to change the Style of those specific Balloons which are attached to assemblies.  Now it should run much quicker, and without all the pop-up messages.

If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("A Drawing document must be active for this code to work. Exiting.", vbCritical, "")
	Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisDoc.Document
Dim oBStyles As BalloonStylesEnumerator = oDDoc.StylesManager.BalloonStyles
Dim oSUB_BalloonStyle As BalloonStyle = oBStyles.Item("SUB")
For Each oSheet As Sheet In oDDoc.Sheets
	For Each oBalloon As Balloon In oSheet.Balloons
		If oBalloon.Attached = False Then Continue For
		Dim oBVS As BalloonValueSet = oBalloon.BalloonValueSets.Item(1)
		Dim oDBOMRow As DrawingBOMRow = oBVS.ReferencedRow
		If oDBOMRow.Virtual Or oDBOMRow.Custom Then Continue For
		Dim oBOMRow As BOMRow = oDBOMRow.BOMRow
		Dim oCD = oBOMRow.ComponentDefinitions.Item(1)
		If TypeOf oCD Is PartComponentDefinition Then
'			MsgBox("Balloon #: " & oBVS.ItemNumber & ", on Sheet: " & oSheet.Name & _
'			vbCrLf & "is attach to a Part.",vbInformation,"Balloon Report")
		ElseIf TypeOf oCD Is AssemblyComponentDefinition Then
'			MsgBox("Balloon #: " & oBVS.ItemNumber & ", on Sheet: " & oSheet.Name & _
'			vbCrLf & "is attach to an Assembly.", vbInformation, "Balloon Report")
			oBalloon.Style = oSUB_BalloonStyle
		End If
	Next
Next

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)