- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @claudio.ibarra. Here is a basic example of what I mentioned above. This iLogic rule first makes sure I am working with a drawing, and if not exits the rule. Then it gets the 'active' sheet. Then it gets the first Balloon on the sheet. Then it gets the first value set of the Balloon (they can have multiple). Then it gets the item number from that. (You could also use its ReferencedRow to get DrawingBOMRow related date from it, if you were familiar with what columns (and specific column header text) of data were available in the PartsList.) Then it gets the balloon's parent drawing view. Then it inserts the item number into the view's name. Then it makes sure that the view's label is actually visible. Then it gets the view's label object. Then it edits the label's FormattedText to make sure it is showing the view's name on the first line, then the view's scale, followed by the sheet number on the second line, as you seem to have it in your screen captured image. The FormattedText part may not be necessary, if you have this formatting already set-up that way in your active default DrawingStandardStyle. If you do not want to put the item number into the view's regular name, then the other option is to put it into the FormattedText of the DrawingViewLabel object, which gets more complicated.
And yes, if there are multiple balloons on the same sheet that are attached to the same drawing view, that will definitely cause problems with an automation routine like this. I do not know how you normally name your drawing views, but as I pointed out above, you could possibly get more information from the parts list row that the balloon references to help with the first part of the drawing view's name too, but that would require being more familiar with your parts list, what columns are shown, and what the exact text of their column headers is, so we can navigate the cells of the parts list row to get the needed data. There will not be multiple parent drawing views for the same exact balloon object, but yes, it is definitely possible that you may have multiple views with a balloon attached to them with the same item number. Automation by code often requires some forethought and preparation with such situations in mind that might hinder the automation process.
Sub Main
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
Dim oDDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim oBalloon As Inventor.Balloon = oSheet.Balloons.Item(1)
Dim oValSet As BalloonValueSet = oBalloon.BalloonValueSets.Item(1)
Dim sItemNum As String = oValSet.ItemNumber
Dim oView As DrawingView = oBalloon.ParentView
'Option 1: you could add the Item # to the view's name
oView.Name = oView.Name & " ITEM " & sItemNum
If oView.ShowLabel = False Then oView.ShowLabel = True
Dim oLabel As DrawingViewLabel = oView.Label
'Option 2: you could try including the Item Number &/or Part Number / Description into this FormattedText somewhere, instead.
'Option 2 is a lot more complicated
oLabel.FormattedText = "<DrawingViewName/><Br/>SCALE: <DrawingViewScale/> SHT: <DerivedProperty DerivedID='29704'>Sheet Number</DerivedProperty>"
oSheet.Update
oDDoc.Update
End Sub
By the way, here is the link to the online help page for FormattedText, even though it may just confuse you more than help you.
Wesley Crihfield
(Not an Autodesk Employee)