[CommandMethod("RemoveStrikethroughText")]
public void RemoveStrikethroughText()
{
using (Transaction trx = Doc.TransactionManager.StartTransaction())
{
PromptEntityOptions peo
= new PromptEntityOptions
("\nSelect Mtext or table"); peo.SetRejectMessage("\nNot Mtext or table");
peo
.AddAllowedClass(typeof(MText
),
true); peo.AllowObjectOnLockedLayer = true;
PromptEntityResult per = Ed.GetEntity(peo);
if (per.Status != PromptStatus.OK)
{
return;
}
List
<string> frags
= new List
<string>(); MTextFragmentCallback cb = (frag, obj) =>
{
if (frag.Strikethrough)
{
frags.Add(frag.Text);
Ed.WriteLine($"Removing: {frag.Text}");
}
return MTextFragmentCallbackStatus.Continue;
};
MText mt = per.ObjectId.GetDBObject<MText>(OpenMode.ForWrite);
mt.ExplodeFragments(cb);
foreach (var frag in frags)
{
mt.Contents = mt.Contents.Replace(frag, String.Empty);
}
trx.Commit();
}
}