private BlockReference FindBlockAtPoint(Database db,Transaction tr, Point3d point)
{
BlockTableRecord modelSpace = tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForRead) as BlockTableRecord;
double tolerance = 0.01;
foreach (ObjectId id in modelSpace)
{
if (id.ObjectClass.IsDerivedFrom(RXObject.GetClass(typeof(BlockReference))))
{
BlockReference blockRef = tr.GetObject(id, OpenMode.ForRead) as BlockReference;
if (blockRef != null)
{
Extents3d extents = blockRef.GeometricExtents;
if (point.X >= extents.MinPoint.X - tolerance && point.X <= extents.MaxPoint.X + tolerance &&
point.Y >= extents.MinPoint.Y - tolerance && point.Y <= extents.MaxPoint.Y + tolerance)
{
return blockRef;
}
}
}
}
}