
    'jo                     r    d dl mZmZ d dlmZmZ d dlmZ ddlm	Z	 d dl
mZmZmZmZ  G d de	          Zd	S )
    )IterableOptional)Vec3UVec)const   )
BaseLayout)
DXFGraphicAttDefBlockEndBlkc                      e Zd ZdZdefdZedee         fd            Z	edee
         fd            Zedefd            Zej        dd            Zed	             Zedefd
            Zej        defd            Zedefd            Zej        defd            Zedefd            Zej        deddfd            Zdee         fdZdedefdZdedee         fdZddededefdZdee         fdZdefdZd ZdS )BlockLayoutzBlockLayout has the same factory-functions as Layout, but is managed
    in the :class:`BlocksSection` class. It represents a DXF Block.

    returnc                 X    t          |t                    r| j        |         }|| j        v S )zReturns ``True`` if block contains `entity`.

        Args:
             entity: :class:`DXFGraphic` object or handle as hex string

        )
isinstancestrentitydbentity_space)selfentitys     S/DATA/AppData/hermes/venv/lib/python3.11/site-packages/ezdxf/layouts/blocklayout.py__contains__zBlockLayout.__contains__   s0     fc"" 	+]6*F***    c                     | j         j        S )z5the associated :class:`~ezdxf.entities.Block` entity.)block_recordblockr   s    r   r   zBlockLayout.block   s      &&r   c                     | j         j        S )z6the associated :class:`~ezdxf.entities.EndBlk` entity.)r   endblkr   s    r   r    zBlockLayout.endblk    s      ''r   c                 $    | j         j        j        S )zGet/set the BLOCK name)r   dxfnamer   s    r   r#   zBlockLayout.name%   s      $))r   Nc                 :    | j                             |           d S N)r   rename)r   new_names     r   r#   zBlockLayout.name*   s      *****r   c                     | j         j        S )z_DXF name space of associated :class:`~ezdxf.entities.BlockRecord`
        table entry.
        )r   r"   r   s    r   r"   zBlockLayout.dxf.   s    
  $$r   c                 >    t          | j        j        j                  S )z\Set property to ``True`` to allow exploding block references of
        this block.
        )boolr   r"   exploder   s    r   can_explodezBlockLayout.can_explode5   s    
 D%)1222r   valuec                 B    t          |          | j        j        _        d S r%   )intr   r"   r+   r   r-   s     r   r,   zBlockLayout.can_explode<   s    (+E

%%%r   c                 >    t          | j        j        j                  S )zgSet property to ``True`` to allow block references of this block
        only scale uniformly.
        )r*   r   r"   scaler   s    r   scale_uniformlyzBlockLayout.scale_uniformly@   s    
 D%)/000r   c                 B    t          |          | j        j        _        d S r%   )r/   r   r"   r2   r0   s     r   r3   zBlockLayout.scale_uniformlyG   s    &)%jj###r   c                 >    t          | j        j        j                  S )z$Get/Set the base point of the block.r   r   r"   
base_pointr   s    r   r7   zBlockLayout.base_pointK   s     DJN-...r   c                 B    t          |          | j        j        _        d S r%   r6   r0   s     r   r7   zBlockLayout.base_pointP   s    $(KK
!!!r   c                     d | D             S )zYReturns iterable of all :class:`~ezdxf.entities.attrib.Attdef`
        entities.
        c              3   D   K   | ]}t          |t                    |V  d S r%   )r   r   ).0es     r   	<genexpr>z&BlockLayout.attdefs.<locals>.<genexpr>X   s1      99a:a#8#89999999r    r   s    r   attdefszBlockLayout.attdefsT   s     :949999r   tagc                 0    |                      |          duS )z_Returns ``True`` if an :class:`~ezdxf.entities.attrib.Attdef` for
        `tag` exist.
        N)
get_attdef)r   r@   s     r   
has_attdefzBlockLayout.has_attdefZ   s     s##4//r   c                 \    |                                  D ]}||j        j        k    r|c S dS )z^Returns attached :class:`~ezdxf.entities.attrib.Attdef` entity by
        `tag` name.
        N)r?   r"   r@   )r   r@   attdefs      r   rB   zBlockLayout.get_attdef`   s=     llnn 	 	Ffjn$$ %tr    defaultc                 L    |                      |          }||S |j        j        S )a  Returns text content for :class:`~ezdxf.entities.attrib.Attdef`
        `tag` as string or returns `default` if no :class:`Attdef` for `tag`
        exist.

        Args:
            tag: name of tag
            default: default value if `tag` not exist

        )rB   r"   text)r   r@   rG   rE   s       r   get_attdef_textzBlockLayout.get_attdef_texti   s)     %%>Nzr   c                 >    d |                                  D             S )zAReturns iterable for all constant ATTDEF entities. (internal API)c              3   (   K   | ]}|j         	|V  d S r%   is_constr;   rE   s     r   r=   z0BlockLayout.get_const_attdefs.<locals>.<genexpr>z   s)      GG6vGGGGGGGr   )r?   r   s    r   get_const_attdefszBlockLayout.get_const_attdefsx   s    GGT\\^^GGGGr   c                 X    t          d |                                 D                       S )zWReturns ``True`` if the block has a non constant attribute
        definition.
        c              3   &   K   | ]}|j          V  d S r%   rM   rO   s     r   r=   z3BlockLayout.has_non_const_attdef.<locals>.<genexpr>   s'      DD6v&DDDDDDr   )anyr?   r   s    r   has_non_const_attdefz BlockLayout.has_non_const_attdef|   s)     DDT\\^^DDDDDDr   c                 x    |                                  }| j                            t          j        |           d S r%   )rT   r   set_flag_stater   BLK_NON_CONSTANT_ATTRIBUTES)r   states     r   update_block_flagszBlockLayout.update_block_flags   s4    ))++
!!%"CUKKKKKr   )r   N)rF   )__name__
__module____qualname____doc__r*   r   propertyr   r   r   r   r    r   r#   setterr"   r,   r3   r   r7   r   r   r   r?   rC   rB   rJ   rP   rT   rY   r>   r   r   r   r   
   s        
	+d 	+ 	+ 	+ 	+ 'x ' ' ' X' (( ( ( ( X( *c * * * X* 
[+ + + [+ % % X% 3T 3 3 3 X3 3 3 3 3 3 1 1 1 1 X1 1T 1 1 1 1 /D / / / X/ 0 0 0 0 0 0:&) : : : :0c 0d 0 0 0 0c hv&6     3  c    H8F#3 H H H HEd E E E EL L L L Lr   r   N)typingr   r   
ezdxf.mathr   r   ezdxf.lldxfr   baser	   ezdxf.entitiesr
   r   r   r   r   r>   r   r   <module>re      s    & % % % % % % % ! ! ! ! ! ! ! !             < < < < < < < < < < < <zL zL zL zL zL* zL zL zL zL zLr   