
    Og                        d dl mZ d dlmZmZmZmZmZ d dlm	Z	 d dl
Z
d dlmZ d dlmZ erd dlmZ d dlmZmZmZmZ d d	lmZ d d
lmZ  e
j2                  d      Z G d d      Z G d d      Zy)    )annotations)TYPE_CHECKINGIterableIteratorcastOptional)chainN)const)entity_linker)Drawing)	DXFEntityDXFTagStorageBlockRecord
DXFGraphic)AbstractTagWriter)Tagsezdxfc                      e Zd ZddZddZy)StoredSectionc                    || _         y N)entities)selfr   s     \/var/www/html/public_html/myphp/venv/lib/python3.12/site-packages/ezdxf/sections/entities.py__init__zStoredSection.__init__   s	         c                j    | j                   D ]  }|j                  |        |j                  d       y )Nz  0
ENDSEC
)r   
write_tags	write_str)r   	tagwriterentitys      r   
export_dxfzStoredSection.export_dxf   s3    mm 	)F  (	) 	O,r   N)r   z
list[Tags])r    r   )__name__
__module____qualname__r   r"    r   r   r   r      s    !-r   r   c                  D    e Zd ZdZ	 	 d	 	 	 d	dZd
dZddZddZddZy)EntitySectionzy:class:`EntitiesSection` is just a proxy for :class:`Modelspace` and
    active :class:`Paperspace` linked together.
    Nc                L    || _         || j                  t        |             y y r   )doc_builditer)r   r*   r   s      r   r   zEntitySection.__init__&   s&    
 KKX'  r   c              #     K   | j                   J | j                   j                  }t        |j                         |j	                               D ]  }|  yw)zbReturns an iterator for all entities of the modelspace and the active
        paperspace.
        N)r*   layoutsr	   
modelspaceactive_layout)r   r.   r!   s      r   __iter__zEntitySection.__iter__/   sT      xx###((""G..0'2G2G2IJ 	FL	s   AAc                    | j                   J | j                   j                  }t        |j                               t        |j	                               z   S )zWReturns the count of all entities in the modelspace and the active paperspace.
        )r*   r.   lenr/   r0   )r   r.   s     r   __len__zEntitySection.__len__8   sJ     xx###((""7%%'(3w/D/D/F+GGGr   c                0  	 | j                   J t        dt        |            }|j                         dk7  s|j                  d   dk7  rt        j                  d      d
	fd}t        d| j                   j                  j                  d            t        d| j                   j                  j                  d	            j                  j                  j                  j                  	t               }|D ]  } ||      r ||        y )Nr   SECTION   )   ENTITIESz-Critical structure error in ENTITIES section.c                   | j                   j                  }d}|k(  rd}n9|k(  rd}n1| j                   j                  d      r| j                   j                  }|rj	                  |        y j	                  |        y )Nr   r7   
paperspace)dxfownerhasattrr;   
add_entity)r!   handler;   mspmsp_layout_keypsppsp_layout_keys      r   addz!EntitySection._build.<locals>.addK   sr    ZZ%%FJ'
>)
## $ZZ22
v&v&r   r   z*Model_Spacez*Paper_Space)r!   r   )r*   r   nextdxftype
base_classr
   DXFStructureErrorblock_recordsgetr<   r@   r   )
r   r   section_headrE   linked_entitiesr!   rA   rB   rC   rD   s
         @@@@r   r+   zEntitySection._buildA   s    xx###OT(^<!Y.,2I2I3
3 ))? 	' 	'$ =$(("8"8"<"<^"LM=$(("8"8"<"<^"LM!ggnn!ggnn'/ 	F #6*F		r   c                6   | j                   J | j                   j                  }|j                  d       |j                         j                  j                  |       |j                         j                  j                  |       |j                  dd       y )Nz  0
SECTION
  2
ENTITIES
r   ENDSEC)r*   r.   r   r/   entity_spacer"   r0   
write_tag2)r   r    r.   s      r   r"   zEntitySection.export_dxfi   s|    xx###(("";< 	))44Y?,,77	BQ)r   )NN)r*   zOptional[Drawing]r   zOptional[Iterable[DXFEntity]])returnIterator[DXFEntity])rR   int)r   rS   rR   None)r    r   rR   rU   )	r#   r$   r%   __doc__r   r1   r4   r+   r"   r&   r   r   r(   r(   !   s<     "&26(( 0(H&P*r   r(   )
__future__r   typingr   r   r   r   r   	itertoolsr	   loggingezdxf.lldxfr
   ezdxf.entitiesr   ezdxf.documentr   r   r   r   r   ezdxf.lldxf.tagwriterr   ezdxf.lldxf.tagsr   	getLoggerloggerr   r(   r&   r   r   <module>rb      sX    # D D    (&PP7% 
		7	#	- 	-P* P*r   