[CONNECT NET] Create TextNode

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).

    1. To acquire a TextBlock from an element, use the ITextQuery handler interface
    2. To modify the text of an element, use the ITextQuery and ITextEdit interfaces to get/set the text
    3. To create a free-standing text element from a TextBlock, use TextHandlerBase::CreateElement

    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.

     
    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