I'm using balloons to get information from parts, then writing that part info to a custom table. I need to keep track of which balloon corresponds to which table row.
Is there some object/property of Balloon where I can store a single number or string? I'm already using the value field, so that's unavailable to me.
Also, one balloon corresponds to one table entry. That means I cannot create a custom iProperty in the part the balloon is attached to since more than one balloon may reference the same part.
New approach to this. It appears Attributes may do what I want. However, Attributes only appear to be available for balloons, not Balloon AttributeSets.
My understanding is that if a balloon is attached to another balloon, that is considered one balloon with 2 attribute sets. Is it possible to assign an attribute to each AttributeSet in a balloon? Is there something else that might work better?
Reference to the DrawingBOMRow is accessible from the reference to the Balloon object. Inventor 2013 API Help contains the sample that shows how we find component referenced by balloon. Here it is:
Public Sub GetComponentReferencedByBalloon() ' Set a reference to the active drawing document Dim oDoc As DrawingDocument Set oDoc = ThisApplication.ActiveDocument ' Get the selected balloon Dim oBalloon As Balloon Set oBalloon = oDoc.SelectSet(1) Dim oBalloonValueSet As BalloonValueSet For Each oBalloonValueSet In oBalloon.BalloonValueSets Dim strDisplay As String strDisplay = "Balloon Item Number: " ' Add the balloon item number (the overridden value if there is one) If oBalloonValueSet.OverrideValue = "" Then strDisplay = strDisplay & oBalloonValueSet.Value Else strDisplay = strDisplay & oBalloonValueSet.OverrideValue End If Dim oDrawingBOMRow As DrawingBOMRow Set oDrawingBOMRow = oBalloonValueSet.ReferencedRow If oDrawingBOMRow.Custom Then ' The referenced item is a custom parts list row. strDisplay = strDisplay & vbNewLine & "Referenced Component(s):" strDisplay = strDisplay & vbNewLine & " Custom PartsList Row" Else Dim oBOMRow As BOMRow Set oBOMRow = oDrawingBOMRow.BOMRow ' Add the Item Number from the model BOM. strDisplay = strDisplay & vbNewLine & "BOM Item Number: " & oBOMRow.ItemNumber strDisplay = strDisplay & vbNewLine & "Referenced Component(s):" Dim oCompDefs As ComponentDefinitionsEnumerator Set oCompDefs = oBOMRow.ComponentDefinitions If oDrawingBOMRow.Virtual Then ' The referenced item is a virtual component. strDisplay = strDisplay & vbNewLine & " Virtual: " & oCompDefs.Item(1).DisplayName Else ' Add the document name of the referenced component. ' There could be multiple if the balloon references ' a merged BOM row in the model. Dim oCompDef As ComponentDefinition For Each oCompDef In oCompDefs strDisplay = strDisplay & vbNewLine & " " & oCompDef.Document.FullDocumentName Next End If End If MsgBox strDisplay Next End Sub
Right, and I'm using code from the sample. I have that part working.
I'm doing something different. Each Balloon can have multiple ValueSets, and each ValueSet corresponds to a part. I can't store the information in the part itself, because each part may have more than one balloon (multiple balloons would mean more than one table entry in my custom table). Therefore, I need a way to make the balloon Valueset correspond to a custom table row I'm creating.
I either need a way to uniquely identify balloon ValueSets(like a sketch's refKey), or I need a way to store a very small amount of data with a balloonValueSet.
You have classic many-to-many relationship between balloons
and parts represented by DrawingBomRow objects.
What information do you need to extract from DrawingBOM and
balloons in order to be saved in your custom table?
Can you please clarify desired workflow in more detail?
The user will balloon parts. I'll be creating a parts list that only includes the parts the user has ballooned. Each balloon placed will correspond to a single table entry, and each table entry will have a description. I need to keep this description linked to the proper balloon. Also, since parts may be used more than once, different instances of the part may have different descriptions.
One table row includes 5 columns: ID, Description, Manufacturer, Part Number, Internal Part Number
There's also the case where the user will attach a balloon(valueSet) from list because they may not be able to see the part they're selecting. This is why the info must be stored in the valueSet object within the balloon, not the balloon object itself.
Also, the balloons will have ID values. This ID value is also in the table. This allows the user to find the part info in the table, then use the ID number to identify which balloon has that info.
That's a very complete description of the whole workflow. I have most of that done, but maintaining a link between the tablerow entry and the balloonValueSet is tricky when I have nowhere to store a string of data in the valueSet.
We have no API to attach attributes to BalloonValueSet
BUT if “Each balloon placed will correspond to a single table entry” with unique description then you may use the following workaround.
AttributeManager.FindObjects method allows you to find references to appropriate balloon by ID and required description. This info allows locate associated BalloonValueSet if needed.
The reference to BalloonValueSet allows find ID and Description in balloon attributes. This data can be used to find table row associated with this BalloonValueSet.
Not very convenient but could work.
You seem to suggest that I store an attributeSet in a tableRow. From what I can tell, tableRow does not have an attributeSet. I believe the attributeSet is in the tableObject itself. I'd then have to create a new attribute in the table for every row.
You're right, it probably would work. However, I think it makes more sense for me to find a different approach. Thank you for the effort to assist me.
As a request to Autodesk,if you would consider adding some sort of storage for every programmatic entity created by Autodesk, visible to a programmer but invisible to the user, that would allow for far greater flexibility.
AttributeSets work great, but I believe only visible objects have them. Child items of visible objects need them as well for them to be useful.
Could you please add this request to Inventor API wish list here:
Thanks and best regards!