Reply

Strange issue with Balloons and CalloutTextWidthMode

Hi there,

 

this should be quite simple, but it's driving me mad.

 

I'm adding some text boxes from the API as Callout Balloons. For some of them, I need to adjust the size so the text inside wraps into the surface. As far as I know, this should work:

 

Dim objBalloon As SolidEdgeFrameworkSupport.Balloon

objBalloon = balloons.Add(0.0, 0.0, 0.0)
objBalloon.Style.Name = strMyStyle  'My style!
objBalloon.TextScale = dMyScale 

'API Docs suggest that width should be defined prior to change widthmode
objBalloon.CalloutTextWidth = dWith
objBalloon.CalloutTextWidthMode = SolidEdgeFrameworkSupport.DimCalloutTextWidthModeConstants.igDimCalloutFixedWrapText

objBalloon.BalloonText = strMyText
objBalloon.Callout = 1
objBalloon.CalloutBorder = False

However, when the app finishes, the text is not wrapped. It retains default width mode (fit to content). The weird thing is that, if you double-click it to edit the properties and, without modifying anything, you close the window, the width mode gets updated with the wrapped value (unfortunately, width measure value is not updated).

 

It seems that the balloon needs some sort of "refresh" in order to get correctly updated, but I don't know how to force that refresh from the API.

 

The only workaround is creating an initial balloon correctly formatted and use Copy/Paste. This is far from elegant and slower, unfortunately.

 

Any clues? Much thanks

 

 

 

 

 

1 REPLY

Re: Strange issue with Balloons and CalloutTextWidthMode

I'm not sure that I fully understand the issue or am able to fully reproduce what you're describing but in my testing, this code got the text to wrap. I understand that my code goes against the API documentation but it's obvious that the order of API calls matters. This still may not be the "correct" approach but it does produce a different result.

 

From what I can gather, setting the BalloonText property a 2nd time before setting the CalloutTextWidth is the trick (hack).

 

Imports SolidEdgeCommunity.Extensions
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Runtime.InteropServices
Imports System.Text
Imports System.Threading.Tasks

Namespace FaceStyle
	Friend Class Program
		<STAThread> _
		Shared Sub Main(ByVal args() As String)
			Dim application = DirectCast(Marshal.GetActiveObject("SolidEdge.application"), SolidEdgeFramework.Application)
			Dim draftDocument = application.GetActiveDocument(Of SolidEdgeDraft.DraftDocument)()
			Dim sheet = draftDocument.ActiveSheet
			Dim balloons = TryCast(sheet.Balloons, SolidEdgeFrameworkSupport.Balloons)
			Dim balloon = balloons.Add(0.05, 0.05, 0)

			balloon.CalloutTextWidthMode = SolidEdgeFrameworkSupport.DimCalloutTextWidthModeConstants.igDimCalloutFixedWrapText
			balloon.BalloonText = "THIS IS A TEST"
			balloon.Callout = 1
			balloon.CalloutBorder = False
			balloon.BalloonText = balloon.BalloonText
			balloon.CalloutTextWidth = 0.015

			' Ghosting occurres (on my machine) so force a window update.
			Dim sheetWindow = CType(application.ActiveWindow, SolidEdgeDraft.SheetWindow)
			sheetWindow.Update()
		End Sub
	End Class
End Namespace

 

Jason Newell
Applications Architect
www.jasonnewell.net