Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
using (Transaction trans=db.TransactionManager.StartTransaction())
{
BlockTable bt = trans.GetObject(db.BlockTableId,OpenMode.ForRead) as BlockTable ;
BlockTableRecord btr = trans.GetObject(bt[BlockTableRecord.ModelSpace],OpenMode.ForRead) as BlockTableRecord;
foreach (ObjectId id in btr)
{
if (trans.GetObject(id, OpenMode.ForRead) is Line)
{
var line = trans.GetObject(id, OpenMode.ForRead) as Line;
Extents3d geoExt = line.GeometricExtents;
MessageBox.Show(geoExt.MaxPoint.ToString());
}
else if (trans.GetObject(id, OpenMode.ForRead) is Autodesk.AutoCAD.DatabaseServices.Polyline)
{
var polyline = trans.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Polyline;
Extents3d geoExt = polyline.GeometricExtents;
MessageBox.Show(geoExt.MaxPoint.ToString());
}
}
trans.Commit();
}