
    'j                        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
j        d          Z G d d          Z G d d          ZdS )    )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dS )
StoredSectionentities
list[Tags]c                    || _         d S N)r   )selfr   s     Q/DATA/AppData/hermes/venv/lib/python3.11/site-packages/ezdxf/sections/entities.py__init__zStoredSection.__init__   s         	tagwriterr   c                n    | j         D ]}|                    |           |                    d           d S )Nz  0
ENDSEC
)r   
write_tags	write_str)r   r   entitys      r   
export_dxfzStoredSection.export_dxf   sD    m 	) 	)F  ((((O,,,,,r   N)r   r   )r   r   )__name__
__module____qualname__r   r#    r   r   r   r      s<        ! ! ! !- - - - - -r   r   c                  @    e Zd ZdZ	 	 dddZdd
ZddZddZddZdS )EntitySectionzy:class:`EntitiesSection` is just a proxy for :class:`Modelspace` and
    active :class:`Paperspace` linked together.
    NdocOptional[Drawing]r   Optional[Iterable[DXFEntity]]c                `    || _         |$|                     t          |                     d S d S r   )r*   _builditer)r   r*   r   s      r   r   zEntitySection.__init__&   s7    
 KKX'''''  r   returnIterator[DXFEntity]c              #     K   | j         J | j         j        }t          |                                |                                          D ]}|V  dS )zbReturns an iterator for all entities of the modelspace and the active
        paperspace.
        N)r*   layoutsr	   
modelspaceactive_layout)r   r3   r"   s      r   __iter__zEntitySection.__iter__/   sf       x###("G..00'2G2G2I2IJJ 	 	FLLLL	 	r   intc                    | j         J | j         j        }t          |                                          t          |                                          z   S )zWReturns the count of all entities in the modelspace and the active paperspace.
        )r*   r3   lenr4   r5   )r   r3   s     r   __len__zEntitySection.__len__8   sO     x###("7%%''((3w/D/D/F/F+G+GGGr   Nonec                  	 | j         J t          dt          |                    }|                                dk    s|j        d         dk    rt          j        d          d	fd}t          d	| j         j                            d
                    t          d	| j         j                            d                    j	        j
        j	        j
        	t                      }|D ]} ||          s ||           d S )Nr   SECTION   )   ENTITIESz-Critical structure error in ENTITIES section.r"   r   c                    | j         j        }d}|k    rd}n/|k    rd}n&| j                             d          r| j         j        }|r                    |            d S                     |            d S )Nr   r>   
paperspace)dxfownerhasattrrB   
add_entity)r"   handlerB   mspmsp_layout_keypsppsp_layout_keys      r   addz!EntitySection._build.<locals>.addK   s    Z%FJ''

>))

##  3 $Z2
 'v&&&&&v&&&&&r   r   z*Model_Spacez*Paper_Space)r"   r   )r*   r   nextdxftype
base_classr
   DXFStructureErrorblock_recordsgetrC   rG   r   )
r   r   section_headrL   linked_entitiesr"   rH   rI   rJ   rK   s
         @@@@r   r.   zEntitySection._buildA   s=   x###OT(^^<<!!Y..,2I3
3 3 )?  	' 	' 	' 	' 	' 	' 	' 	' 	'$ =$("8"<"<^"L"LMM=$("8"<"<^"L"LMM!gn!gn'// 	 	F #?6** F		 	r   r   r   c                6   | j         J | j         j        }|                    d           |                                j                            |           |                                j                            |           |                    dd           d S )Nz  0
SECTION
  2
ENTITIES
r   ENDSEC)r*   r3   r!   r4   entity_spacer#   r5   
write_tag2)r   r   r3   s      r   r#   zEntitySection.export_dxfi   s    x###(";<<< 	)44Y???,77	BBBQ)))))r   )NN)r*   r+   r   r,   )r0   r1   )r0   r7   )r   r1   r0   r;   )r   r   r0   r;   )	r$   r%   r&   __doc__r   r6   r:   r.   r#   r'   r   r   r)   r)   !   s          "&26( ( ( ( (   H H H 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>re      s\   # " " " " " D D D D D D D D D D D D D D              ( ( ( ( ( ( &&&&&&&PPPPPPPPPPPP777777%%%%%% 
	7	#	#	- 	- 	- 	- 	- 	- 	- 	-P* P* P* P* P* P* P* P* P* P*r   