I tried a lot of way to do that,but still failed.
TextNode element has not got the width,height and font properties.
Who can help? Thanks.
spike: TextNodeElement has not got the width, height or font properties.
TextNodeElement has not got the width, height or font properties.
A TextNodeElement is not a TextElement. A TextNodeElement is a container of TextElements. TextElements have properties concerning appearance and contain the text that you see in graphics.
You need to enumerate the TextElements contained in the TextNodeElement, and set the symbology for each TextElement that you find. Lookup GetSubElements in VBA help.
Regards, Jon Summers LA Solutions
Hi,Jon.
Actually,I did what you said like followings,but it still didn't work.
------------------------------------------------------------
Sub main()
Dim txtNd As TextNodeElement Dim oTextEnum As ElementEnumerator Dim txt As TextElement Set txtNd = CreateTextNodeElement1(Nothing, Point3dFromXY(0, 0), Matrix3dIdentity) txtNd.AddTextLine ("aaa") txtNd.AddTextLine ("bbb") Set oTextEnum = txtNd.GetSubElements Do While oTextEnum.MoveNext Set txt = oTextEnum.Current txt.TextStyle.Color = 3 txt.TextStyle.Width = 10 txt.TextStyle.Height = 15 txt.TextStyle.Font = ActiveDesignFile.Fonts("Arial") Loop ActiveModelReference.AddElement txtNd End Sub ------------------------------------------------------------ Am I right?
txtNd is never redrawn.
AddElement should always be followed by a element.Redraw
spike: Am I right?
Am I right?
You are not... Unfortunately, you can't modify TextElements inside of TextNodeElement until it is added into model...
This is explanation from help about GetSubelements:
When a program uses the Current property of an ElementEnumerator that GetSubElements returned, it gets a copy of the element. Changes to this element do not affect the contents of the ElementEnumerator or the contents of the ComplexElement. If the program changes this copy and saves it to the DesigFile, the next time the program accesses the element from the DesignFile the ComplexElement will have the changed components.
Sub main() Dim txtNd As TextNodeElement Dim oTextEnum As ElementEnumerator Dim txt As TextElement Set txtNd = CreateTextNodeElement1(Nothing, Point3dFromXY(0, 0), Matrix3dIdentity) txtNd.AddTextLine ("aaa") txtNd.AddTextLine ("bbb") ActiveModelReference.AddElement txtNd Set oTextEnum = txtNd.GetSubElements Do While oTextEnum.MoveNext Set txt = oTextEnum.Current txt.TextStyle.Color = 3 txt.TextStyle.Width = 10 txt.TextStyle.Height = 15 txt.TextStyle.Font = ActiveDesignFile.Fonts("Arial") txt.Rewrite Loop End Sub
Unknown said:A TextNodeElement is not a TextElement. A TextNodeElement is a container of TextElements. TextElements have properties concerning appearance and contain the text that you see in graphics.
TextNodeElement also has formatting properties, even when there is no text in it.
Just add a new text node in the GUI, then look at its Element properties,When one adds some text to the textnode, these properties are inherited, but the text node still has a sepate formatting - one can inspect the file with OpenDGN to see that.
So the remaining question is how to reach these properties through the Microstation API.Or is it some deprecated feature of DGN V7 that is deliberately made inaccessible?
E.Jamster: TextNodeElement also has formatting properties, even when there is no text in it
True, but the TextElements contained by that TextNodeElement are free to have their individual formatting. The original question is how to modify the contained text elements, not how to apply a text style to a TextNodeElement.
E.Jamster: Is it some deprecated feature of DGN V7 that is deliberately made inaccessible?
If it were a deprecated feature of V7, you would not see it in the user interface.
E.Jamster: how to reach these properties through the Microstation API
MDL provides the required functions. They are not exposed by VBA.
Unknown said:MDL provides the required functions. They are not exposed by VBA.
I suspected so. Thank you for the confirmation.