Block
=====

.. module:: ezdxf.entities
    :noindex:

BLOCK (`DXF Reference`_) entity is embedded into the :class:`~ezdxf.layouts.BlockLayout` object.
The BLOCK entity is accessible by the :attr:`BlockLayout.block` attribute.

======================== ==========================================
Subclass of              :class:`ezdxf.entities.DXFEntity`
DXF type                 ``'BLOCK'``
Factory function         :meth:`Drawing.blocks.new` (returns a :class:`~ezdxf.layouts.BlockLayout`)
======================== ==========================================

.. seealso::

    :ref:`tut_blocks` and DXF Internals: :ref:`Block Management Structures`


.. class:: Block

    .. attribute:: dxf.handle

        BLOCK handle as plain hex string. (feature for experts)

    .. attribute:: dxf.owner

        Handle to owner as plain hex string. (feature for experts)

    .. attribute:: dxf.layer

        Layer name as string; default value is ``'0'``

    .. attribute:: dxf.name

        BLOCK name as string. (case insensitive)

    .. attribute:: dxf.base_point

        BLOCK base point as ``(x, y, z)`` tuple, default value is ``(0, 0, 0)``

        Insertion location referenced by the :class:`~ezdxf.entities.Insert` entity to place the block reference
        and also the center of rotation and scaling.

    .. attribute:: dxf.flags

        BLOCK flags (bit-coded)

        ==== ===========
        1    Anonymous block generated by hatching, associative dimensioning, other internal operations, or an application
        2    Block has non-constant attribute definitions (this bit is not set if the block has any attribute
             definitions that are constant, or has no attribute definitions at all)
        4    Block is an external reference (xref)
        8    Block is an xref overlay
        16   Block is externally dependent
        32   This is a resolved external reference, or dependent of an external reference (ignored on input)
        64   This definition is a referenced external reference (ignored on input)
        ==== ===========

    .. attribute:: dxf.xref_path

        File system path as string, if this block defines an external reference (XREF).

    .. autoattribute:: is_layout_block

    .. autoattribute:: is_anonymous

    .. autoattribute:: is_xref

    .. autoattribute:: is_xref_overlay


EndBlk
======

ENDBLK entity is embedded into the :class:`~ezdxf.layouts.BlockLayout` object.
The ENDBLK entity is accessible by the :attr:`BlockLayout.endblk` attribute.

======================== ==========================================
Subclass of              :class:`ezdxf.entities.DXFEntity`
DXF type                 ``'ENDBLK'``
======================== ==========================================

.. class:: EndBlk

    .. attribute:: dxf.handle

        BLOCK handle as plain hex string. (feature for experts)

    .. attribute:: dxf.owner

        Handle to owner as plain hex string. (feature for experts)

    .. attribute:: dxf.layer

        Layer name as string; should always be the same as :attr:`Block.dxf.layer`

.. _DXF Reference: http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-66D32572-005A-4E23-8B8B-8726E8C14302