Insert a newline character in MText

By Augusto Goncalves

For MText (.NET) or AcDbMText (ObjectARX C++) entities, the newline character is \P as opposed to the traditional ‘\n’ escape character, so setting the content use \\P C#/C++ (double backslash is interpreted as one) or \P for VB.NET.

(C#)

MText myText = // open me here

myText.Contents = "First line \\P Second line";

(VB.NET)

Dim myText As MText = ‘ open me here

myText.Contents = "First line \P Second line"

For a complete list of multi-line text formatting characters, visit Format Codes for Alternate Text Editor Reference.


Comments

One response to “Insert a newline character in MText”

  1. You can use the MText.LineBreak constant, but this property returns \p (lowercase) and the code needs to be in upper case…
    So :
    myText.Contents = “First line” + MText.LineBreak.ToUpper() + “Second line”;

Leave a Reply to MaxenceCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading