1.. _dwgmanagement:
2
3Document Management
4===================
5
6.. module:: ezdxf
7
8Create New Drawings
9-------------------
10
11.. autofunction:: new(dxfversion='AC1027', setup=False, units=6) -> Drawing
12
13Open Drawings
14-------------
15
16Open DXF drawings from file system or text stream, byte stream usage is not supported.
17
18DXF files prior to R2007 requires file encoding defined by header variable $DWGCODEPAGE, DXF R2007 and later
19requires an UTF-8 encoding.
20
21`ezdxf` supports reading of files for following DXF versions:
22
23=========== ========== ============== ===================================
24Version     Release    Encoding       Remarks
25=========== ========== ============== ===================================
26< AC1009               $DWGCODEPAGE   pre AutoCAD R12 upgraded to AC1009
27AC1009      R12        $DWGCODEPAGE   AutoCAD R12
28AC1012      R13        $DWGCODEPAGE   AutoCAD R13 upgraded to AC1015
29AC1014      R14        $DWGCODEPAGE   AutoCAD R14 upgraded to AC1015
30AC1015      R2000      $DWGCODEPAGE   AutoCAD R2000
31AC1018      R2004      $DWGCODEPAGE   AutoCAD R2004
32AC1021      R2007      UTF-8          AutoCAD R2007
33AC1024      R2010      UTF-8          AutoCAD R2010
34AC1027      R2013      UTF-8          AutoCAD R2013
35AC1032      R2018      UTF-8          AutoCAD R2018
36=========== ========== ============== ===================================
37
38.. autofunction:: readfile(filename: str, encoding: str = None, errors: str="surrogateescape") -> Drawing
39
40.. autofunction:: read(stream: TextIO) -> Drawing
41
42.. autofunction:: readzip(zipfile: str, filename: str = None, errors: str="surrogateescape") -> Drawing
43
44.. autofunction:: decode_base64(data: bytes, errors: str="surrogateescape") -> Drawing
45
46.. hint::
47
48    This works well with DXF files from trusted sources like AutoCAD or BricsCAD,
49    for loading DXF files with minor or major flaws look at the
50    :mod:`ezdxf.recover` module.
51
52Save Drawings
53-------------
54
55Save the DXF document to the file system by :class:`~ezdxf.document.Drawing` methods
56:meth:`~ezdxf.document.Drawing.save` or :meth:`~ezdxf.document.Drawing.saveas`.
57Write the DXF document to a text stream with :meth:`~ezdxf.document.Drawing.write`,
58the text stream requires at least a :meth:`write` method. Get required output
59encoding for text streams by property :attr:`Drawing.output_encoding`
60
61.. _globaloptions:
62
63Drawing Settings
64----------------
65
66The :class:`~ezdxf.sections.header.HeaderSection` stores meta data like modelspace extensions, user name or saving time
67and current application settings, like actual layer, text style or dimension style settings. These settings are not
68necessary to process DXF data and therefore many of this settings are not maintained by `ezdxf` automatically.
69
70Header variables set at new
71~~~~~~~~~~~~~~~~~~~~~~~~~~~
72
73================ =================================
74$ACADVER         DXF version
75$TDCREATE        date/time at creating the drawing
76$FINGERPRINTGUID every drawing gets a GUID
77================ =================================
78
79Header variables updated at saving
80~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81
82================ =================================
83$TDUPDATE        actual date/time at saving
84$HANDSEED        next available handle as hex string
85$DWGCODEPAGE     encoding setting
86$VERSIONGUID     every saved version gets a new GUID
87================ =================================
88
89.. seealso::
90
91    - Howto: :ref:`set/get header variables`
92    - Howto: :ref:`set drawing units`
93