bpoly API

bpoly API

Anonymous
Not applicable
1,288 Views
2 Replies
Message 1 of 3

bpoly API

Anonymous
Not applicable

Hi there,

 

Is there an api wich works like the bpoly command in AutoCAD.

 

Click a point and the function gives met the points of the enclosed object.

 

I hope my question is clear if you got any questions pleaze ask.

 

Kind Regards,

 

Irvin

0 Likes
Accepted solutions (1)
1,289 Views
2 Replies
Replies (2)
Message 2 of 3

_gile
Consultant
Consultant
Accepted solution

Hi,

 

If you're targetting the 2011 SDK, look at the Editor.TraceBoundary() method.

 

Here's a quick and dirty

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Colors;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using AcAp = Autodesk.AutoCAD.ApplicationServices.Application;


namespace TraceBoundarySample
{
    public class TestCommand
    {

        [CommandMethod("Test")]
        public void Test()
        {
            Document doc = AcAp.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            PromptPointResult ppr = ed.GetPoint("\nSelect inner point: ");
            if (ppr.Status != PromptStatus.OK)
                return;
            DBObjectCollection objs = ed.TraceBoundary(ppr.Value, true);
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTableRecord btr =
                    (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                foreach (DBObject obj in objs)
                {
                    Entity ent = (Entity)obj;
                    btr.AppendEntity(ent);
                    tr.AddNewlyCreatedDBObject(ent, true);
                    ent.Color = Color.FromColorIndex(ColorMethod.ByAci, 1);
                }
                tr.Commit();
            }
        }
    }
}

 

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 3

Anonymous
Not applicable

Thanks verry much for your reply. Kind regards,

 

Irvin

0 Likes