As you are aware if you have done
any routed systems there is no way of labeling same valve (or components for
that matter) with different names / tags / id_numbers and call it on the
drawing. You can create leader notes in the drawing but if they need changing
you need to manually do it and it’s time consuming if you have large assemblies
and multiple sheets and views. I have seen the same problem for people doing assemblies
of electric components.
A 2” ball valve can have
different identification tags in the P&ID but be a reused library component
in Inventor.
I've been searching for a
solution to this problem for the last 8 years or so and I couldn't find
anything on autodesk forums or other discussion groups.
I instinctively knew that we
would need to use the assembly browser name (occurrence name) but didn't see how
to get it to show up in the drawing.
I have got together bits of
iLogic codes from the internet that can get the assembly occurrence name and
link it to the override value of my custom style balloons.
For this I have created a new balloon
style called “Tags” and made it of type “Hexagon” with just the “Item” info in
it.
The code processes just balloons
of style “Tags” for we don’t want to change parts list balloons as well.
Because changing the occurrence
name in the assembly involves a lot of steps (find component in browser / edit
parent subassembly / change name of component / activate top level again) it is
better to do it from the drawing.
You need to use “balloon”
command, because “auto-balloon” cannot label same component on different views
more than once.
Place balloons as you would
normally do using “balloon” command and override the field with your text. You
only need to do it once per component then run the code
When running the code it will
prompt you if you want to set names from the balloons or from the browser.
Choose balloon to send the override value to the model browser (occurrence
name).
Continue placing balloons on all
views and then run the code again. Choose to set the value from the browser to
get the value on all new balloons.
This way I can balloon same component multiple times on same view if wanted.
As you can see the Occurrence name in browser and iproperties changed but the part number, stock number and other properties didn't changed.
Here's the code with explanatory comments:
' Set a reference to the drawing document.
Best of luck
ADS.
This way I can balloon same component multiple times on same view if wanted.
As you can see the Occurrence name in browser and iproperties changed but the part number, stock number and other properties didn't changed.
' Set a reference to the drawing document.
' This assumes a drawing document is
active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
' Set Reference to Active Sheet
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet
'get the name and path of the first
model in the drawing
oAsmName = ThisDrawing.ModelDocument.FullFileName
' Set Reference to the Assembly and Open
Silently
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.Documents.Open(oAsmName, False)
' Set a reference to the assembly
component definintion.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAsmDoc.ComponentDefinition
Dim oBalloon As Balloon
'Ask the user if he wants to set the
component name from browser
'or if he wants to set the browser name
from overwritten balloon value
booleanParam = InputRadioBox("Set name from?: ", "Browser", "Balloon", True, Title :="Read/Write")
'Start a counter for sheets to process
Dim SheetCount As Long
SheetCount = 1
Dim oSheets As Sheet
'step through each drawing sheet
For Each oSheets In oDrawDoc.Sheets
'
Iterate over each balloon on the sheet.
For Each oBalloon In oSheet.Balloons
Dim leader As Leader
Leader = oBalloon.Leader
'assuming
the leader is a single line segment
Dim leaderNode As LeaderNode = leader.AllNodes(2)
Dim intent As GeometryIntent
intent = leaderNode.AttachedEntity
Dim curve As DrawingCurve
curve = intent.Geometry
Dim edgePx As EdgeProxy
edgePx= curve.ModelGeometry
Dim occurrencedrg As ComponentOccurrence
occurrencedrg = edgePx.ContainingOccurrence
Dim oBalloonValueSet As BalloonValueSet
'
Iterate over each value set (attached balloons) in a balloon.
For Each oBalloonValueSet In oBalloon.BalloonValueSets
'only process if balloon of style of type "Tags"
If oBalloon.Style.Name = "Tags" Then
'if user wants to get name from browser
If booleanParam = True Then
' Set balloon value from browser.
oBalloonValueSet.OverrideValue = occurrencedrg.Name
'if user wants to set browser name from
balloon
ElseIf booleanParam = False Then
' Set browser name from balloon override
value.
occurrencedrg.Name = oBalloonValueSet.OverrideValue
End If
End If
Next
Next
'Increase sheet counter
SheetCount = SheetCount +1
Next
No comments:
Post a Comment