31 lines
894 B
C#
31 lines
894 B
C#
using Autodesk.AutoCAD.DatabaseServices;
|
|
using Autodesk.AutoCAD.Geometry;
|
|
|
|
namespace CadParamPluging.Cad
|
|
{
|
|
public class CadDrawingService
|
|
{
|
|
private readonly CadContext _context;
|
|
|
|
public CadDrawingService(CadContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public ObjectId DrawLine(Point3d start, Point3d end)
|
|
{
|
|
var db = _context.Database;
|
|
var tr = _context.Transaction;
|
|
var blockTable = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
|
|
var blockTableRecord = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
|
|
|
|
using (var line = new Line(start, end))
|
|
{
|
|
var id = blockTableRecord.AppendEntity(line);
|
|
tr.AddNewlyCreatedDBObject(line, true);
|
|
return id;
|
|
}
|
|
}
|
|
}
|
|
}
|