tarikjabiri / js-dxf

JavaScript DXF writer
MIT License
179 stars 76 forks source link

Exported DXF can't be opened with revit #22

Closed jonathan-merlet-ocl closed 1 year ago

jonathan-merlet-ocl commented 4 years ago

Hello,

I'm using the lib to export a DXF. It opens fine in archicad and librecad, but not in Revit. If I save the DXF in Librecad, it will load fine in Revit. I tried saving the DXF in Librecad in R12 (oldest supported version by librecad) and R2007 (most recent) format, and see that both files differ quite a lot from the one produced by the lib (absence of header, but other sections as well). What is the DXF specification the lib is based on ? is there a document explaining the specification ? Maybe I could modify the lib so that the DXF would conform to the format that Revit expect.

ognjen-petrovic commented 4 years ago

Hi Jonathan,

I do not have access to Revit :( , it would be great if you can do that.

I used this documents: https://www.autodesk.com/techpubs/autocad/acadr14/dxf/header_section_al_u05_c.htm https://www.autodesk.com/techpubs/autocad/acad2000/dxf/header_section_group_codes_dxf_02.htm

jonathan-merlet-ocl commented 4 years ago

I finally had time to dig into this problem and now understand a bit of what is happening.

If what this post says about autocad also applies to revit : https://forums.autodesk.com/t5/autocad-forum/minimum-dxf-code-to-display-entities-with-true-color/m-p/8856675/highlight/true#M983376 Then without a version number, revit may assume the dxf file is following the R12 format. The specification you linked to is for R14/2000. According to this post : https://forums.autodesk.com/t5/autocad-forum/minimum-dxf-code-to-display-entities-with-true-color/m-p/8871972/highlight/true#M984356 Starting from the R13, a lot more information are needed in the files. I made a mistake when implementing true color in the lib because this feature shouldn't be available before version 2004. (maybe this should be reverted ?) I also had spaces in the name of my layers, which revit doesn't seem to like. This is strange, because if I save the file as a R12 dxf in librecad, it keeps the spaces but revit accepts the file, so it may be something else...

So revit seems to be way stricter in what it accepts compared to librecad. Sadly, I don't have the time to modify the lib so that it produces a strict R14 DXF (the spec you used). However, I found a nice page on the docs of the (python) ezdxf package which explains what a minimum dxf file should contain for R12 and R14 : https://ezdxf.readthedocs.io/en/master/dxfinternals/filestructure.html If anybody has more time than me...

ognjen-petrovic commented 4 years ago

Hi Jonathan,

Great thanks for your research and explanation. I will try to add that soon.

Ognjen

yowzadave commented 4 years ago

Are there any R13-R14-specific properties that this library is using? When I import a file generated by this library into AutoCAD, it notifies me: "Opening a Release 12 DXF file," and seems to display correctly. Perhaps the easiest approach would be to just explicitly define it as an R12 output in the header:

9
$ACADVER
1
AC1009
ognjen-petrovic commented 4 years ago

Hi,

As per Jonathan's post above, yes, there is at least true color feature that is not available in R12.

You could try set version and check if that helps. To set a version use header method:

let d = new Drawing();
d.header('ACADVER', [[1, 'AC1009']]);
kriffe commented 3 years ago

This should be resolved with a successful implementation of header in https://github.com/ognjen-petrovic/js-dxf/issues/33