Giter VIP home page Giter VIP logo

Comments (11)

qprotex avatar qprotex commented on August 27, 2024 2

Thanks. Any chance the Load method can throw System.NotSupportedException in future versions?

from netdxf.

haplokuon avatar haplokuon commented on August 27, 2024 1

There are two methods in the class DxfDocument exactly for this purpose, called:

public static DxfVersion CheckDxfFileVersion(Stream stream, out bool isBinary)

and

public static DxfVersion CheckDxfFileVersion(string file, out bool isBinary)

In your case it will return AutoCad14. netDxf is compatible with dxf versions AutoCad2000 and upwards, anything lower and it will not be able to read it. You can use the Debug build if you want the library to throw any exception that might occur during the reading process. The thing is that, if the file is one of the compatible dxf versions, and the Load method still returns null there is nothing you can do. It might be a bad formatted file or a bug, in that case I will need to take a look at it to find a fix.

Daniel

from netdxf.

LeaderXinjianSun avatar LeaderXinjianSun commented on August 27, 2024 1

You can copy all elements to to a compatible dxf file which you can load successfully, then save as it.The new file can be loaded successfully too.

from netdxf.

sorifiend avatar sorifiend commented on August 27, 2024

The "Load" method will return null if the file has not been able to load.

Please verify that the "BICYCLE.dxf" in in the correct place and that your code can see it by using something like this first: Console.WriteLine("File exists: " + File.Exists("BICYCLE.dxf")).

This is almost always a local issue involving an incorrect path. I suggest using an exact file path while testing your code so that you know 100% that it works first.

Note:
Loading dxf files prior to AutoCad 2000 is not supported.

from netdxf.

qprotex avatar qprotex commented on August 27, 2024

The file exists and I am able to use the library with many other DXF files but not with bycicle.dxf. Also, the Load method should throw a FileNotFoundException if the file does not exist but it is not the case. Had you the chance to test the file I attached?

from netdxf.

sorifiend avatar sorifiend commented on August 27, 2024

Ahh, I receive a System.NotSupportedException.

Your issue is that Loading dxf files prior to AutoCad 2000 is not supported.
I opened the file with CAD and resaved it as AutoCAD 2007 format, and the 'DxfDocument.Load()' worked perfectly.

Alternately you are using another unsupported format (Too new?, or from some odd program with bad heders?)

from netdxf.

sorifiend avatar sorifiend commented on August 27, 2024

That is a question best asked of the developer haplokuon, but I imagine that there are so many things that can cause the file not to load, and there is very little way to tell between something being unsupported verses something being corrupt etc.

You are welcome to investigate and submit a pull request to add the feature, but its easy enough to catch a generic exception or show a generic error to a user whenever the return is null, and just state that it is an unsupported file, and that they should manually resave the file in a newer format (AutoCAD 2007 in my case).

Source of the dxf loading (DxfDocument Read(Stream stream)) is here if you want to take a look: https://github.com/haplokuon/netDxf/blob/master/netDxf/IO/DxfReader.cs

from netdxf.

DmitryDronovDre avatar DmitryDronovDre commented on August 27, 2024

You can copy all elements to to a compatible dxf file which you can load successfully, then save as it.The new file can be loaded successfully too.

Thx, it work for me too. File that was saved from autocad was not opened. but show version DXF.
image
When i save els at new file - document start to reading.
Besides file after copy become from 30MB - 10MB
image

Thx.

from netdxf.

haplokuon avatar haplokuon commented on August 27, 2024

@DmitryDronovDre

I got your file " MKM_HdM_EP_100_GR_G00_x_x_01_Grundriss.dxf" and you need to update the library using the latest source code. It seems that the problem you have loading the file is related with a bug while reading the layer states, that has already been fixed.

Regarding the reduction in file size that may happen. Overtime the drawing can accumulate a lot of stuff that is not in use anymore like blocks, styles, layers,... If you use AutoCad that exactly the purpose of the "purge" command clean the drawing of unreferenced objects.

from netdxf.

yoonsungkim76 avatar yoonsungkim76 commented on August 27, 2024

Hi haplokuon.
Here is a sample dxf file(cad 2000) still have null issue. could you check this file?
test.zip

from netdxf.

haplokuon avatar haplokuon commented on August 27, 2024

@yoonsungkim76
If you have a new problem open a new Issue, do not hijack unrelated old posts.

First make sure you use the latest available source code. I found a small problem with your DXF, there are several 1071 codes out of place in the Layer data. If you use the Debug build an assertion (not an exception) will be raised showing that there is something abnormal with your file but will allow you to continue loading it. If you use the Release build the problematic lines will be skipped and the loading process will continue normally without returning null.

from netdxf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.