Here is Some code that i use in one of my plugins. In this example i just highlight the points you can change it to suite your needs:
public static void SelectPointsInCircle()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
try
{
// Prompt the user to select a circle
PromptEntityOptions peo = new PromptEntityOptions("\nSelect a circle: ");
peo.SetRejectMessage("\nThe selected object is not a circle.");
peo.AddAllowedClass(typeof(Circle), false);
PromptEntityResult per = ed.GetEntity(peo);
if (per.Status != PromptStatus.OK) return;
// Open the selected circle
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Circle circle = tr.GetObject(per.ObjectId, OpenMode.ForRead) as Circle;
if (circle == null) return;
Point3d center = circle.Center;
double radius = circle.Radius;
// Create a selection filter for Civil 3D points
TypedValue[] filterList = new TypedValue[]
{
new TypedValue((int)DxfCode.Start, "AECC_COGO_POINT")
};
SelectionFilter filter = new SelectionFilter(filterList);
// Select all points in the drawing
PromptSelectionResult psr = ed.SelectAll(filter);
if (psr.Status != PromptStatus.OK)
{
ed.WriteMessage("\nNo points found in the drawing.");
return;
}
SelectionSet selSet = psr.Value;
ObjectIdCollection selectedPoints = new ObjectIdCollection();
foreach (SelectedObject selObj in selSet)
{
if (selObj != null)
{
CogoPoint point = tr.GetObject(selObj.ObjectId, OpenMode.ForRead) as CogoPoint;
if (point != null)
{
// Check if the point is within the circle
if (center.DistanceTo(point.Location) <= radius)
{
selectedPoints.Add(point.ObjectId);
}
}
}
}
// Highlight the selected points
if (selectedPoints.Count > 0)
{
foreach (ObjectId id in selectedPoints)
{
Entity entity = tr.GetObject(id, OpenMode.ForWrite) as Entity;
if (entity != null)
{
entity.Highlight();
}
}
ed.WriteMessage($"\n{selectedPoints.Count} points were selected within the circle.");
}
else
{
ed.WriteMessage("\nNo points were found in the circle.");
}
tr.Commit();
}
}
catch (System.Exception ex)
{
ed.WriteMessage($"\nError: {ex.Message}");
}
}
Civil 3D Certified Professional