What’s up with DWG adoption in free software?


Having been asked recently about reasons for lack of DWG support in free software, we started digging and very nearly fell into a pitch black abyss.

As pretty much every engineer knows, DWG is the native file format of various applications by Autodesk since 1982. Over decades it has become a kind of de-facto standard in some industries that heavily rely on CAD software.

Blueprint view in FreeCAD

While file formats such as STEP (ISO 10303) exist, DWG is still part of far too many production workflows. Within those workflows if you can’t read and save DWG, you can’t get the job done. That effectively prevents free CAD applications from being much used to accomplish real life tasks.

The overall situation with DWG is far from being healthy. Until fairly recently proprietary software vendors that make use of the file format had been arguing over DWG trademark infringements, and these days they are basically in two camps.

The Autodesk camp doesn’t make any public documentation on DWG. The Open Design Alliance camp has a publicly available spec. None of them makes free software compatible SDK, and that seriously complicates work of some free software developers.

Rise and shine of DraftSight, a 2D drafting application from Dassault Systems, changed the situation for the better last year due to its support for DWG and lack of a price tag. Even so, we are talking about proprietary software that’s controlled by a single vendor.

In 2008, Free Software Foundation acknowledged the issue and gave it a high priority. Later, in 2009, several Brazilian developers started a new project called LibreDWG that derived its initial code base from libdwg, a formerly abandoned attempt to fix the lack of a free library for handling DWG files.

The project had a rapid start, but came to a halt in early 2011 with just a single free software project (GRASS) adopting it and lack of support for newer file format versions. As we started figuring out why it happened, several reasons presented themselves, two of them being really outstanding.

Incomplete DWG spec by ODA. The document used to be badly incomplete, with whole sections of essential information missing, and the PDF file was even corrupted at times.

GPLv3 license. It doesn’t work for end-user software, because they tend to use 3rd party components under different licenses that impose restrictions. FSF who are sole copyright holders of LibreDWG objected to relicensing. With regards to FreeCAD project and Yorik van Havre, its contributor, Richard Stallman stated:

You should not change the license of your library. Rather, it is best to make it clear to him what the conditions are.

To make sure that we have a complete and up to date understanding of the situation, we approached both LibreDWG developers, developers of end-user software and Free Software Foundation.

What LibreDWG team says

We contacted Felipe Sanches and Rodrigo Rodrigues da Silva, developers of LibreDWG, to tell us about the status of the project and explain the state of affairs with DWG support in free software.

Back in 2009 the lawsuit of Autodesk against ODA over DWG trademark was still in progress. Even though the situation looked somewhat scary, you started the project anyway. Why?

Felipe: The purpose of GNU LibreDWG is to enable people to read files in the DWG format without being forced to install proprietary software. We do not like the DWG format, so we do not want to encourage its usage by simply adding DWG support to any application.

Our intention is to have DWG support only on the applications that really need it. That seems to be the case for most free software CAD tools in order to compete with the proprietary CAD tools (such as AutoCAD).

How far have you progressed with it? What parts of the file formats have been reverse-engineered and what’s missing?

We have implemented most of what is described in the “OpenDWG” spec provided by the Open Design Alliance. There’s been some new versions of the spec released, but until recently the PDF files were mostly corrupted, with lots of information missing.

Complex 3D objects in DWG are encoded in another undocumented format and embedded as a blob into the DWG file. We found out it is implemented by a proprietary 3D kernel that is possibly licensed by Autodesk (and other companies) and embedded into AutoCAD. Sometimes it is text and sometimes it is binary. When it is encoded as text, it is almost human-readable. With enough samples one could reverse-engineer it without much effort.

FreeCAD

We were able to decode 3D objects as a text block almost by accident: the spec wasn’t clear enough, and there was a silly hack to make it not human-readable at a first glance. We found it out when an Ukrainian hacker sent a message to our mailing list. His English was very poor and we couldn’t figure out what he meant until he replied with a code snippet in C.

Currently, LibreDWG can decode R13, R14 and DWG 2000 files. DWG 2004 support is almost ready, but we still need to work on 2007 and 2010. Until version 5.1 of the spec there wasn’t enough information to implement it because either the document was corrupted or it had several sections intentionally omitted. Write support is partially implemented, but reading is our priority.

Judging by last year’s discussion in the mailing list, you never made any formal contacts to ODA, so it’s not quite clear whether they think their spec is used legally. Is it correct?

Rodrigo: No, we never made any formal contacts to ODA. They published the specification in a public area on their website, we read it and it helped us write our software. We never used their spec in any other way than that. If they didn’t want people to do it, they wouldn’t have published it in the first place.

How much of the work is based on the spec and how much did you have to reverse-engineer yourself?

Rodrigo: We didn’t do much reverse-engineering work, except when the spec was unclear or wrong.

It looks like after nearly 3 years no actual releases of LibreDWG have been done yet. Why?

Rodrigo: LibreDWG will be released when it is ready and stable. Sadly, since we are all volunteers and don’t have any kind of funding, we cannot work on it as much as we would like to. Plus, there wasn’t enough documentation about the most recent versions of the file, but now there is much more information available than a year ago.

The project seems to be inactive presently. Latest commits to the public Git repository are from January 2011. What happened?

Felipe: Unfortunately, the current licensing terms of LibreDWG (GPLv3 or later) are incompatible with the licensing terms of most free software CAD programs. So we’ve been talking to the FSF, which is one of the copyright holders for LibreDWG, in order to figure out the best relicensing strategy for LibreDWG.

This has been a pending issue for a while, so I have been less motivated to work on the project while we have this issue unsolved. It is very frustrating to work in a library project when no application actually uses the library at all.

Who made the original decision to license the code under GPLv3?

Rodrigo: The choice of GPLv3 is a “heritage” from libdwg.

And Free Software Foundation owns the copyright?

Rodrigo: Yes.

What license do you want for LibreDWG? LGPL?

Rodrigo: I don’t think that LGPL is a good choice, because then non-free software could benefit from it. I understand that reading DWG files is a nice feature that can make a CAD software more attractive and competitive, and we don’t want to make it available to software that harms the freedom of users.

I think that GPLv2+ would be a good choice, because some free programs that could benefit from its features are GPLv2 only, and the current developers cannot change the license.

Is LibreDWG already good enough to be used by 3rd party apps?

Felipe: Yes, it is. If you try using it, please report any issues, and we’ll be glad to fix them as soon as possible.

Do you feel like you have good contacts to developers of end-user free software?

Felipe: There’s not been much conversation with them yet. Some developers contacted us, but we mostly got stuck by the licensing issues.

LibreCAD

What’s the current situation with FSF and relicensing?

Rodrigo: I first contacted them a few months ago. They wanted more information to hand the decision over to RMS [Richard Matthew Stallman — LGW]. It is taking a bit longer than it should, because I didn’t have much time to gather all the information (like what would be the impact of changing the license, how many free software cads are GPLv2-only and so) and follow up the issue. Since few weeks they have all the information they need and now I’m waiting for them.

What end-user software developers say

There’s not a terrible lot of free CAD/CAx software to benefit from DWG support, but that still gives us three major players: LibreCAD, FreeCAD and Blender.

LibreCAD is an actively developed fork of the Qcad’s community edition. Ries van Twisk, leader of the project, told us:

Personally I don’t understand GNU’s unwillingness to change the license. There are less than a handful of projects that are using it and therefore there is no development going on. With LibreCAD, we have a couple of smart developers and they will for sure submit patches to LibreDWG, if we find bugs, buts it’s only possible if LibreDWG is GPLv2 or higher.

FreeCAD

FreeCAD is the mostly actively, if not the only developed free/open source 3D CAD application that could be the top “consumer” of LibreDWG. Yorik van Havre who specializes on 2D drafting and architecure/BIM features in FreeCAD, provided a rather extensive reply:

Basically I had few looks at LibreDWG, so what I write here could be a bit outdated. I actually met the two guys behind it, Rodrigo Da Silva and Felipe Sanches. They are Brazilian and live here in São Paulo too, so I bumped into them a couple of times.

At the time I met them, back in 2009, I got pretty interested in using LibreDWG in FreeCAD. I was working on a 2D module, a-la AutoCAD, and the idea of being able to import/export DWG files was very appealing.

Then the license discussions came, and we got the same problems as LibreCAD: the GPL v3 license is not compatible with GPL v2. And all that software, FreeCAD, LibreCAD and LibreDWG, inherit their license from other projects they are based on, so they simply cannot decide to change their license.

Then I had a closer look at the code, and began to understand the wide abyss between what the LibreDWG could hope to achieve and what would be “proper” DWG support.

The LibreDWG code is mainly based on a document emitted by the Open Design Alliance alliance that describes the DWG format. That document is very, very far from being complete. OTOH, I just had a quick look at the most recent revision, and indeed there is much, much more than when I saw it the first time. It’s hard for me to tell how far that allows to go, though. I think Rodrigo will be able to tell you that.

Either way, the LibreDWG team, as far as I remember, very quickly implemented about the totality of that document. It could then do basic things such as read a DWG file and extract simple things, such as lines, circles, layers, color, blocks, etc… And it only supported DWG versions up to 2004, the highest version described in the OpenDWG document by then.

Then the real problems began. Rodrigo and Felipe began to work on reverse-engineering DWG stuff in order to implement more. That was a very complicated work, and I think they got very little results. They both got involved in other projects (Felipe is a regular developer of Inkscape now, I believe), and got less time to allow to LibreDWG.

And if you look at the work to do in order to achieve something good, even if we say, okay, let’s just support 3D to begin with, and if you think that next year Autodesk will issue a new version of the DWG format, incompatible with older versions, and a good part of the work will need to be done again, you will begin to realize the huge, almost impossible work that is to offer DWG compatibility.

Compared to this, the DXF format was freely available, correctly documented, and every piece of software out there that supported DWG also supported DXF. So the decision was quickly made to stick with DXF and not lose a lot of time with DWG.

But basically it all comes down to that license issue. If that problem wasn’t there, using LibreDWG, even in its bare shape, could be useful for FreeCAD, and probably it would have been included by now.

Blender doesn’t have any code for reading or writing DWG files, but Open Assets Library (Assimp for short) has support for Blender in works. So we asked Alexander Gessler, one of Assimp’s core team members, for an opinion on the situation. Here is what he came up with:

Personally, I’m extremely unhappy with their [LibreDWG’s — LGW] GPL licensing. It prohibits its use in Assimp and for many other applications as well.

I don’t like dogmatic ideologies, and freeing software by force (as GPL/GNU does) is something I dislike in particular. It’s fine for applications, because it doesn’t hurt at this point, but, in my opinion, not for libraries that are designed to be used as freely as possible.

Apart from that (or rather: assuming this issue solved, i.e. licensing changed), it’s a great project, and DWG is an important file format and an important candidate for Assimp as well.

Finally, Ton Roosendaal, chairman of Blender Foundation, who earlier classified DWG as “the holy grail of file formats for the project and the open source movement”, said:

Blender is also still “GPLv2 or later”. For the time being we stick to that, moving to GPL 3 has no evident benefits I know of. My advice for LibreDWG: if you make a library, choosing a widely compatible license (MIT, BSD, or LGPL) is a very positive choice.

What FSF says

We asked FSF to comment on the licensing issue, and here is what Brett Smith, a license compliance engineer, replied:

I had a conversation with Scott Howard [a LibreCAD contributor — LGW] where he indicated that he was part of a group working on replacing all of the code under GPLv2 only with new code that would be released under GPLv2-or-later.

I understand that they’re also wondering if we’ll relicense LibreDWG, and that’s something I’m still discussing with the LibreDWG developers to figure out what the right policy would be. A change would address LibreCAD’s immediate concerns, but getting away from the dependency on the GPLv2-only code would be a smart long-term move for the project for lots of reasons, if that’s the licensing they prefer.

In other words, after an initial opposition Free Software Foundation seems to be coming to terms with 3rd party projects or, at least, is considering a possibility of it.

Conclusions

It looks like the two major issues that we mentioned in the beginning have been addressed.

The current (v5.2) revision of the DWG spec seems more complete. It’s worth noting, though, that we specifically asked LibreDWG developers about that, and they could only give it a cursory glance so far. Which means there still could be missing information that’s vital for development.

As for the second problem, a solution to the licensing issue is currently a work in progress with no clear statements made yet.

It really isn’t possible to judge on the future of DWG support in free CAD applications until the final agreement is reached, and the licensing of LibreDWG is adjusted.

If LibreDWG stays GPLv3+, free CAD software is going to be considerably backward in terms of compatibility with the real world. And if you think about the amount of work required to implement even very basic support for DWG, it is unlikely that someone’s going to venture starting a new, more liberally licensed library.

The unfortunate choice of a license isn’t something terribly uncommon. There are quite well-known free software projects where development of some features is blocked by incompatibility of GNU licenses with each other.

In particular, GEGL, the new GIMP’s image processing core, cannot ship operations in frequency domain developed in 2008 by a GSoC student due to FFTW3 being GPL.

The very same issue prevents Audacity from reusing parts of Gnome Wave Cleaner which also relies on FFTW3 for removing different kinds of noise from audio records.

Availability of legal code reuse is an essential feature of free software. If it fails, then there’s something going seriously wrong, and someone’s got to get their act together.

From now on we are monitoring the situation closely. Stay tuned for further news.

Edit: we published several updates to this story. The latest one is from December 2012. You can read it here.


Illustrations in this article are mostly done from files by Adrian Przekwas who maintains an excellent blog with FreeCAD tutorials. Check it out!


Patreon subscribers get early access to my posts. If you are feeling generous, you can also make a one-time donation on BuyMeACoffee.

Support Libre Arts at Patreon