Balloon Positioning In Drafting

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

I have been struggling a bit with placing balloons relative to other objects.

This post was helpful but I am still having trouble.

I need to create a balloon attached to another annotation, like a dimension.

But I want to precisely position it relative to the other annotation.
I noticed that I could move the balloon if I worked with an existing balloon but not one I just created in code.

It seems that a refresh is required to get it to work but that really slows down the process.

Here is my code from my test project.

        Dim pt As New cPoint()
        Dim balloon1 As SolidEdgeFrameworkSupport.Balloon = Nothing
        Dim X1, Y1, X2, Y2 As Double
        Dim selObj As Object

        GetEdge()

        Dim balloons As SolidEdgeFrameworkSupport.Balloons = mDftDoc.ActiveSheet.Balloons
        selObj = mDftDoc.SelectSet.Item(1)

        'Gets the location of the dimension text
        GetObjectTextZone(selObj, pt)

        balloon1 = balloons.Add(pt.X1, pt.Y1, 0)
        balloon1.Leader = False
        balloon1.BalloonSize = 1.5

        'How big is my balloon?
        balloon1.Range(X1, Y1, X2, Y2)
        balloon1.Leader = True

        balloon1.BalloonText = "12345"
        balloon1.BalloonType = SolidEdgeFrameworkSupport.DimBalloonTypeConstants.igDimBalloonOval

        'Connect balloon to dimension so it moves if you move the dimension.
        balloon1.SetTerminator(selObj, pt.X1, pt.Y1, 0, False)

        'Why do I need this????? Without it the SetKeyPoint below will not work
        mDftDoc.Windows.Item(1).Update

        'Shift the balloon locatin up by the height of the balloon
        balloon1.SetKeyPoint(1, pt.X1, pt.Y1 - (Y1 - Y2), 0.0)
        balloon1.Leader = False

Any idea's would be welcome.

Jason T.

 

 

LMGi
www.TLMGi.com
3 REPLIES

Re: Balloon Positioning In Drafting

Pioneer
Pioneer

Hi,

 

Can you try getting terminator object after setting. Just check if it doesn't returns object then wait until it returns the object.

 

I haven't tried in code but maybe this will help.

 

Regards,

Onkar

Re: Balloon Positioning In Drafting

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Jason,

I tried your code and the balloon seems to come out as desired, also attached to and moving with the dimension.

BalloonText.png

Here is my code and I did NOT need to call the window update under SE ST8 MP10.

    '----------------------------------------------------------------------
    ' Create a balloon on the active sheet attached to the selected dimension
    '----------------------------------------------------------------------
    Dim objDoc As SolidEdgeDraft.DraftDocument = objApp.ActiveDocument
    Dim objSheet As SolidEdgeDraft.Sheet = objDoc.ActiveSheet
    Dim objBalloons As SolidEdgeFrameworkSupport.Balloons = objSheet.Balloons
    Dim objBalloon1 As SolidEdgeFrameworkSupport.Balloon = Nothing
    ' Get the selected dimension
    Dim objDim As SolidEdgeFrameworkSupport.Dimension = objDoc.SelectSet.Item(1)
    ' Get the location of the dimension text
    Dim xp, yp, zp As Double
    Dim kpType As SolidEdgeFramework.KeyPointType
    Dim hndType As Integer
    For i As Integer = 0 To objDim.KeyPointCount - 1
      objDim.GetKeyPoint(i, xp, yp, zp, kpType, hndType)
    Next

    objBalloon1 = objBalloons.Add(xp, yp, 0)
    objBalloon1.Leader = False
    objBalloon1.BalloonSize = 1.5

    ' How big is my balloon?
    Dim x1, y1, x2, y2 As Double
    objBalloon1.Range(x1, y1, x2, y2)
    objBalloon1.Leader = True
    objBalloon1.BalloonText = "12345"
    objBalloon1.BalloonType = DimBalloonTypeConstants.igDimBalloonOval

    ' Connect balloon to dimension so it moves if you move the dimension
    objBalloon1.SetTerminator(objDim, xp, yp, 0, False)

    ' Why do I need this?? Without it the SetKeyPoint below will not work!
    'objDoc.Windows.Item(1).Update()

    ' Shift the balloon location up by the height of the balloon
    objBalloon1.SetKeyPoint(1, xp, yp - (y1 - y2), 0)
    objBalloon1.Leader = False

    Marshal.ReleaseComObject(objBalloon1) : objBalloon1 = Nothing
    Marshal.ReleaseComObject(objSheet) : objSheet = Nothing
    Marshal.ReleaseComObject(objDoc) : objDoc = Nothing

Re: Balloon Positioning In Drafting

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Thanks @MartinBernhard and @SEWarrior12, I will review my code compared to yours and try again when I get back to that project.

I now have MP1 for ST9 also.

Thanks for taking the time.

Jason T.

LMGi
www.TLMGi.com