using System;
using System.IO;
using System.Resources;
using Exception = System.Exception;
#if AUTOCAD
using Application = Autodesk.AutoCAD.ApplicationServices.Core.Application;
using Ap = Autodesk.AutoCAD.ApplicationServices;
using Db = Autodesk.AutoCAD.DatabaseServices;
using Ed = Autodesk.AutoCAD.EditorInput;
using Gm = Autodesk.AutoCAD.Geometry;
using Rt = Autodesk.AutoCAD.Runtime;
#endif
namespace AGThsDrw
{
public sealed class AcLineDraw
{
[Rt.CommandMethod("AGDrawLine", "AGDrawLine", Rt.CommandFlags.Modal)]
public void DrLine()
{
var doc = Application.DocumentManager.MdiActiveDocument;
var db = doc.Database;
using (Db.Transaction tr = db.TransactionManager.StartTransaction())
{
var model = tr.GetObject(Db.SymbolUtilityServices.GetBlockModelSpaceId(db), Db.OpenMode.ForWrite) as
Db.BlockTableRecord;
Ed.PromptPointOptions pPtOpts = new Ed.PromptPointOptions("");
// Prompt for the start point
pPtOpts.Message = "\nEnter the start point of the line: ";
var pPtRes = doc.Editor.GetPoint(pPtOpts);
var ptStart = pPtRes.Value;
// Prompt for the end point
pPtOpts.Message = "\nEnter the end point of the line: ";
pPtRes = doc.Editor.GetPoint(pPtOpts);
var ptEnd = pPtRes.Value;
Db.Line line1 = new Db.Line(ptStart, ptEnd);
line1.SetDatabaseDefaults();
if (model != null) model.AppendEntity(line1);
tr.AddNewlyCreatedDBObject(line1, true);
tr.Commit();
}
}
}
}