I am drawing ordinate dimensions in blocks and then I am getting the geometric extents of these blocks, if the block contains the dimension, the extents are much larger than expected. What may be the cause?
See the attached drawing, the lines are connecting geometric extents MinPoint and MaxPoint. For the blocks that don't have dimension in them, the extents are correct.
Hi,
Sorry for the delay.
In your sample drawing, I could not find the block with the ordinate dimension in it.
Can you please share a sample drawing for me to reproduce the behavior.
I tried this with a simple block which included a ordinate dimension that I created, but the extents were right. I have attached the sample drawing that I used.
In general, the Geometric extents of a block reference may be larger than the actual extents as explained in the documentation. I have attached a sample code from a Devnote that explains a way to compute the right extents for a block reference.
Thanks for the reply,
the blocks are exploded after the calculation of extents. So I changed the code to retain the blocks and here is the drawing with blocks.
Hi,
I have attached a screenshot of the extent points that the following code snippet creates for the drawing. The extents seem right.
[CommandMethod("TTG")] public void TTG() { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; PromptEntityOptions peo = new PromptEntityOptions("\nSelect a block reference: "); peo.SetRejectMessage("\nMust be a block reference..."); peo.AddAllowedClass(typeof(BlockReference), true); PromptEntityResult per = ed.GetEntity(peo); if (per.Status != PromptStatus.OK) return; using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockReference bref = tr.GetObject(per.ObjectId, OpenMode.ForWrite) as BlockReference; BlockTableRecord btr = tr.GetObject(bref.BlockTableRecord, OpenMode.ForWrite) as BlockTableRecord; Extents3d exts = bref.GeometricExtents; BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord model = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; DBPoint minPt = new DBPoint(exts.MinPoint); minPt.ColorIndex = 2; model.AppendEntity(minPt); tr.AddNewlyCreatedDBObject(minPt, true); DBPoint maxPt = new DBPoint(exts.MaxPoint); maxPt.ColorIndex = 2; model.AppendEntity(maxPt); tr.AddNewlyCreatedDBObject(maxPt, true); tr.Commit(); } }
That's interresting, I will try to isolate the code I use for getting the extents and then post it tomorrow.