Hi,
when creating a text element with CreateTextElement1() using a Template, then the color of the template isn't applied to the new text:
Sub TextTemplateTest() Dim oTextTemplate As TextElement Set oTextTemplate = CreateTextElement1(Nothing, "*", Point3dZero, Matrix3dIdentity) oTextTemplate.Color = 3 oTextTemplate.LineWeight = 3 Dim oText As TextElement Set oText = CreateTextElement1(oTextTemplate, "test", Point3dZero, Matrix3dIdentity) ' Check: LineWeight is ok, Color isn't! Debug.Print "oText.Color = " & CStr(oText.Color) & ", oText.LineWeight = " & CStr(oText.LineWeight) End Sub
The output is: oText.Color = 0, oText.LineWeight = 3.
Sould I mention that this used to work in V8i? Does anybody believe it's not a bug in Microstation?
Robert Schwenn said:Does anybody believe it's not a bug in Microstation?
As you probably know, the VBA classes are a wrapper around C++. The C++ text API was comprehensively revised for CONNECT. It's quite possible that something was forgotten when updating those wrappers...
Regards, Jon Summers LA Solutions
1. I only use temporary templates, so didn't test the other way.
2. The template's Color number doesn't matter - the created text always gets color = 0.
Robert Schwenn said:I only use temporary templates, so didn't test the other way.
I only use temporary templates, so didn't test the other way.
You posted a question. I suggested you try something, in an attempt to understand the domain of the problem. When you write "I didn't test the other way" then you ignored my suggestion.
There's little point in posting a question here if you then ignore our responses.
Not a text expert (or VBA), but I suspect that the way you are assigning a color to the dhdr isn't being carried over to the color members of TextParamWide/TextStringProperties.
Since your template is only being used for symbology, try using a Line element instead of a Text element for the template, for the C++ api anyway, this goes through a different code path.
If there is a method for setting the color instead of just assigning a value to the dhdr, that would probably work as well...
Thank You, Jon and Brien.Of course we can work around this bug. The simplest way is an additional code line after creating the new text:
oText.Color = oTextTemplate.Color
But it isn't the intended way. So I just wanted to document this issue for the community. And since a thread here has to be a "question" or "discussion" I choosed question, which was "Does anybody believe it's not a bug in Microstation?"
CheersRobert
It may not be a bug in Microstation. It could be a bug in your code.
MaryB
Power GeoPak 08.11.09.918Power InRoads 08.11.09.918OpenRoads Designer 2021 R2
Bentley has filed Defect # 1124402 ...
Aha...Thanks for the update!