File: print_layout_properties.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 (82 lines) | stat: -rw-r--r-- 3,183 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
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Copyright (c) 2018-2022, Manfred Moitzi
# License: MIT License
import sys
import ezdxf

# ------------------------------------------------------------------------------
# print DXF attributes of layouts
#
# docs about layouts: https://ezdxf.mozman.at/docs/layouts/index.html
# ------------------------------------------------------------------------------


def print_layout(layout):
    dxf = layout.dxf_layout.dxf
    print(f"#LAYOUT: {layout.name}")
    print("##PLOT SETTINGS:")
    print(f"(1) page_setup_name: {dxf.plot_configuration_file}")
    print(f"(2) plot_configuration_file: {dxf.plot_configuration_file}")
    print(f"(4) paper_size: {dxf.paper_size}")
    print(f"(6) plot_view_name: {dxf.plot_view_name}")
    print(f"(40) left_margin: {dxf.left_margin}")
    print(f"(41) bottom_margin: {dxf.bottom_margin}")
    print(f"(42) right_margin: {dxf.right_margin}")
    print(f"(43) top_margin: {dxf.top_margin}")
    print(f"(44) paper_width: {dxf.paper_width}")
    print(f"(45) paper_height: {dxf.paper_height}")
    print(f"(46) plot_origin_x_offset: {dxf.plot_origin_x_offset}  ")
    print(f"(47) plot_origin_y_offset: {dxf.plot_origin_y_offset}  ")
    print(f"(48) plot_window_x1: {dxf.plot_window_x1}")
    print(f"(49) plot_window_y1: {dxf.plot_window_y1}")
    print(f"(140) plot_window_x2: {dxf.plot_window_x2}")
    print(f"(141) plot_window_y2: {dxf.plot_window_y2}")
    print(f"(142) scale_numerator: {dxf.scale_numerator}")
    print(f"(143) scale_denominator: {dxf.scale_denominator}")
    flags = dxf.plot_layout_flags
    print(f"(70) plot_layout_flags: {flags} b{flags:b}")
    print(f"(72) plot_paper_units: {dxf.plot_paper_units}")
    print(f"(73) plot_rotation: {dxf.plot_rotation}")
    print(f"(74) plot_type: {dxf.plot_type}")
    print(f"(7) current_style_sheet: {dxf.current_style_sheet}")
    print(f"(75) standard_scale_type: {dxf.standard_scale_type}")
    print(f"(147) unit_factor: {dxf.unit_factor}")
    print(f"(148) paper_image_origin_x: {dxf.paper_image_origin_x}")
    print(f"(149) paper_image_origin_y: {dxf.paper_image_origin_y}")
    print("##LAYOUT SETTINGS:")
    print(f"(1) name: {dxf.name}  ")
    print(f"(7) layout_flags: {dxf.name}  ")
    flags = dxf.layout_flags
    print(f"(70) layout_flags: {flags} b{flags:b}")
    print(f"(71) taborder: {dxf.taborder}")
    print(f"(10) limmin: {dxf.limmin}")
    print(f"(11) limmax: {dxf.limmax}  ")
    print(f"(12) insert_base: {dxf.insert_base}")
    print(f"(14) extmin: {dxf.extmin}")
    print(f"(15) extmax: {dxf.extmax}")
    print(f"(146) elevation: {dxf.elevation}")
    print(f"(13) ucs_origin: {dxf.ucs_origin}")
    print(f"(16) ucs_xaxis: {dxf.ucs_xaxis}")
    print(f"(17) ucs_yaxis: {dxf.ucs_yaxis}")
    print(f"(76) ucs_type: {dxf.ucs_type}\n")


def print_layouts(layouts):
    for layout in layouts:
        print_layout(layout)


def process_file(filename):
    doc = ezdxf.readfile(filename)
    if doc.dxfversion > "AC1009":
        print_layouts(doc.layouts)
    else:
        print(f"DXF R12 not supported: {filename}")


def run(files):
    for filename in files:
        process_file(filename)


if __name__ == "__main__":
    run(sys.argv[1:])