Code Red > .NET

Transient graphics not showing Text

(1/2) > >>

ROYNIJKAMP:
I am displaying a temporary line between 2 picked polylines.
The line is showing as expected execept for the Text object.
I have tried to add a Text to the Transient Graphics, but is it not showing.
Why is the Text not showing, is it not possible to show the text on the Fly?

Below the code i use.

--- Code - vb.net: ---Public Class clsMarkerLine    Private Shared plStart As Polyline    Private Shared plEind As Polyline     Private Shared m_markers As DBObjectCollection = New DBObjectCollection()    Private Shared collectints As IntegerCollection = New IntegerCollection()     Public Shared Sub StartMarker(ByVal polyStart As Polyline, ByVal polyEind As Polyline)        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor        AddHandler ed.PointMonitor, New PointMonitorEventHandler(AddressOf ed_PointMonitor)        plStart = polyStart        plEind = polyEind    End Sub     Public Shared Sub StopMarker()        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor        ed.TurnForcedPickOn()        RemoveHandler ed.PointMonitor, New PointMonitorEventHandler(AddressOf ed_PointMonitor)        ClearMarkers()    End Sub     Private Shared Sub ed_PointMonitor(ByVal sender As Object, ByVal e As PointMonitorEventArgs)        showLine(e.Context.RawPoint)    End Sub     Private Shared Sub showLine(ByVal pt As Point3d)        ClearMarkers()        'marker line        Dim myLine As Line = dynLine(pt)        m_markers.Add(myLine)        aGi.TransientManager.CurrentTransientManager.AddTransient(myLine, aGi.TransientDrawingMode.DirectShortTerm, 128, collectints)                'marker text        Dim myText As DBText = dynLineLengthText(pt, myLine)        m_markers.Add(myText)        aGi.TransientManager.CurrentTransientManager.AddTransient(myText, aGi.TransientDrawingMode.DirectShortTerm, 128, collectints)            End Sub     Public Shared Function dynLine(pt As Point3d, Optional sLayer As String = "0") As Line        Dim myLine As Line = New Line()        myLine.StartPoint = pt        myLine.EndPoint = plStart.GetClosestPointTo(pt, True)        Dim pts As New Point3dCollection()        myLine.IntersectWith(plEind, Intersect.ExtendThis, pts, New IntPtr(0), New IntPtr(0))        If pts.Count > 0 Then            myLine.StartPoint = pts(0)        End If        myLine.Layer = sLayer        myLine.ColorIndex = 10        dynLine = myLine    End Function         Public Shared Function dynLineLengthText(pt As Point3d, ln As Line, Optional sLayer As String = "0") As DBText        Dim acText As DBText = New DBText()        Dim dStart As Double = (ln.StartPoint.X + ln.EndPoint.X) / 2        Dim dEind As Double = (ln.StartPoint.Y + ln.EndPoint.Y) / 2        Dim ptCenter As Point3d = New Point3d(dStart, dEind, 0)        Dim CustomLineParmameters As CustomLineParam = getCustomLineParam(ln, ptCenter, True, False, 0.0, 0.5)        Dim newAngle As Double = CustomLineParmameters.Angle                acText.Rotation = newAngle * Math.PI / 180        acText.TextString = Math.Round(CustomLineParmameters.LineLength, 2).ToString & " m"        acText.Position = CustomLineParmameters.Point        acText.Layer = sLayer        acText.ColorIndex = 10        dynLineLengthText = acText    End FunctionEnd Class

n.yuan:

--- Quote from: ROYNIJKAMP on June 11, 2020, 07:25:19 AM ---
...


--- Code - vb.net: ---Public Class clsMarkerLine        ...    Private Shared collectints As IntegerCollection = New IntegerCollection()    ...     Private Shared Sub showLine(ByVal pt As Point3d)        ClearMarkers()        'marker line        Dim myLine As Line = dynLine(pt)        m_markers.Add(myLine)        aGi.TransientManager.CurrentTransientManager.AddTransient(myLine, aGi.TransientDrawingMode.DirectShortTerm, 128, collectints)                'marker text        Dim myText As DBText = dynLineLengthText(pt, myLine)        m_markers.Add(myText)        aGi.TransientManager.CurrentTransientManager.AddTransient(myText, aGi.TransientDrawingMode.DirectShortTerm, 128, collectints)            End Sub     ...  End Class
--- End quote ---

I think the issue lies in the argument of IntegerCollection passed into AddTransient() method: you need to pass a new/empty IntegerCollection, not one shared by multiple calls, like:

TransientManager.AddTransient(myLine, aGi.TransientDrawingMode.DirectShortTerm, 128, new IntegerCollection())
TransientManager.AddTransient(myText, aGi.TransientDrawingMode.DirectShortTerm, 128, new IntegerCollection())

huiz:
I am not sure if it is impossible but I had only success with shx fonts, not with ttf fonts.

Jeff_M:
I have always used the single IntergerCollection for any number of objects to be displayed, Norman.

If the text style used is a TrueType font, trying changing to one that uses an SHX font. I seem to recall having issues with TT fonts in TransientGraphics. huiz beat me to this.

n.yuan:

--- Quote from: Jeff_M on June 11, 2020, 01:29:04 PM ---I have always used the single IntergerCollection for any number of objects to be displayed, Norman.
...

--- End quote ---

Good to know, Jeff. Thanks.

Navigation

[0] Message Index

[#] Next page

Go to full version