This project has moved. For the latest updates, please go here.

Exploding a block

Jun 29, 2013 at 12:07 AM
Hi Daniel,
I want to write a function to explode all blocks of a document.
My problem is that I don't know what should I do to have access to the fields of each entities in the block.
For example, I would like to have the center point of the following circle in an block.
            DxfDocument dxf = new DxfDocument();
            Block myBlock = new Block("myBlock");
            myBlock.Entities.Add(new Circle(Vector3.Zero, 5));
            Insert myInsert = new Insert(myBlock, new Vector3(1, 1, 0));
and if I write it like this:
            Block blk = dxf.Blocks[2];
            EntityObject Ent = blk.Entities[0];
I wont be able to have access to the center point.
How should I write the code?

Also Thank you for your awesome library :)
Jun 30, 2013 at 10:29 AM
You need to cast the return object to its actual type, in this case is a Circle; EntityObject is the base class from which all entities derive. You can find in the web detailed information about casting, it is a common operation in object oriented programming.
Circle ent = (Circle)blk.Entities[0];