Message 1 of 6
Multiple Background Mtext
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
I have an issue that I need help with. Here are the details:
I created a command to make the background of multiple MText objects. However, after running this command, all the text merges into a single line. I would like to keep the original positions of the text. How can I achieve that?
[CommandMethod("QM")]
public void ApplyBackgroundMaskToMTexts()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
PromptSelectionOptions pso = new PromptSelectionOptions();
pso.MessageForAdding = "Select MText:";
SelectionFilter filter = new SelectionFilter(new TypedValue[] { new TypedValue((int)DxfCode.Start, "MTEXT") });
PromptSelectionResult psr = ed.GetSelection(pso, filter);
if (psr.Status != PromptStatus.OK)
{
ed.WriteMessage("\nNone Object selected.");
return;
}
using (Transaction tr = db.TransactionManager.StartTransaction())
{
SelectionSet sset = psr.Value;
foreach (SelectedObject selObj in sset)
{
if (selObj != null)
{
MText mtext = tr.GetObject(selObj.ObjectId, OpenMode.ForWrite) as MText;
if (mtext != null)
{
mtext.BackgroundFill = true;
mtext.BackgroundScaleFactor = 1;
mtext.BackgroundFillColor = Color.FromColorIndex(ColorMethod.ByAci, 1);
mtext.ColumnType = ColumnType.NoColumns;
mtext.Width = 0;
mtext.Height = 0;
}
}
}
tr.Commit();
}
}
}