Hello Forum,
Can someone tell me why a just created BlockReference does not have GeometricExtents.
BlockReference dxfBlkRef = new BlockReference(Point3d.Origin, dxfBlkId); ms.UpgradeOpen(); ms.AppendEntity(dxfBlkRef); tr.AddNewlyCreatedDBObject(dxfBlkRef, true); try { //This failed because the BlockReference does not have Extents yet ZoomUtils.ZoomObjects(doc, new ObjectId[] { dxfBlkRef.ObjectId }); } catch { //Summing the Extents of the Nested objects solve this problem Extents3d blkRefExts = GetBlockRefExtentsByNestedEntities(dxfBlkRef); ZoomUtils.ZoomExtents(doc, blkRefExts); }
A solution is to explode the BlockReference but i like to avoid that.
Other solutions tried are:
- different versions of AutoCAD (2012+2014)
- dxfBlkRef.GeometryExtentsBestFit()
Attached is the code and a DXF sample
Thanks for any advise.
Solved! Go to Solution.
hello.
you have to validate the transaction .
After that you can have the geometry extend.
The block is inserted after the validate of the transaction.
You can start a new transaction and retrieve again the BlockReference using the original ObjectId. The ObjectId is guaranteed to remain constant inside an database Open-Close cycle.
usualy I do :
- open new transaction
- Insert Block
- retreave the Object Id (If i dont close the file)
- retreave the handle (If i close the file but i want to save the Id of the block)
- commit the transaction.
- regen
- open new transaction
- retrieve the block ref with ObecjtId or Handle.
- modify etc..
- commit the transaction.
The ObjectId is the same in the same file. but if you close, re open the file the objectId is not the same. For this use the Handle (a string)
Can't find what you're looking for? Ask the community or share your knowledge.