Encoding DWG files, i.e. DWG write support, can be disabled via
./configure --disable-write
. The default formats and only useful
ones are currently r1.1 - r2000. Experimentally work is ongoing for the r2004
format, which is also used for r2010, r2013, and r2018.
The r2007 format version is not covered yet.
The pre-r13 formats are much simpler and can be written, but need some
hand-holding and manual conversions when converting from newer formats still.
See src/in_dxf.c for a high-level usage example. The default codepage is Latin-1, 30.
The highest level function for encoding a bitstream to a file is
dwg_write_file
, which dumps the dwg to a file.
Open filename and write the dwg to it. Return 0 if successful.
See add api for:
const int imperial, const int loglevel) Creates an initial template dwg structure in memory, suitable to be written to a DWG or DXF file, without any additional table records or entities. Creates ModelSpace, PaperSpace and most Tables and basic Dictionaries.
and how to add entities and objects from scratch.
Low level-functions:
Adds a new uninitialized object to the dwg->object[] array. Return 0 or -1 if successful, otherwise DWG_ERR_OUTOFMEM. -1 is the array was re-allocated.
Then for each object or entity type there is a
Initializes an object for the given OBJECT or ENTITY type, with all fields being zero’ed. This does not initialize the obj size, type, address, handlestream_size, bitsize fields.
The encoder is driven by the fields definition in the src/dwg.spec and the generated src/dynapi.c, which adds each field to the object. This is done by src/encode.c or any src/in_*.c import module.
Encodes the DWG bitstream from the fields of the object.
The iterator is similar to above, but you want to encode all data structures, not just the entities. But note that you need many helper functions, such as the dynapi, to create all needed sections to store a DWG if you didn’t read a DWG into the right a Dwg_Data* dwg struct already. This is especially important when importing from DXF or from an earlier or later DWG version.