C# with Autocad

C# with Autocad

Anonymous
Not applicable
858 Views
1 Reply
Message 1 of 2

C# with Autocad

Anonymous
Not applicable

I have several points height and width, I want to join the points one by one. example. height: 0cm, 1.5cm, 2.5 cm. Language C#

 

Example in Image

 

WhatsApp Image 2018-08-15 at 20.33.05.jpegWhatsApp Image 2018-08-19 at 21.17.52.jpeg

0 Likes
859 Views
1 Reply
Reply (1)
Message 2 of 2

stefan.hofer
Advocate
Advocate

What do you mean with join points? Just draw polylines?

 

 

using acApp = Autodesk.AutoCAD.ApplicationServices.Application;
using Autodesk.AutoCAD.Geometry;
//......

private void MyPolyLine()
{
var doc = acApp.DocumentManager.MdiActiveDocument;
var db = doc.Database;
var ed = doc.Editor;
using (DocumentLock docloc = doc.LockDocument())
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Polyline path = DrawRect(width, height);
//BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord curSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
curSpace.AppendEntity(path);
tr.AddNewlyCreatedDBObject(path, true);
}
}
}
private Polyline DrawRect(double width, double height) { var pline = new Polyline(4); var pt = Point2d.Origin; pline.AddVertexAt(0, pt, 0.0, 0.0, 0.0); //Start pt += new Vector2d(0, height); pline.AddVertexAt(1, pt, 0.0, 0.0, 0.0); pt += new Vector2d(width, 0.0); pline.AddVertexAt(2, pt, 0.0, 0.0, 0.0); pt += new Vector2d(0.0, -height); pline.AddVertexAt(3, pt, 0.0, 0.0, 0.0); pline.Closed = true; return pline; }

 

0 Likes