File: dxfgfx.rst

package info (click to toggle)
ezdxf 0.18.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 46,952 kB
  • sloc: python: 158,141; javascript: 166; cpp: 138; makefile: 116; lisp: 20
file content (175 lines) | stat: -rw-r--r-- 5,340 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
DXF Graphic Entity Base Class
=============================

.. module:: ezdxf.entities
    :noindex:

Common base class for all graphical DXF entities.

This entities resides in entity spaces like :class:`~ezdxf.layouts.Modelspace`, any :class:`~ezdxf.layouts.Paperspace`
or :class:`~ezdxf.layouts.BlockLayout`.

============ =================================
Subclass of  :class:`ezdxf.entities.DXFEntity`
============ =================================

.. warning::

    Do not instantiate entity classes by yourself - always use the provided factory functions!

.. class:: DXFGraphic

    .. attribute:: rgb

        Get/set DXF attribute :attr:`dxf.true_color` as ``(r, g, b)`` tuple, returns ``None`` if attribute
        :attr:`dxf.true_color` is not set.

        .. code-block:: python

            entity.rgb = (30, 40, 50)
            r, g, b = entity.rgb

        This is the recommend method to get/set RGB values, when ever possible do not use the DXF low level attribute
        :attr:`dxf.true_color`.


    .. attribute:: transparency

        Get/set transparency value as float. Value range ``0`` to ``1``, where ``0`` means entity is opaque and
        ``1`` means entity is 100% transparent (invisible). This is the recommend method to get/set transparency
        values, when ever possible do not use the DXF low level attribute :attr:`DXFGraphic.dxf.transparency`

        This attribute requires DXF R2004 or later, returns ``0`` for prior DXF versions
        and raises :class:`DXFAttributeError` for setting `transparency` in older DXF versions.

    .. autoproperty:: is_transparency_by_layer

    .. autoproperty:: is_transparency_by_block

    .. automethod:: ocs

    .. automethod:: get_layout

    .. automethod:: unlink_from_layout

    .. automethod:: copy_to_layout

    .. automethod:: move_to_layout

    .. automethod:: graphic_properties

    .. automethod:: has_hyperlink

    .. automethod:: get_hyperlink

    .. automethod:: set_hyperlink

    .. automethod:: transform

    .. automethod:: translate

    .. automethod:: scale

    .. automethod:: scale_uniform

    .. automethod:: rotate_x

    .. automethod:: rotate_y

    .. automethod:: rotate_z

    .. automethod:: rotate_axis

.. _Common graphical DXF attributes:

Common graphical DXF attributes
-------------------------------

    .. attribute:: DXFGraphic.dxf.layer

        Layer name as string; default = ``'0'``

    .. attribute:: DXFGraphic.dxf.linetype

        Linetype as string, special names ``'BYLAYER'``, ``'BYBLOCK'``; default value is ``'BYLAYER'``

    .. attribute:: DXFGraphic.dxf.color

        :ref:`aci`,  default = ``256``

        Constants defined in :mod:`ezdxf.lldxf.const`

        === =========
        0   BYBLOCK
        256 BYLAYER
        257 BYOBJECT
        === =========

    .. attribute:: DXFGraphic.dxf.lineweight

        Line weight in mm times 100 (e.g. 0.13mm = 13). There are fixed valid lineweights which are accepted by AutoCAD,
        other values prevents AutoCAD from loading the DXF document, BricsCAD isn't that picky. (requires DXF R2000)

        Constants defined in :mod:`ezdxf.lldxf.const`

        === ==================
        -1  LINEWEIGHT_BYLAYER
        -2  LINEWEIGHT_BYBLOCK
        -3  LINEWEIGHT_DEFAULT
        === ==================

        Valid DXF lineweights stored in ``VALID_DXF_LINEWEIGHTS``:
        0, 5, 9, 13, 15, 18, 20, 25, 30, 35, 40, 50, 53, 60, 70, 80, 90, 100, 106, 120, 140, 158, 200, 211

    .. attribute:: DXFGraphic.dxf.ltscale

        Line type scale as float; default = ``1.0`` (requires DXF R2000)

    .. attribute:: DXFGraphic.dxf.invisible

        ``1`` for invisible, ``0`` for visible; default = ``0`` (requires DXF R2000)

    .. attribute:: DXFGraphic.dxf.paperspace

        ``0`` for entity resides in modelspace or a block, ``1`` for paperspace,
        this attribute is set automatically by adding an entity to a layout
        (feature for experts); default = ``0``

    .. attribute:: DXFGraphic.dxf.extrusion

        Extrusion direction as 3D vector; default = ``(0, 0, 1)``

    .. attribute:: DXFGraphic.dxf.thickness

        Entity thickness as float; default = ``0.0`` (requires DXF R2000)

    .. attribute:: DXFGraphic.dxf.true_color

        True color value as int ``0x00RRGGBB``, use :attr:`DXFGraphic.rgb` to
        get/set true color values as ``(r, g, b)`` tuples. (requires DXF R2004)

    .. attribute:: DXFGraphic.dxf.color_name

        Color name as string. (requires DXF R2004)

    .. attribute:: DXFGraphic.dxf.transparency

        Transparency value as int, ``0x020000TT`` ``0x00`` = 100% transparent /
        ``0xFF`` = opaque, special value ``0x01000000`` means transparency by
        block. An unset transparency value means transparency by layer.
        Use :attr:`DXFGraphic.transparency` to get/set transparency as float
        value, and the properties :attr:`DXFGraphic.is_transparency_by_block`
        and :attr:`DXFGraphic.is_transparency_by_layer` to check special cases.

        (requires DXF R2004)

    .. attribute:: DXFGraphic.dxf.shadow_mode

        === ==========================
        0   casts and receives shadows
        1   casts shadows
        2   receives shadows
        3   ignores shadows
        === ==========================

        (requires DXF R2007)