After 18 months I’ve finally started to code on the DrawGin library again and made the following changes.
- * Refactored project directory structure.
- ** Added VS 2008 solution file (no longer need cmake to build one).
- Some code cleanup.
- Fix bug when decoding class maps with multiple sections and added additional logging to help locate said bug.
In the VS property page for DrawinApp, added the following line to the Debugging/Command Arguments section:
–v=4 –log_dir=$(OutDir)\logs –alsologtostderr=1 –drawing=C:\Users\Paul\Documents\TestDwgs\TestDwg3.dwg
Decoding the Objects section is still a todo item. Once completed the library should be able to read AutoCAD R14 drawing files.
* The CMake projects files have not been updated to reflect the changed directory structure. Then means creating projects/solutions for your favorite IDE is temporarily broken.
The DrawGin library is rapidly taking shape and able to read most sections of an AutoCAD R14 formatted drawing. The next section to code up is the area where AcDbObject and AcDbEntity derived objects are stored (section 6 below). For the purpose of deserializing the bit encoded drawing data, sections 1, 2, 3, 4, 5 are completed.
- Drawing File Header – Defines where key sections are located within the drawing file.
- Preview Image – Bitmap image created when drawing was last saved.
- Header Variables – various setting variables associated with the drawing file.
- Classes Map – Holds information about various application defined classes that are used (instances of) in the drawing.
- Objects Map – Tells the file position of each object stored in the drawing (with AutoCAD object handle)
- Objects – The object instances referenced in the Objects Map (these are AcDbObject and AcDbEntity derived).
Most of the drawing format is defined at the bit level, which require special IO routines found in the OcBs directory (OcBitStream). The OcBsStreamIn class handles reading the various bit level data types and keeps track of the running CRC calculation. The stream also has a 4K memory buffer and handles huge 100 meg files, no problem.
Classes in the OcDb represent the various data types that make up a drawing. Most of the classes will have a one-to-one similarity by name to those found in Autodesk’s ObjectARX SDK. At this time DrawGin is not going for ObjectARX compatibility, so member function names and signatures will not be the same.
Future blog entries will delve into the framework and implementation details. For now just wanted to post a quick status update.
DrawGin is a new open source project to read and write “.dwg” file formats. Current work is focused on the cross platform C++ framework to support reading drawing files in the AutoCAD R14 format, with write support to follow shortly thereafter.
There is lots of source code to view at the project page, and if you are interested in contributing to DrawGin, let me know. The code currently compiles in OS X and Linux using the Codelite IDE, and in Windows using Visual C++ 2008.
The “.dwg” format specification, versions 4.0 and 5.1, published by the Open Design Alliance are the reference documents used to write the DrawGin library.
Figures there would be a problem installing gdb on Snow Leopard using Macports. The error message was
libbfd.c: In function ‘bfd_get_b_signed_64’:
lipo: can’t figure out the architecture type of: …
Looking at the build log file shows gdb being built for i386 and x86_64. After a little poking around I found the culprit to be in
where when I initially installed Macports had enabled +universal (don’t recall why). So, comment out the +universal line and rebuilt gdb.
sudo port clean gdb
sudo port install gdb
Afterwards, the new gdb will be installed to
I decided to install gcc 4.5.1 via Macports and the process didn’t exactly go smoothly. IIRC, the initial error was something about base_file.cc not being find. I’m not sure what caused the problem, however the fix was to temporarily rename the directory /opt/local to /opt/local-temp. The only packages installed in /opt/local/ are python 2.6, git, and Qt4.7.
So the basic steps if you have problems with the install using Macports is
mv local local-temp
sudo port clean gcc45
sudo port selfupdate
sudo port upgrade outdated
sudo port install gcc45
Towards the end of the build process there was another error about libpng being wrong or something. Simply reinstalling libpng via macports resolved the issue and allowed gcc finish building.
sudo port clean libpng
sudo port install libpng
sudo port install gcc45
Afterwards, rename /opt/local-temp to /opt-local.
If you type gcc –version at the command line the version install with XCode will probably run. This is because the Macports version is named gcc-mp-45. Using Macports install gcc_select.
sudo port install gcc_select
gcc_select –l will list the available versions of gcc, and gcc_select mp-gcc45 will make version 4.5 the default. This changes the symbolic link for /opt/local/bin/gcc. I also had to add the new symbolic link to /usr/local/bin/gcc (make a copy of the original) in order to get everything to work correctly.