Hi
You can get an idea from this code
https://forums.autodesk.com/t5/net/spatial-query-in-autocad-2010/m-p/5304221/highlight/true#M42039
[CommandMethod("TEST")]
public void Test()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
PromptEntityOptions peo = new PromptEntityOptions("\nSelect a polyline: ");
peo.SetRejectMessage("Only a polyline !");
peo.AddAllowedClass(typeof(Polyline), true);
PromptEntityResult per = ed.GetEntity(peo);
if (per.Status != PromptStatus.OK)
return;
using (Transaction tr = db.TransactionManager.StartOpenCloseTransaction())
{
Polyline pline = (Polyline)tr.GetObject(per.ObjectId, OpenMode.ForRead);
if (!pline.Closed)
{
ed.WriteMessage("\nPolyline must be closed.");
return;
}
DBObjectCollection curves = new DBObjectCollection();
curves.Add(pline);
try
{
using (DBObjectCollection regions = Region.CreateFromCurves(curves))
using (Region region = (Region)regions[0])
{
PromptPointOptions ppo = new PromptPointOptions("\nPick a point <quit>: ");
ppo.AllowNone = true;
while (true)
{
PromptPointResult ppr = ed.GetPoint(ppo);
if (ppr.Status != PromptStatus.OK)
break;
Application.ShowAlertDialog(
GetPointContainment(region, ppr.Value).ToString());
}
}
}
catch (System.Exception exn)
{
ed.WriteMessage("\nError: " + exn.Message);
}
}
}
private PointContainment GetPointContainment(Region region, Point3d point)
{
PointContainment result = PointContainment.Outside;
using (Brep brep = new Brep(region))
{
if (brep != null)
{
using (BrepEntity ent = brep.GetPointContainment(point, out result))
{
if (ent is Autodesk.AutoCAD.BoundaryRepresentation.Face)
{
result = PointContainment.Inside;
}
}
}
}
return result;
}