Reply

Using objBalloons.AddByTerminator on a DrawingView

[ Edited ]

I can add a balloon to a line on the sheet easy enough:

objBalloon1 = objBalloons.AddByTerminator(objLine, 0.75, 0.015, 0, True)

 

But I can't add a balloon to a line in a drawing view:

objBalloon1 = objBalloons.AddByTerminator(objDVLine, 0.75, 0.015, 0, True)

 

It gives me the following error:

Exception from HRESULT: 0x80040223

 

ST2 VB2010

 

Thanks

 

Posted by: Terry Tyson
Post date: 9/26/2011 10:42:09 AM

5 REPLIES

RE: Using objBalloons.AddByTerminator on a DrawingView

[ Edited ]

 

Terry, 

 

try with

objBalloon1 = objBalloons.AddByTerminator(objDVLine.Reference, 0.75, 0.015, 0, True)

 

 

 

 

Posted by: Wolfgang Kunert
Post date: 9/26/2011 8:31:12 PM

RE: Using objBalloons.AddByTerminator on a DrawingView

[ Edited ]

Wolfgang,

 

Thanks for the reply. This has gotten me closer to where I need to be. I get a balloon but I don't seem to have much control over that balloon. Specifically, the .Leader and .BreakLine don't seem to work. Here is my code.

 

Imports System.Runtime.InteropServices

 

Module Module1

 

    Sub Main()

        Dim objApp As SolidEdgeFramework.Application = Marshal.GetActiveObject("SolidEdge.Application")

        Dim objDoc As SolidEdgeDraft.DraftDocument = objApp.ActiveDocument

        Dim objSheet As SolidEdgeDraft.Sheet = objDoc.ActiveSheet

        Dim objView As SolidEdgeDraft.DrawingView = objSheet.DrawingViews.Item(1)

        Dim objBalloons As SolidEdgeFrameworkSupport.Balloons = objSheet.Balloons

        Dim objDVBalloons As SolidEdgeFrameworkSupport.Balloons = objView.Sheet.Balloons

        Dim objBalloon1 As SolidEdgeFrameworkSupport.Balloon = Nothing

        Dim objLine As SolidEdgeFrameworkSupport.Line2d = Nothing

        Dim objDVLine As SolidEdgeDraft.DVLine2d = Nothing

 

        objLine = objSheet.Lines2d.Item(1)

        objDVLine = objView.DVLines2d.Item(10)

 

        'objBalloon1 = objBalloons.AddByTerminator(objLine, 0.75, 0.015, 0, True)

        objBalloon1 = objDVBalloons.AddByTerminator(objDVLine.Reference, 1, 1, 0, True)

        objBalloon1.TextScale = 1.5

        objBalloon1.BalloonText = "%{PART NUMBER|GP}"

        objBalloon1.Leader = True

        objBalloon1.BreakLine = True

 

 

        ReleaseObject(objDVLine)

        ReleaseObject(objLine)

        ReleaseObject(objBalloon1)

        ReleaseObject(objDVBalloons)

        ReleaseObject(objBalloons)

        ReleaseObject(objView)

        ReleaseObject(objSheet)

        ReleaseObject(objDoc)

        ReleaseObject(objApp)

 

    End Sub

 

    Private Sub ReleaseObject(ByRef objComObject As Object)

        If objComObject IsNot Nothing Then

            Marshal.ReleaseComObject(objComObject)

            objComObject = Nothing

        End If

    End Sub

 

End Module

 

Thanks for your help.

 

 

Posted by: Terry Tyson
Post date: 9/27/2011 5:09:47 AM

RE: Using objBalloons.AddByTerminator on a DrawingView

[ Edited ]

Wolfgang, thanks for the help.

 

Here is what's working. Now I just need to take it and run with it.

 

Imports System.Runtime.InteropServices

 

Module Module1

 

    Sub Main()

        Dim objApp As SolidEdgeFramework.Application = Marshal.GetActiveObject("SolidEdge.Application")

        Dim objDoc As SolidEdgeDraft.DraftDocument = objApp.ActiveDocument

        Dim objSheet As SolidEdgeDraft.Sheet = objDoc.ActiveSheet

        Dim objView As SolidEdgeDraft.DrawingView = objSheet.DrawingViews.Item(1)

        Dim objBalloons As SolidEdgeFrameworkSupport.Balloons = objSheet.Balloons

        Dim objDVBalloons As SolidEdgeFrameworkSupport.Balloons = objView.Sheet.Balloons

        Dim objBalloon1 As SolidEdgeFrameworkSupport.Balloon = Nothing

        Dim objDVLine As SolidEdgeDraft.DVLine2d = Nothing

 

        objDVLine = objView.DVLines2d.Item(10)

 

        'objBalloon1 = objBalloons.AddByTerminator(objLine, 0.75, 0.015, 0, True)

        objBalloon1 = objBalloons.AddByTerminator(objDVLine.Reference, 1, 1, 0, False)

        objBalloon1.TextScale = 1.5

        objBalloon1.BalloonText = "%{PART NUMBER|GP}"

        objBalloon1.Leader = True

        objBalloon1.BreakLine = True

        objBalloon1.AddVertex(0.1, 0.1, 0)

 

 

        ReleaseObject(objDVLine)

        ReleaseObject(objBalloon1)

        ReleaseObject(objDVBalloons)

        ReleaseObject(objBalloons)

        ReleaseObject(objView)

        ReleaseObject(objSheet)

        ReleaseObject(objDoc)

        ReleaseObject(objApp)

 

    End Sub

 

    Private Sub ReleaseObject(ByRef objComObject As Object)

        If objComObject IsNot Nothing Then

            Marshal.ReleaseComObject(objComObject)

            objComObject = Nothing

        End If

    End Sub

 

End Module

 

 

Posted by: Terry Tyson
Post date: 9/27/2011 5:56:40 AM

RE: Using objBalloons.AddByTerminator on a DrawingView

[ Edited ]

 

For a better relative placement of the balloon, use the following code:

 

Dim objTerminator As Object = Nothing

Dim x,y,z As Double

 

objBalloon1 = objBalloons.AddByTerminator(objDVLine.Reference, 0.75, 0.015, 0, True)

objBalloon1.GetTerminator(objTerminator, x, y, z, keyPoint)

objBalloon1.AddVertex(x + 0.01, y - 0.01, z)

 

 

 

Posted by: Martin Bernhard
Post date: 9/27/2011 6:13:43 AM

RE: Using objBalloons.AddByTerminator on a DrawingView

[ Edited ]

Awesome Martin, thanks again. This is just what I was looking for.

 

 

Posted by: Terry Tyson
Post date: 9/27/2011 6:49:20 AM