- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This is a somewhat odd request, but I'll give it a try.
Do you need to use Balloons for this, or would another form of annotation like a LeaderNote (Leader Text) work?
Here is some (untested) code that may work for you using Balloons.
It it set up have you select an existing balloon, that is already attached to a component you want to call-out this way.
It then attempts to get the parent view. Get the assembly document within that view. User the balloons BalloonValueSet that contains a reference to which DrawingBOMRow it is associated with. Get the ComponentDefinition associated with that row. Get the BrowserNode for that component. Then search up through a couple of parent nodes, checking to see if they are a BrowserFolder, and if it finds one, it then tries to override the value of the balloon with the name of that folder.
Here's the (untested) code I've got so far. See if this will work for you.
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim oBalloon As Balloon = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingBalloonFilter,"Select a Balloon.")
Dim oView As DrawingView = oBalloon.ParentView
Dim oADoc As AssemblyDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oVBSet As BalloonValueSet
Dim oCD As ComponentDefinition
If oBalloon.Attached Then' or Try
oVBSet = oBalloon.BalloonValueSets.Item(1)
oCD = oVBSet.ReferencedRow.BOMRow.ComponentDefinitions.Item(1)
End If
'Get BrowserNode for this component, then use that to find what BrowserFolder it is within
Dim oPane As BrowserPane = oADoc.BrowserPanes.Item("PmDefault")
Dim oNode As BrowserNode = oPane.GetBrowserNodeFromObject(oCD)
Dim oBFolder As BrowserFolder
If oNode.Parent.Type = ObjectTypeEnum.kBrowserFolderObject Then
oBFolder = oNode.Parent
ElseIf oNode.Parent.Parent.Type = ObjectTypeEnum.kBrowserFolderObject Then
oBFolder = oNode.Parent.Parent
Else
MsgBox("Couln't find the Browser Folder for the Item this Balloon is attached to. Exiting.", vbOKOnly, " ")
Exit Sub
End If
oBalloon.BalloonValueSets.Item(1).OverrideValue = oBFolder.Name
oBalloon.BalloonValueSets.Item(1).Static = True
Wesley Crihfield
(Not an Autodesk Employee)