And yet again
the question of “how to indentify same parts with different labels-marks-balloons”
has passed my way. This time it’s a variation of the previous but the answer
stays the same and as far as Inventor is concerned, at the moment there is only
one solution.
 |
Are you looking for balloons? |
As most stuff on
this blog it’s not documented and only came to me after long years of testing the
software but I have been using it successfully ever since.
While you can
add notes, balloons or leader texts to your drawing, they will not
update and you need to manually adjust these every time. Don't get me wrong, the values will not update automatically with this method either but we will use ilogic code to force update them all..
The only way to
tag equipment is to use assembly browser name. That stays unique to each occurrence
(component) and while a valve can be used 100 times in the assembly and reside
in library (read only folder) you can change the browser name in the assembly and
give it an unique ID.
If you don’t
know what I am taking about or you need a refresh, start with this post where I
am explaining this concept and the setup of custom balloons in the drawing.
Then read the
update on tagging from the assembly, which might be faster/preferred by some
people.
Then there’s the
final code to use in the drawing which merges both codes and creates the
balloon on the drawing and renames the assembly browser node. If that component
(eg. Valve) has a tag already then it prompts the user to change the value.
I should mention
that it is possible to create a custom table to extract tagged equipment with
any iproperties you wish along (eg. PN, Description, Stock Number, etc.).
here's how to
create custom table:
and here's how
to edit a Parts List table:
Now that we’ve
cleared that out, how would I tag top level components like documenting nozzle
on a tank assembly?
While
I am used to label end components this time we need to label top level
subassemblies.
Start
by creating a custom balloon style, so that the code will only change those and
ignore any standard balloons like Item Number and Quantity.
Then
we have several options:
1.
Balloon the items (make sure
you select correct style).
a.
Use ilogic to update the value
of balloons you select on screen.
b.
Use ilogic change the values of
all balloons of that style current sheet / all sheets (complete drawing).
2.
Use ilogic to create balloons
on the fly, prompt the user for tag value, and override the value on the
assembly browser node and on the balloon.
For simiplicity I have created the second option where the balloons are created for you. Try this out and
let me know how that goes.
--------------------------------------------------------------------------------------------------
'this sets a tag to each selected component and creates
'a balloon for it, asks for update of existing balloons
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
' Set a reference to the active sheet.
Dim oActiveSheet As Sheet
oActiveSheet = oDrawDoc.ActiveSheet
Dim oStyles As DrawingStylesManager
oStyles = oDrawDoc.StylesManager
Dim oCurve As DrawingCurve
Dim oEdge As EdgeProxy
Dim occurrence As ComponentOccurrence
Dim oGeometryIntent As GeometryIntent
While True
Try
' Get a drawing curve segment selection from the user
Dim oCS As DrawingCurveSegment
oCS = ThisApplication.CommandManager.Pick( _
SelectionFilterEnum.kDrawingCurveSegmentFilter, "Pick a drawing curve segment")
If oCS Is Nothing Then
'MessageBox.Show ("Selection was cancelled","ilogic")
Beep
Exit While
End If
oCurve = oCS.Parent
oEdge = oCurve.ModelGeometry
occurrence = oEdge.ContainingOccurrence
While Not occurrence.ParentOccurrence Is Nothing
'MessageBox.Show("Parent Occ name: " & occurrence.ParentOccurrence.Name,"ilogic")
occurrence = occurrence.ParentOccurrence
'MessageBox.Show("cur Occ name: " & occurrence.Name,"ilogic")
End While 'end test for parent
'MessageBox.Show("Old Occ name: " & occurrence.Name,"ilogic")
Retry = True
'as long as retry is selected by user
While Retry
'get tag from user
oTagOcc = InputBox("Enter Tag No: ", "Tag Prompt", occurrence.Name)
Try
' try and set that value
occurrence.Name = oTagOcc
'if success exit the retrying loop
Exit While
'if tag allready exists
Catch
'prompt if user wants to try again
Retry = InputRadioBox("Allready used, try again", "Yes", "No", Retry, Title := "Retry")
End Try
End While
'if user canceled the retry skip the rest of the code and
'prompt to select parts again
If Retry = False Then
Continue While
End If
'Get the mid point of the selected curve
' assuming that the selection curve is linear
Dim oMidPoint As Point2d
oMidPoint = oCurve.MidPoint
' Set a reference to the TransientGeometry object.
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry
Dim oLeaderPoints As ObjectCollection
oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection
Try
' Create a couple of leader points.
Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X + 0.5, oMidPoint.Y + 1))
'Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X + 1, oMidPoint.Y + 0.5))
Catch
MessageBox.Show("Circular segment found," & _
vbLf & "Can't get sement center," & _
vbLf & "Manually move balloon please", _
"Position error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
' Add the GeometryIntent to the leader points collection.
' This is the geometry that the balloon will attach to.
oGeometryIntent = oActiveSheet.CreateGeometryIntent(oCurve)
Call oLeaderPoints.Add(oGeometryIntent)
Dim oBalloon As Balloon
Try
oBalloon = oDrawDoc.ActiveSheet.Balloons.Add(oLeaderPoints)
Catch
MessageBox.Show("Can'te activate BOM." & _
vbLf & "Temporary add a Parts List on the sheet" & _
vbLf & "You can remove it later", "ilogic")
End Try
'set the style of the balloon to "Tags"; if you don't have a style called tags
'you can remove this to keep it as default or use some of these settings:
'oBalloon.SetBalloonType (kHexagonBalloonType)
'---------
'other options here are kCircularWithOneEntryBalloonType,
'kCircularWithTwoEntriesBalloonType, kHexagonBalloonType,
'kLinearBalloonType, kNoneBalloonType And kSketchedSymbolBalloonType
'---------
oBalloon.Style = oStyles.BalloonStyles.item("Tags")
Dim oBalloonValueSet As BalloonValueSet
' Iterate over each value set (attached balloons) in a balloon.
For Each oBalloonValueSet In oBalloon.BalloonValueSets
' Set balloon value from browser.
oBalloonValueSet.OverrideValue = occurrence.Name
Next
Catch
'end try
End Try
End While
'----------Update existing balloons on all sheets
'Ask the user if he wants to update values of all balloons (if edited some)
booleanParam = InputRadioBox("Update existing balloons?: ", "Yes", "No", True, Title :="Update Existing?")
If booleanParam = False Then
Exit Sub
ElseIf booleanParam = True
'process all sheets
For Each oSheets In oDrawDoc.Sheets
' Iterate over each balloon on the sheet.
For Each oBalloon In oActiveSheet.Balloons
If oBalloon.Style.Name = "Tags" Then
Try
Dim leader As Leader
Leader = oBalloon.Leader
'assuming the leader is a single line segment
Dim leaderNode As LeaderNode
leaderNode = leader.AllNodes(2)
oGeometryIntent = leaderNode.AttachedEntity
curve = oGeometryIntent.Geometry
oEdge = curve.ModelGeometry
'occurrence = oEdge.ContainingOccurrence
While Not occurrence.ParentOccurrence Is Nothing
'MessageBox.Show("Parent Occ name: " & occurrence.ParentOccurrence.Name,"ilogic")
occurrence = occurrence.ParentOccurrence
'MessageBox.Show("cur Occ name: " & occurrence.Name,"ilogic")
End While 'end test for parent
' Iterate over each value set (attached balloons) in a balloon.
For Each oBalloonValueSet In oBalloon.BalloonValueSets
' Set balloon value from browser.
oBalloonValueSet.OverrideValue = occurrence.Name
Next 'go to next balloon
Catch'do nothing if error
End Try
End If 'end of search for Tags balloons
Next
Next
End If
'----------End Update existing balloons on all sheets
---------------------------------------------------------------------------------------------------
Later,
ADS.
photo credit:
Mass Ascension (license)