haplokuon / netDxf

.net dxf Reader-Writer
MIT License
986 stars 400 forks source link

Saving DxfDocument including given blocks causes error #327

Open seppelhuang opened 2 years ago

seppelhuang commented 2 years ago

soure files

1.dxf

1

2.dxf

2

See The following codes:

       DxfDocument dxf = new DxfDocument();
       Block block1 = Block.Load("E:\\1.dxf", "1");
        Vector2 center1 = new Vector2(0, 0);
        Insert insert1 = new Insert(block1, center1);

       Block block2 =Block.Load("E:\\2.dxf", "2");
        Vector2 center2 = new Vector2(0, 500);
        Insert insert2 = new Insert(block2, center2);

       dxf.Save("E:\\3.dxf");

Results: 3

related dxf files dxf.zip

haplokuon commented 2 years ago

Read this post, you have the same problem. Both files 1.dxf and 2.dxf have a block definition named "*U1" that comes from a dynamic block, when you try to merge them into the same document one overwrites the other. You need to rename them first, this library does not support dynamic blocks.

seppelhuang commented 2 years ago

How to rename the blocks using this library, Using Block.Name="xxx" throw exception " "Blocks for internal use cannot be renamed."

haplokuon commented 2 years ago

You need to use the latest source code, check the changelog.txt