Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Balloon Text Color

1 REPLY 1
Reply
Message 1 of 2
Anonymous
622 Views, 1 Reply

Balloon Text Color

I have iLogic code that cycles through all balloons on a drawing and finds any overridden values. What I need to do is change the balloon text color ONLY on the specific balloons that have been overridden. Any help?

1 REPLY 1
Message 2 of 2
philippe.leefsma
in reply to: Anonymous

Here is a sample extracted from the API Help files, it's VBA and it illustrates how to cycle all balloons and override their value:

 

Public Sub EditBalloons()
    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument
    
    'Set a reference to the active sheet.
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet
    
    Dim BalloonCount As Long
    BalloonCount = 1
    
    Dim oBalloon As Balloon
    
    ' Iterate over each balloon on the sheet.
    For Each oBalloon In oSheet.Balloons
    
        ' Change the balloon type
        oBalloon.SetBalloonType (kHexagonBalloonType)
        
        ' Change balloon placement direction so all the attached
        ' balloons are placed to the right of the previous ones.
        oBalloon.PlacementDirection = kBottomDirection
       
        Dim ValueSetCount As Long
        ValueSetCount = 1
    
        Dim oBalloonValueSet As BalloonValueSet
        
        ' Iterate over each value set (attached balloons) in a balloon.
        For Each oBalloonValueSet In oBalloon.BalloonValueSets
        
            ' Change the override value.
            oBalloonValueSet.OverrideValue = "Balloon" & BalloonCount & ": ValueSet" & ValueSetCount
            ValueSetCount = ValueSetCount + 1
        Next
        BalloonCount = BalloonCount + 1
    Next
End Sub

By checking the BalloonValueSet.Static property you can determine if the balloon has been overriden. But I suspect from your description that you already know that...

 

I don't think you can change the color of a balloon, but you can set the layer it belongs to and set the color of that layer. Here is an another example that illustrates how to move entities to a new layer:

 

Public Sub Layer()   
    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument
    
    'Set a reference to the drawing view.
    Dim oDraftView As DrawingView
    Set oDraftView = oDrawDoc.ActiveSheet.DrawingViews.AddDraftView(1#, "My Draft View")
    
    ' Set a reference to the sketch of the created draft view.
    Dim oSketch As DrawingSketch
    Set oSketch = oDraftView.Sketches.Item(1)
    
    ' Set a reference to the transient geometry object.
    Dim oTransGeom As TransientGeometry
    Set oTransGeom = ThisApplication.TransientGeometry

    ' Draw four sketch lines that form a rectangle
    Call oSketch.SketchLines.AddAsTwoPointRectangle(oTransGeom.CreatePoint2d(10, 10), _
                                                oTransGeom.CreatePoint2d(30, 30))

    ' Draw four sketch circles
    Dim oSketchCircles(1 To 4) As SketchCircle
    Set oSketchCircles(1) = oSketch.SketchCircles.AddByCenterRadius(oTransGeom.CreatePoint2d(12, 12), 1.5)
    Set oSketchCircles(2) = oSketch.SketchCircles.AddByCenterRadius(oTransGeom.CreatePoint2d(28, 12), 1.5)
    Set oSketchCircles(3) = oSketch.SketchCircles.AddByCenterRadius(oTransGeom.CreatePoint2d(12, 28), 1.5)
    Set oSketchCircles(4) = oSketch.SketchCircles.AddByCenterRadius(oTransGeom.CreatePoint2d(28, 28), 1.5)
    
    ' Create a new layer (as a copy of the 'Sketch Geometry' layer)
    ' to put the sketch circles in.
    Dim oNewLayer As Layer
    Set oNewLayer = oDrawDoc.StylesManager.Layers.Item("Sketch Geometry (ANSI)").Copy("Custom Sketch Circles")
    
    ' Set the LineType on the new layer to 'dashed'.
    oNewLayer.LineType = kDashedLineType
    
    'Put all the sketch circles on this layer
    oSketchCircles(1).Layer = oNewLayer
    oSketchCircles(2).Layer = oNewLayer
    oSketchCircles(3).Layer = oNewLayer
    oSketchCircles(4).Layer = oNewLayer
    
    ' Turn off the new layer
    oNewLayer.Visible = False
    
    ' Exit from editing the sketch.
    oSketch.ExitEdit
End Sub

Hope this helps,

Philippe.

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report