File: modify_dxf_attributes.rst

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 (40 lines) | stat: -rw-r--r-- 918 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
.. _modify_dxf_attributes:

Modify DXF Attributes of Entities
=================================

All DXF attributes of an entity are grouped in the namespace attribute :attr:`dxf`. 
You can modify/set a DXF attribute by assignment:

.. code-block:: Python

    e.dxf.layer = "MyLayer"
    e.dxf.color = 9

... or by the :meth:`set` method:

.. code-block:: Python

    e.dxf.set('color', 9)

The attribute has to be supported by the DXF type otherwise a :class:`DXFAttributeError` 
will be raised.  You can check if an DXF attribute is supported by the method 
:meth:`dxf.is_supported`:

.. code-block:: Python

    line = msp.add_line((0, 0), (1, 0))
    assert line.dxf.is_supported("text") is False


.. seealso::
    
    **Tasks**

    - :ref:`Common graphical DXF attributes`
    - :ref:`get_dxf_attributes`
    - :ref:`delete_dxf_attributes`

    **Tutorials:**
   
    - :ref:`tut_common_graphical_attributes`