Hello everyone,
does anyone know how to create a TextNode in CONNECT C # .NET?
many thanks and best regards,
The primary API for text in both C++ and .NET is the TextBlock. From DgnPlatformNET help: this is the master object that represents a piece of text as a whole, and is the primary high-level object used to deal with multi-line, formatted text (and is also generally recommended for any text, regardless of complexity). As described in the Text module documentation, TextBlock consists of a DOM (Document Object Model).
TextBlock
When you create an element from a TextBlock, the choice of a TextElement or a TextNodeElement is automatic. That is, TextHandlerBase::CreateElement creates a text node if there are multiple text parts in the TextBlock, or a text element if there is a single text part in the TextBlock.
TextElement
TextNodeElement
TextHandlerBase::CreateElement
Regards, Jon Summers LA Solutions
Francesc,
Here is some example C# code for creating text.
//you'll need to get the textstyle you want to use before creating your text block TextBlock labelBlock = new TextBlock(textStyle, Session.Instance.GetActiveDgnModel()); labelBlock.AppendText("Line One"); labelBlock.AppendLineBreak(); labelBlock.AppendText("Line Two"); labelBlock.SetUserOrigin(labelOrigin); labelBlock.SetOrientation(dMatrix3D); TextNodeElement textElement = (TextNodeElement)TextNodeElement.CreateElement(null, labelBlock); SetElementProperties(textElement, coreBoringSettings.textLevelName, SymbologyValue.ColorByLevel, 1, "ByLevel"); textElement.AddToModel();
Answer Verified By: Francesc Calaf
Thank you so much!