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

a problem when adding a real entity in block

Dec 16, 2014 at 7:20 AM
Edited Dec 16, 2014 at 7:22 AM
version is 0.9.1
like this :
//create a new dxf file and save it.
        DxfDocument dxf = new DxfDocument();
        Line line = new Line(new Vector2(0, 0), new Vector2(100, 100));
        dxf.AddEntity(line);
        dxf.Save(@"F:\temp.dxf");
//load the dxf file
        dxf = DxfDocument.Load(@"F:\temp.dxf");
//add the entity 'line' into a new block 'myblock'
        Line theline = dxf.Lines[0];
        Block bk = theline.Owner; 
        bk.Entities.Remove(theline);
        Block theblock = new Block("myblock");
        theblock.Entities.Add(theline);
but theline's owner is still '*Model_Space',how to set it's owner value?
thanks!
Dec 16, 2014 at 7:49 AM
Edited Dec 16, 2014 at 7:50 AM
I have no idear about that, but I think you can clone "theline" and remove it . and add the "cloneline" to "theblock".
Dec 16, 2014 at 8:32 AM
thanks,nalutao.
        netDxf.Entities.EntityObject clone = (netDxf.Entities.EntityObject)theline.Clone();
        dxf.RemoveEntity(theline);
        theblock.Entities.Add(clone);
it works fine