
    Ogo                     j    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y	)
    )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y)BlockLayoutzBlockLayout has the same factory-functions as Layout, but is managed
    in the :class:`BlocksSection` class. It represents a DXF Block.

    returnc                 \    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     ^/var/www/html/public_html/myphp/venv/lib/python3.12/site-packages/ezdxf/layouts/blocklayout.py__contains__zBlockLayout.__contains__   s-     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                 B    | j                   j                  j                  S )zGet/set the BLOCK name)r   dxfnamer   s    r   r#   zBlockLayout.name%   s       $$)))r   Nc                 :    | j                   j                  |       y 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    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122r   valuec                 L    t        |      | j                  j                  _        y r%   )intr   r"   r+   r   r-   s     r   r,   zBlockLayout.can_explode<   s    (+E
%r   c                 T    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0r   c                 L    t        |      | j                  j                  _        y r%   )r/   r   r"   r2   r0   s     r   r3   zBlockLayout.scale_uniformlyG   s    &)%j#r   c                 T    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     DJJNN--..r   c                 L    t        |      | j                  j                  _        y r%   r6   r0   s     r   r7   zBlockLayout.base_pointP   s    $(K

!r   c                     d | D        S )zYReturns iterable of all :class:`~ezdxf.entities.attrib.Attdef`
        entities.
        c              3   B   K   | ]  }t        |t              s|  y wr%   )r   r   ).0es     r   	<genexpr>z&BlockLayout.attdefs.<locals>.<genexpr>X   s     9a:a#89s    r   s    r   attdefszBlockLayout.attdefsT   s     :499r   tagc                 (    | j                  |      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                 h    | j                         D ]  }||j                  j                  k(  s|c S  y)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`   s3     lln 	Ffjjnn$	 r   defaultc                 X    | j                  |      }||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@   rF   rE   s       r   get_attdef_textzBlockLayout.get_attdef_texti   s*     %>Nzzr   c                 0    d | j                         D        S )zAReturns iterable for all constant ATTDEF entities. (internal API)c              3   :   K   | ]  }|j                   s|  y wr%   is_constr;   rE   s     r   r=   z0BlockLayout.get_const_attdefs.<locals>.<genexpr>z   s     G6vGs   )r?   r   s    r   get_const_attdefszBlockLayout.get_const_attdefsx   s    GT\\^GGr   c                 B    t        d | j                         D              S )zWReturns ``True`` if the block has a non constant attribute
        definition.
        c              3   6   K   | ]  }|j                      y wr%   rL   rN   s     r   r=   z3BlockLayout.has_non_const_attdef.<locals>.<genexpr>   s     D6v&Ds   )anyr?   r   s    r   has_non_const_attdefz BlockLayout.has_non_const_attdef|   s     DT\\^DDDr   c                 x    | j                         }| j                  j                  t        j                  |       y r%   )rS   r   set_flag_stater   BLK_NON_CONSTANT_ATTRIBUTES)r   states     r   update_block_flagszBlockLayout.update_block_flags   s*    ))+

!!%"C"CUKr   )r   N) )__name__
__module____qualname____doc__r*   r   propertyr   r   r   r   r    r   r#   setterr"   r,   r3   r   r7   r   r   r   r?   rC   rB   rI   rO   rS   rX   r>   r   r   r   r   
   s   
	+d 	+ 'x ' ' (( ( ( *c * * 
[[+ + % % 3T 3 3 3 3 3 1 1 1 1T 1 1 /D / / 0 0 0 0:&) :0c 0d 0c hv&6 3  c H8F#3 HEd E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r   