File: create_point_examples.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 (62 lines) | stat: -rw-r--r-- 1,097 bytes parent folder | download | duplicates (2)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Copyright (c) 2020, Manfred Moitzi
# License: MIT License
import ezdxf


def new_doc(pdmode: int, pdsize: float = 1):
    doc = ezdxf.new("R2000")
    doc.header["$PDMODE"] = pdmode
    doc.header["$PDSIZE"] = pdsize
    return doc


PDSIZE = 0.5
MODES = [
    0,
    1,
    2,
    3,
    4,
    32,
    33,
    34,
    35,
    36,
    64,
    65,
    66,
    67,
    68,
    96,
    97,
    98,
    99,
    100,
]


def add_point(x, angle: float, color: int):
    point = msp.add_point(
        (x, 3),
        dxfattribs={
            "color": color,
            "angle": angle,
        },
    )
    for entity in [
        e.translate(0, -2, 0) for e in point.virtual_entities(PDSIZE, pdmode)
    ]:
        msp.add_entity(entity)


for pdmode in MODES:
    doc = new_doc(pdmode, PDSIZE)
    msp = doc.modelspace()
    msp.add_lwpolyline([(0, 0), (10, 0), (10, 4), (0, 4)], close=True)
    add_point(1, 0, 1)
    add_point(3, 30, 2)
    add_point(5, 45, 3)
    add_point(7, 60, 4)
    add_point(9, 90, 6)
    doc.set_modelspace_vport(10, (5, 2))
    doc.saveas(f"points_pdmode_{pdmode}.dxf")