Hi.
A lot of credits to the guy that made this guide:
http://blog.ads-sol.com/2014/08/component-tags-in-inventor.html?m=1
I have a Mechanical Link set up for my assembly and I want to show the TAG's from AutoCAD Electrical schematics in the Inventor drawing.
So I have modified the code from the guide above to get the Electrical TAG's via the Mechanical Linked assembly.
SyntaxEditor Code Snippet
Sub Main() test(ThisApplication) End Sub Private Sub test(ByVal app As Inventor.Application) Dim oDrawDoc As DrawingDocument = app.ActiveDocument Dim oSheet As Sheet = oDrawDoc.ActiveSheet Dim oBalloon As Balloon For Each oSheets In oDrawDoc.Sheets For Each oBalloon In oSheet.Balloons Dim oLeader As Leader = oBalloon.Leader Dim oLeaderNode As LeaderNode = oLeader.AllNodes(2) Dim oGeometryIntent As GeometryIntent = oLeaderNode.AttachedEntity Dim oDrawingCurve As DrawingCurve = oGeometryIntent.Geometry Dim oModelGeom As Object = oDrawingCurve.ModelGeometry Dim oComponentOccurrence As ComponentOccurrence = oModelGeom.ContainingOccurrence Dim attrbSets = oComponentOccurrence.AttributeSets Dim attrbSet = attrbSets.Item("com.autodesk.mechatronics") Dim attrib = attrbSet.Item("ComponentTag") Dim oBalloonValueSet As BalloonValueSet If oBalloon.Style.Name = "Tags" Then For Each oBalloonValueSet In oBalloon.BalloonValueSets oBalloonValueSet.OverrideValue = attrib.Value Exit For Next End If Next Next End Sub
Colbjørn.
the guy who made the guide salutes you. What a nice job you've done..... keep up the good work.
I wish the AutoCAD P&ID could be linked.
:((
Updated code:
SyntaxEditor Code Snippet
Sub Main() UpdateBalloonTAG() End Sub Private Sub UpdateBalloonTAG() Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument Dim oLeader As Leader Dim oLeaderNode As LeaderNode Dim oGeometryIntent As GeometryIntent Dim oDrawingCurve As DrawingCurve Dim oModelGeom As Object Dim oComponentOccurrence As ComponentOccurrence Dim oParentDefinition As ComponentDefinition Dim oAttributeSets as AttributeSets Dim oAttributeSet As AttributeSet Dim oBalloonString As String Dim intStart As Integer Dim intStop As Integer Dim oBalloonValueSet As BalloonValueSet For Each oSheet In oDrawDoc.Sheets For Each oBalloon In oSheet.Balloons If Not oBalloon.Style.Name = "Balloon TAG" Then Continue For oLeader = oBalloon.Leader oLeaderNode = oLeader.AllNodes(oLeader.AllNodes.Count) oGeometryIntent = oLeaderNode.AttachedEntity oDrawingCurve = oGeometryIntent.Geometry oModelGeom = oDrawingCurve.ModelGeometry oComponentOccurrence = oModelGeom.ContainingOccurrence oAttributeSets = oComponentOccurrence.AttributeSets On Error Resume Next oAttributeSet = oAttributeSets.Item("com.autodesk.mechatronics") If Err.Number <> 0 Then Err.Clear If oComponentOccurrence.ParentOccurrence.Name = "" Then oBalloon.BalloonValueSets.Item(1).OverrideValue = "FAILED!" Continue For Else oParentDefinition = oComponentOccurrence.ParentOccurrence.Definition oAttributeSets = oParentDefinition.Occurrences.ItemByName(oComponentOccurrence.Name).AttributeSets On Error Resume Next oAttributeSet = oAttributeSets.Item("com.autodesk.mechatronics") If Err.Number <> 0 Then Err.Clear oBalloon.BalloonValueSets.Item(1).OverrideValue = "FAILED!" Continue For End If End If End If If oAttributeSet.Item("Category").Value = "TRMS" Then intStart = InStr(1, oAttributeSet.Item("TerminalBlock").Value, "TerminalBlockNumber", CompareMethod.Text) + 21 intStop = InStr(1, oAttributeSet.Item("TerminalBlock").Value, "TerminalBlockPinL", CompareMethod.Text) - 2 oBalloonString = oAttributeSet.Item("TerminalStripTag").Value & ":" & Mid(oAttributeSet.Item("TerminalBlock").Value, intStart ,intStop - intStart) Else oBalloonString = oAttributeSet.Item("ComponentTag").Value End If For Each oBalloonValueSet In oBalloon.BalloonValueSets oBalloonValueSet.OverrideValue = oBalloonString Exit For Next Next Next End Sub
Updated Code:
SyntaxEditor Code Snippet
Sub Main() UpdateBalloonTAG() End Sub Private Sub UpdateBalloonTAG() Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument Dim oLeader As Leader Dim oLeaderNode As LeaderNode Dim oGeometryIntent As GeometryIntent Dim oDrawingCurve As DrawingCurve Dim oModelGeom As Object Dim oComponentOccurrence As ComponentOccurrence Dim oParentDefinition As ComponentDefinition Dim oAttributeSets as AttributeSets Dim oAttributeSet As AttributeSet Dim oBalloonString As String Dim intStart As Integer Dim intStop As Integer Dim oBalloonValueSet As BalloonValueSet For Each oSheet In oDrawDoc.Sheets For Each oBalloon In oSheet.Balloons If Not oBalloon.Style.Name = "Balloon TAG" Then Continue For oLeader = oBalloon.Leader oLeaderNode = oLeader.AllNodes(oLeader.AllNodes.Count) oGeometryIntent = oLeaderNode.AttachedEntity oDrawingCurve = oGeometryIntent.Geometry oModelGeom = oDrawingCurve.ModelGeometry oComponentOccurrence = oModelGeom.ContainingOccurrence oAttributeSets = oComponentOccurrence.AttributeSets On Error Resume Next oAttributeSet = oAttributeSets.Item("com.autodesk.mechatronics") If Err.Number <> 0 Or Not oComponentOccurrence.ParentOccurrence.Name = "" Then Err.Clear If oComponentOccurrence.ParentOccurrence.Name = "" Then oBalloon.BalloonValueSets.Item(1).OverrideValue = "FAILED!" Continue For Else oParentDefinition = oComponentOccurrence.ParentOccurrence.Definition oAttributeSets = oParentDefinition.Occurrences.ItemByName(oComponentOccurrence.Name).AttributeSets On Error Resume Next oAttributeSet = oAttributeSets.Item("com.autodesk.mechatronics") If Err.Number <> 0 Then Err.Clear oBalloon.BalloonValueSets.Item(1).OverrideValue = "FAILED!" Continue For End If End If End If If oAttributeSet.Item("Category").Value = "TRMS" Then intStart = InStr(1, oAttributeSet.Item("TerminalBlock").Value, "TerminalBlockNumber", CompareMethod.Text) + 21 intStop = InStr(1, oAttributeSet.Item("TerminalBlock").Value, "TerminalBlockPinL", CompareMethod.Text) - 2 oBalloonString = oAttributeSet.Item("TerminalStripTag").Value & ":" & Mid(oAttributeSet.Item("TerminalBlock").Value, intStart ,intStop - intStart) Else oBalloonString = oAttributeSet.Item("ComponentTag").Value End If For Each oBalloonValueSet In oBalloon.BalloonValueSets oBalloonValueSet.OverrideValue = oBalloonString Exit For Next Next Next End Sub
Is there a way to do this, but not use balloon tags...? instead import the Tag Data into text that could be used to make an engraved label that would come into a bill of materials as a part?
The name of the component exists in ACADE and also exists in the link file... maybe make a balloon that looks like a phenolic label?
This seems such a simple question but I cant figure it out.
In AutoCAD Electrical I have Circuit Breaker 150 "CB-150" and I just want that text to show as a Nameplate / Tag in Inventor.
Hi @PaulMunford .
I have no idea about 2022 and Instance Properties.
As any major corporation in the world mine is couple versions back, still on AIP 2019 🙂