File: custom_header_vars.py

package info (click to toggle)
ezdxf 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 104,528 kB
  • sloc: python: 182,341; makefile: 116; lisp: 20; ansic: 4
file content (34 lines) | stat: -rw-r--r-- 1,000 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Copyright (c) 2014-2022, Manfred Moitzi
# License: MIT License
import pathlib
import ezdxf

CWD = pathlib.Path("~/Desktop/Outbox").expanduser()
if not CWD.exists():
    CWD = pathlib.Path(".")

# ------------------------------------------------------------------------------
# create custom HEADER variables
#
# for more information about custom HEADER variables see:
# https://ezdxf.mozman.at/docs/tutorials/custom_data.html#custom-document-properties
# ------------------------------------------------------------------------------


def main():
    # this feature requires DXF R2000 or later
    doc = ezdxf.new("R2000")
    msp = doc.modelspace()

    # create some content
    points = [(0, 0), (3, 0), (6, 3), (6, 6)]
    msp.add_polyline2d(points)

    # create custom HEADER variables
    doc.header.custom_vars.append("Name", "Manfred Moitzi")
    doc.header.custom_vars.append("Adresse", "8020 Graz")
    doc.saveas(CWD / "custom_header_vars.dxf")


if __name__ == "__main__":
    main()