// скрытие фона под выбранными пользователем вхождениями многострочных атрибутов во вставках блоков
[CommandMethod("attbackgrhide",CommandFlags.UsePickSet)]
public void HideAttributeBackground()
{
Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database;
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
PromptSelectionOptions prSelOpt = new PromptSelectionOptions();
prSelOpt.MessageForAdding = "\nВыберите объекты для скрытия фона: ";
PromptSelectionResult prSelRes = ed.GetSelection(prSelOpt);
if (prSelRes.Status == PromptStatus.OK)
{
using (Transaction trans = db.TransactionManager.StartTransaction())
{
foreach (SelectedObject selObj in prSelRes.Value)
{
DBObject obj = trans.GetObject(selObj.ObjectId, OpenMode.ForRead);
if (obj is BlockReference)
{
BlockReference br = (BlockReference)obj;
foreach (ObjectId attrRefObjId in br.AttributeCollection)
{
AttributeReference attrRef = (AttributeReference)trans.GetObject(attrRefObjId, OpenMode.ForRead);
if (attrRef.IsMTextAttribute)
{
attrRef.UpgradeOpen();
attrRef.MTextAttribute.BackgroundFill = true;
attrRef.MTextAttribute.BackgroundScaleFactor = 1.1;
attrRef.MTextAttribute.UseBackgroundColor = true;
}
}
}
if (obj is MText)
{
MText mtxt = (MText)obj;
mtxt.UpgradeOpen();
mtxt.BackgroundFill = true;
mtxt.BackgroundScaleFactor = 1.1;
mtxt.UseBackgroundColor = true;
}
}
trans.Commit();
}
}
}