//[CommandMethod("Drafting", "qAtt", 0)]
[CommandMethod("qAtt"]
public void QuickAttributeEditor()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
try
{
using (Transaction tr = doc.TransactionManager.StartTransaction())
{
doc.TransactionManager.EnableGraphicsFlush(true);
PromptNestedEntityOptions pneo
= new PromptNestedEntityOptions
("\nSelect attribute to edit"); AttributeReference ar = null;
while (true)
{
PromptNestedEntityResult pner = ed.GetNestedEntity(pneo);
if (pner.Status != PromptStatus.OK) return;
ar = pner.ObjectId.GetObject(OpenMode.ForRead) as AttributeReference;
if (ar != null) break;
ed.WriteMessage("\nNot an attribute reference!");
}
ar.UpgradeOpen();
if (ar.IsMTextAttribute)
{
try
{
MText tempText = ar.MTextAttribute;
ar.Visible = false;
doc.TransactionManager.QueueForGraphicsFlush();
doc.TransactionManager.FlushGraphics();
InplaceTextEditor
.Invoke(tempText,
new InplaceTextEditorSettings
()); ar.MTextAttribute = tempText;
ar.Visible = true;
}
catch (System.Exception e)
{
Application.ShowAlertDialog(String.Format("Error: {0}", e));
return;
}
}
else
{
ObjectId
[] ids
= new ObjectId
[1] { ar
.ObjectId }; InplaceTextEditor.Invoke(ar, ref ids);
}
tr.Commit();
ed.Regen();
}
}
catch
{ throw; }
}