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

Adding entities to the layout paperspace

Apr 25, 2015 at 10:01 PM
What's the right way to add entities to the paperspace of a layout ?

I tried follow without success :
            var lay = new Layout("test1");
            dxf.Layouts.Add(lay);
            
            var blk = lay.AssociatedBlock;            
            blk.Entities.Add(new Line(new Vector3(0, 0, 0), new Vector3(100, 100, 100)));            
thanks
Coordinator
Apr 26, 2015 at 6:49 PM
Check the sample method "PaperSpace( )" in the "TestDxfDocument" project. Basically what you need to do is set the document ActiveLayout property, in your case:
dxf.ActiveLayout = lay.Name;
At the moment this is how it needs to be done, but I might revise it in the future. I would like to hear other people opinions on how to handle the way entities are added to a document, now that multiple paper spaces are possible. In the beginning I was only interested in the entities of the model space and to avoid breaking the existing code too much, that is how I ended doing it.

The way you were trying to do it could be a way on how to handle it. This is also related to your previous thread *Model_Space as block. Internally the dxf stores the entities of the ModelSpace and PaperSpace layouts in the ENTITIES section, while the entities of other layouts, PaperSpace0, PaperSpace1, ... are stored in the BLOCKS section as any other block.

So, if anyone else is reading this please comments are welcome.

Daniel