Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not read saved files #156

Open
rocketsay opened this issue Feb 22, 2021 · 2 comments
Open

Not read saved files #156

rocketsay opened this issue Feb 22, 2021 · 2 comments

Comments

@rocketsay
Copy link

Please help.
Autocad throws an exception, when I'm try to load dxf file, after savind with dxf.Save.
Firstly, I've tried to change the block of dxfInsert by changing the property Name. After saving I converted the new file into .pdf and everything was good. But I couldn't open this new file again with DxfFile.Load. So, I tried only Load file and Save file without editing, And I found the same exception "System.InvalidOperationException: The sequence contains no elements"

dxfFile = DxfFile.Load(path);
dxfFile.Header.Version = DxfAcadVersion.R14;
dxfFile.Save("012.dxf");

dxf files is attached.
Debug.zip

@rocketsay
Copy link
Author

dxf.Header.SetDefaults();
dxf.ViewPorts.Clear();
dxf.Save("testp_1.dxf");

If I use just that, I can load file after saving, but it loses about 70% of data

@brettfo
Copy link
Member

brettfo commented Feb 24, 2021

AutoCAD is very particular about what it will accept in a DXF file, and it can be difficult to make it happy.

It sounds like the issue is some object names getting out of sync with each other in the file. Can you modify your original example by adding a call to the Normalize() function right before you save like this:

 dxfFile = DxfFile.Load(path);
 dxfFile.Header.Version = DxfAcadVersion.R14;
+dxfFile.Normalize(); // <-- add this line; it attempts to bring everything back in sync
 dxfFile.Save("012.dxf");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants