Hi,
As @ActivistInvestor (is it you Tony?) said, you'll find some ways to evaluate if a point is inside a polyline from this thread.
Anyway, if the polyline does not have bulges (i.e., a polygon) you can also try a more trivial way using a polygonal selection.
[CommandMethod("TEST")]
public void Test()
{
var doc = Application.DocumentManager.MdiActiveDocument;
var db = doc.Database;
var ed = doc.Editor;
var options = new PromptEntityOptions("\nSelect a polyline: ");
options.SetRejectMessage("\nSelected object is not a polyline.");
options.AddAllowedClass(typeof(Polyline), true);
var result = ed.GetEntity(options);
if (result.Status != PromptStatus.OK)
return;
var polygon = new Point3dCollection();
var ucs = ed.CurrentUserCoordinateSystem;
Extents3d extents;
using (var tr = db.TransactionManager.StartOpenCloseTransaction())
{
var pline = (Polyline)tr.GetObject(result.ObjectId, OpenMode.ForRead);
extents = pline.GeometricExtents;
for (int i = 0; i < pline.NumberOfVertices; i++)
{
polygon.Add(pline.GetPoint3dAt(i).TransformBy(ucs));
}
tr.Commit();
}
var filter = new SelectionFilter(new[] { new TypedValue(0, "POINT") });
dynamic acadApp = Application.AcadApplication;
acadApp.ZoomWindow(extents.MinPoint.ToArray(), extents.MaxPoint.ToArray());
var selection = ed.SelectCrossingPolygon(polygon, filter);
acadApp.ZoomPrevious();
if (selection.Status == PromptStatus.OK)
ed.SetImpliedSelection(selection.Value);
}