[CommandMethod("GetDimTextRotation")]
public void GetDimTextRotation()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
if (doc == null)
return;
Editor ed = doc.Editor;
Database db = doc.Database;
PromptEntityOptions prOpt =
new PromptEntityOptions("Укажите размер ");
prOpt.SetRejectMessage("Это не размер!");
prOpt.AddAllowedClass(typeof(Dimension), false);
PromptEntityResult rsEnt = ed.GetEntity(prOpt);
if (rsEnt.Status != PromptStatus.OK)
return;
using (Transaction tr = doc.TransactionManager.StartTransaction())
{
Dimension dim =
tr.GetObject(rsEnt.ObjectId, OpenMode.ForRead) as Dimension;
BlockTableRecord dimBlk =
tr.GetObject(dim.DimBlockId, OpenMode.ForRead) as BlockTableRecord;
if (dimBlk != null)
{
foreach (ObjectId id in dimBlk)
{
if (id.ObjectClass.IsDerivedFrom(RXClass.GetClass(typeof(MText))))
{
MText dimText = tr.GetObject(id, OpenMode.ForRead) as MText;
ed.WriteMessage("\nУгол поворота: {0} радиан ({1} градусов)",
dimText.Rotation, dimText.Rotation * 180 / System.Math.PI);
break;
}
}
}
tr.Commit();
}
}