File: create_all_supported_dxf_versions.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 (35 lines) | stat: -rw-r--r-- 1,024 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
35
# Copyright (c) 2019-2022 Manfred Moitzi
# License: MIT License
import pathlib
import ezdxf
from ezdxf import zoom
from ezdxf.lldxf.const import versions_supported_by_new
from ezdxf.gfxattribs import GfxAttribs

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

# ------------------------------------------------------------------------------
# create DXF documents for all supported DXF versions
# ------------------------------------------------------------------------------


def create_doc(dxfversion: str):
    doc = ezdxf.new(dxfversion, setup=True)
    msp = doc.modelspace()
    msp.add_circle(
        center=(0, 0),
        radius=1.5,
        dxfattribs=GfxAttribs(layer="test", linetype="DASHED"),
    )

    zoom.extents(msp, factor=1.1)
    filename = CWD / f"{doc.acad_release}.dxf"
    doc.saveas(filename)
    print(f"DXF file '{filename}' created.")


if __name__ == "__main__":
    for version in versions_supported_by_new:
        create_doc(version)