Hello,
I want to determine the size of a (non-dynamic non-annotative) block definition (BlockTableRecord). Does a block have a boundry or limits?
For example, if the block would contain a simple square, the size of the block would be equal to the size of the square.
Thank you.
Solved! Go to Solution.
Solved by Hallex. Go to Solution.
Hi,
do you look for that?
Public Overridable ReadOnly Property GeometricExtents As Autodesk.AutoCAD.DatabaseServices.Extents3d
Member von Autodesk.AutoCAD.DatabaseServices.Entity
[EDIT] sorry, I saw to late that you wrote "block-definition", not block-reference.
So you can either scan through the elements within the blockdefinition or you create one reference virtually and take that reference for .GeometricExtents. [/EDIT]
- alfred -
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(); } }
Can't find what you're looking for? Ask the community or share your knowledge.