ACadSharp icon indicating copy to clipboard operation
ACadSharp copied to clipboard

DwgWriter write error

Open KiisMyGun opened this issue 1 year ago • 2 comments

Describe the bug

Error saving original file as new file:System.ArgumentOutOfRangeException:“Index was out of range. Must be non-negative and less than the size of the collection. Arg_ParamName_Name”

To Reproduce

test.zip After decompression, read this file and save it as a new file

var input = "D:\\Users\\26295\\Documents\\KLW单梯土建图1-销售技术部测试-KLW-1250-1-L1-4-15.dwg";
var output = "D:\\Users\\26295\\Documents\\test9.dwg";

CadDocument doc = DwgReader.Read(input);

//New document to transfer the entities
CadDocument transfer = new CadDocument();
doc.Header.Version = doc.Header.Version;

//Nove the entities to the created document
List<ACadSharp.Entities.Entity> entities = new List<ACadSharp.Entities.Entity>(doc.Entities);
foreach (var item in entities)
{
    ACadSharp.Entities.Entity e = doc.Entities.Remove(item);
    transfer.Entities.Add(e);
}

//Save the document
using (DwgWriter writer = new DwgWriter(output, transfer))
{
    writer.Write();
}

Expected behavior

Based on the original dwg file. I hope to generate 50 new files in bulk.

  • Modify several objects through multiple parameters, such as stretching/text modification, etc.
  • Then generate new files in bulk.
  • If this object is associated with other objects, if one is changed, other objects can also be updated together Screenshots image

Additional context

test.zip

KiisMyGun avatar May 14 '24 14:05 KiisMyGun

Hi @KiisMyGun,

The issue seems to be when the Hatch is been written, I'll open a branch to take care of this issue.

Thanks for reporting the bug.

DomCR avatar May 16 '24 10:05 DomCR

Hi @DomCR

Thanks for the quick reply.

KiisMyGun avatar May 20 '24 02:05 KiisMyGun