I wrote, the previous code to fast.... and forgot something - to check if we
select a text....:
[CommandMethod("DBTEXT")]
public void dbtext()
{
Document doc = acadApp.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
//PromptEntityOptions prOpt = new PromptEntityOptions("\nSelect
text: ");
//prOpt.SetRejectMessage("\nText object only!");
//prOpt.AddAllowedClass(typeof(DBText), true);
//PromptEntityResult rs = ed.GetEntity(prOpt);
PromptEntityResult res = ed.GetEntity("\nSelect text: ");
if (res.Status != PromptStatus.OK) return;
using (Transaction tr =
db.TransactionManager.StartTransaction())
{
DBText text = tr.GetObject(res.ObjectId, OpenMode.ForRead,
false) as DBText;
if (text != null)
{
ed.WriteMessage("\nAlignment is " +
text.HorizontalMode.ToString());
}
tr.Commit();
}
}