You can check bound property of block as well:
[CommandMethod("bsz")]
static public void BlockRecordSize()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = HostApplicationServices.WorkingDatabase;
PromptStringOptions pso = new PromptStringOptions("\nEnter block name:");
pso.AllowSpaces = true;
PromptResult res;
res = ed.GetString(pso);
if (res.Status != PromptStatus.OK) return;
string blockname = res.StringResult;
ed.WriteMessage("\nBock name entered\t{0}\n", blockname);
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTable bt= tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
if (!bt.Has(blockname))
{
ed.WriteMessage("\nBock \"{0}\" does not exists.\n", blockname);
return;
}
BlockTableRecord btrec = (BlockTableRecord)tr.GetObject(bt[blockname], OpenMode.ForRead,false);
Extents3d? bounds;
bounds = btrec.Bounds;
if (bounds.HasValue)
{
Extents3d ext = bounds.Value;
double width = ext.MaxPoint.X - ext.MinPoint.X;
double height = ext.MaxPoint.Y - ext.MinPoint.Y;
ed.WriteMessage("\nBock {0} hase width= {1:f3}; height = {2:f3}\n", blockname, width, height);
}
else
{
BlockReference bref = new BlockReference(Point3d.Origin, bt[blockname]);
bounds =bref.Bounds;
Extents3d ext = bounds.Value;
double width = ext.MaxPoint.X - ext.MinPoint.X;
double height = ext.MaxPoint.Y - ext.MinPoint.Y;
ed.WriteMessage("\nBock {0} hase width= {1:f3}; height = {2:f3}\n", blockname, width, height);
bref.Dispose();
}
tr.Commit();
}
}
_____________________________________
C6309D9E0751D165D0934D0621DFF27919