How to get Mtext contents without the formatting? (AutoCAD .net API)

Normally you’d go straight for the .Contents property…and I did just that but I also got some formatting marks. So how’d you get it without them?

Simple: just use the .Text property. Don’t bother with Regex and trying to parse the string. Ugh!

MText slabThicknessMtext = new MText();            
  slabThicknessMtext.Contents = panelMesh.SlabThickness; // this will produced text with the formatted codes (if any exist)
  slabThicknessMtext.Text = panelMesh.SlabThickness; // this will produced text with the UNformatted codes

Hope that helps!

Written on February 22, 2017