Simple sample:
[code]
[CommandMethod("GetLineAngle")]
public void GetLineAngle()
{
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
Database db = HostApplicationServices.WorkingDatabase;
PromptEntityOptions prOpt = new PromptEntityOptions("\nSelect Line entity: ");
prOpt.SetRejectMessage("\nOnly Lines may be selected.");
prOpt.AddAllowedClass(typeof(Line),true);
PromptEntityResult rs = ed.GetEntity(prOpt);
if (rs.Status == PromptStatus.OK) {
using (Transaction trans = db.TransactionManager.StartTransaction()) {
Line line = trans.GetObject(rs.ObjectId, OpenMode.ForRead) as Line;
if (line != null) {
Vector3d v = line.EndPoint - line.StartPoint;
Plane plane = new Plane(new Point3d(0,0,0),new Vector3d(0,0,1));
double ang = v.AngleOnPlane(plane) / Math.PI * 180;
ed.WriteMessage("\nLine angle = {0}", ang);
}
}
}
}
[/code]