
    h(                    $   S SK Jr  S SKJrJr  S SKJr  S SKrS SKJ	r	  S SK
JrJrJrJrJr  S SKJrJrJrJr  S SKJrJrJr  S S	KJr  S
SKJr  \(       a.  S SKJr  S SKJ r J!r!J"r"  S SKJ#r#  S SK$J%r%  S SK&J'r'  S SK(J)r)  S SK*J+r+  S/r,\RZ                  " S5      r.\" S\" S\	R^                  S9\" SSS9\" SS
\\	R`                  \S9\" SS \\	R`                  \S9\" SS \\	Rb                  " S S5      \S9S.5      r2\" \25      r3\ " S  S\5      5       r4g)!    )annotations)TYPE_CHECKINGOptional)SelfN)	validator)DXFAttrDXFAttributesDefSubclassRETURN_DEFAULTgroup_code_mapping)DXF12SUBCLASS_MARKERDXF2007DXFInternalEzdxfError)
base_classSubclassProcessor	DXFEntity)acdb_symbol_table_record   )register_entity)Auditor)
DXFGraphicBlockEndBlk)DXFNamespaceEntitySpace)BlockLayout)AbstractTagWriter)xrefBlockRecordezdxfAcDbBlockTableRecord   iT  0)defaulti  )r&   
dxfversionr   fixeri  F      )namelayoutexplodescaleunitsc                  n  ^  \ rS rSrSrSr\" \\\	5      r
SU 4S jjrSS jrSS jrSS jr S   SU 4S jjjrSU 4S	 jjrSS
 jrS U 4S jjrS!U 4S jjrU 4S jr\S"S j5       r\S"S j5       r\S"S j5       r\S"S j5       r\S"S j5       r\S"S j5       rS#S jrS#S jrS#S jrS$U 4S jjrSr U =r!$ )%r!   [   zDXF BLOCK_RECORD table entity

BLOCK_RECORD is the hard owner of all entities in BLOCK definitions, this
means owner tag of entities is handle of BLOCK_RECORD.

BLOCK_RECORDc                p   > SSK Jn  [        TU ]  5         U" 5       U l        S U l        S U l        S U l        g )Nr   r   )ezdxf.entitydbr   super__init__entity_spaceblockendblkblock_layout)selfr   	__class__s     L/var/www/html/env/lib/python3.13/site-packages/ezdxf/entities/blockrecord.pyr6   BlockRecord.__init__g   s3    . (M&*
(,37    c                    Xl         X l        U R                  R                  U R                   R                  l        U R                  R                  U R                  R                  l        g N)r8   r9   dxfhandleowner)r;   r8   r9   s      r=   	set_blockBlockRecord.set_blocks   s<    
#xx

 $r?   c                    Xl         g rA   )r7   )r;   r7   s     r=   set_entity_spaceBlockRecord.set_entity_spacey   s    (r?   c                v    U R                   c   eXR                  l        XR                   R                  l        g rA   )r8   rB   r+   )r;   r+   s     r=   renameBlockRecord.rename|   s)    zz%%%"

r?   c                `   > [         TU ]  U5      nU(       a  UR                  U[        5        U$ rA   )r5   load_dxf_attribssimple_dxfattribs_loaderacdb_blockrec_group_codes)r;   	processorrB   r<   s      r=   rN   BlockRecord.load_dxf_attribs   s-     g&y1..s4MN
r?   c                .  > [         TU ]  U5        UR                  [        :X  a  [	        S5      eUR                  [        [        R                  5        UR                  [        [        R                  5        U R                  R                  U/ SQ5        g )Nz$Exporting BLOCK_RECORDS for DXF R12.)r+   r,   r/   r-   r.   )r5   export_entityr'   r   r   
write_tag2r   r   r+   acdb_blockrecrB   export_dxf_attribs)r;   	tagwriterr<   s     r=   rT   BlockRecord.export_entity   sq    i(5('(NOO_.F.K.KL_m.@.@A##		
r?   c                t   U R                   c   eU R                  c   eU R                  b  U R                  R                  5         U R                   R	                  U5        U R
                  (       d,  U R                  (       d  U R                  R	                  U5        U R                  R	                  U5        g)zExports the BLOCK entity, followed by all content entities and finally the
ENDBLK entity, except for the *Model_Space and *Paper_Space blocks, their
entities are stored in the ENTITIES section.

N)r8   r9   r:   update_block_flags
export_dxfis_modelspaceis_active_paperspacer7   )r;   rX   s     r=   export_block_definition#BlockRecord.export_block_definition   s     zz%%%{{&&&(002

i(""d&?&?((3y)r?   c                  > U R                   c   S5       eU R                   R                  c   S5       e[        TU ]  U5        U R                  R
                  nX R                   R                  ;   d   S5       eU R                  b  UR                  U R                  US9  O[        SU S35      eU R                  b  UR                  U R                  US9  O[        SU S35      eU R                   H  nUR                  X2S9  M     g)	z5Register required resources to the resource registry.Nz0BLOCK_RECORD entity must be assigned to documentzentity database requiredzinvalid BLOCK_RECORD handle)	block_keyzBLOCK entity in BLOCK_RECORD #z is invalidzENDBLK entity in BLOCK_RECORD #)docentitydbr5   register_resourcesrB   rC   r8   
add_entityr   r9   r7   )r;   registrykeyer<   s       r=   re   BlockRecord.register_resources   s   xx#W%WW#xx  ,H.HH,"8,hhoohh'''F)FF'::!

c:'0[A  ;;"s;'1#kB  ""A1 #r?   c                B  > [        U[        5      (       d   e[        TU ]  X5        U R                  c   eUR                  U R                  5        U R                  c   eUR                  U R                  5        U R                   H  nUR                  U5        M     g)z3Translate resources from self to the copied entity.N)
isinstancer!   r5   map_resourcesr8   map_resources_of_copyr9   r7   )r;   clonemappingentityr<   s       r=   rm   BlockRecord.map_resources   s    %----e-zz%%%%%djj1{{&&&%%dkk2''F))&1 (r?   c                   > U R                   (       d  gU R                  R                  5         U R                  R                  5         U R                   H  nUR                  5         M     U ?U ?U ?[        TU ]	  5         g)a	  Destroy associated data:

    - BLOCK
    - ENDBLK
    - all entities stored in this block definition

Does not destroy the linked LAYOUT entity, this is the domain of the
:class:`Layouts` object, which also should initiate the destruction of
'this' BLOCK_RECORD.

N)is_aliver8   destroyr9   r7   r:   r5   )r;   rq   r<   s     r=   ru   BlockRecord.destroy   se     }}

''FNN ( JKr?   c                P    U R                   R                  R                  5       S:H  $ )z*``True`` if is "active" paperspace layout.*paper_spacerB   r+   lowerr;   s    r=   r^    BlockRecord.is_active_paperspace         xx}}""$66r?   c                h    U R                   R                  R                  5       R                  S5      $ )z-``True`` if is any kind of paperspace layout.rx   )rB   r+   rz   
startswithr{   s    r=   is_any_paperspaceBlockRecord.is_any_paperspace   s&     xx}}""$//??r?   c                P    U R                   R                  R                  5       S:H  $ )z%``True`` if is the modelspace layout.z*model_spacery   r{   s    r=   r]   BlockRecord.is_modelspace   r}   r?   c                @    U R                   =(       d    U R                  $ )z;``True`` if is any kind of modelspace or paperspace layout.)r]   r   r{   s    r=   is_any_layoutBlockRecord.is_any_layout   s     !!;T%;%;;r?   c                $    U R                   (       + $ )z^``True`` if not any kind of modelspace or paperspace layout, just a
regular block definition.
)r   r{   s    r=   is_block_layoutBlockRecord.is_block_layout   s    
 %%%%r?   c                v    U R                   b,  [        U R                   R                  R                  S-  5      $ g)zD``True`` if represents an XREF (external reference) or XREF_OVERLAY.   F)r8   boolrB   flagsr{   s    r=   is_xrefBlockRecord.is_xref  s/     ::!

,,r122r?   c           	     8    UR                  U R                  R                  [        U R                  5      S9  U R                  R                  U5        g! [
         a:    [        R                  S[        U5       S[        U R                  5       35         N_f = f)zTAdd an existing DXF entity to BLOCK_RECORD.

Args:
    entity: :class:`DXFGraphic`

)
paperspacezUnexpected DXF entity z in N)	set_ownerrB   rC   intr   AttributeErrorloggerdebugstrr8   r7   addr;   rq   s     r=   rf   BlockRecord.add_entity  s~    	VTXX__T=S=S9TU
 	f%	  	VLL1#f+d3tzz?BSTU	Vs   7A ABBc                    UR                   (       a.  U R                  R                  U5         UR                  S5        gg! [         a     gf = f)zUnlink `entity` from BLOCK_RECORD.

Removes `entity` just from  entity space but not from the drawing
database.

Args:
    entity: :class:`DXFGraphic`

N)rt   r7   remover   r   r   s     r=   unlink_entityBlockRecord.unlink_entity  sK     ??$$V,  &  " s   A 
AAc                F    U R                  U5        UR                  5         g)zmDelete `entity` from BLOCK_RECORD entity space and drawing database.

Args:
    entity: :class:`DXFGraphic`

N)r   ru   r   s     r=   delete_entityBlockRecord.delete_entity,  s     	6"r?   c                ~   > U R                   (       d  g[        TU ]	  U5        U R                  R                  U5        g)zValidity check. (internal API)N)rt   r5   auditr7   )r;   auditorr<   s     r=   r   BlockRecord.audit6  s-    }}g(r?   )r8   r:   r9   r7   )returnNone)r8   r   r9   r   )r7   r   r   r   )r+   r   r   r   rA   )rQ   zOptional[SubclassProcessor]r   r   )rX   r   r   r   )rg   zxref.Registryr   r   )ro   r   rp   zxref.ResourceMapperr   r   )r   r   )rq   r   r   r   )r   r   r   r   )"__name__
__module____qualname____firstlineno____doc__DXFTYPEr	   r   r   rV   
DXFATTRIBSr6   rE   rH   rK   rN   rT   r_   re   rm   ru   propertyr^   r   r]   r   r   r   rf   r   r   r   __static_attributes____classcell__)r<   s   @r=   r!   r!   [   s     Gz+C]SJ
80)# 8<4	 
$*2.24 7 7 @ @ 7 7 < < & &  & ") )r?   )5
__future__r   typingr   r   typing_extensionsr   loggingezdxf.lldxfr   ezdxf.lldxf.attributesr   r	   r
   r   r   ezdxf.lldxf.constr   r   r   r   ezdxf.entities.dxfentityr   r   r   ezdxf.entities.layerr   factoryr   ezdxf.auditr   ezdxf.entitiesr   r   r   r   r4   r   ezdxf.layoutsr   ezdxf.lldxf.tagwriterr   r"   r    __all__	getLoggerr   is_valid_block_nameis_integer_boolis_in_integer_rangerV   rP   r!    r?   r=   <module>r      s%   # * "  !   N M 9 $#88+*)7/			7	#Y%B%BC#s+// 
 // 
 33Ar: 
+ B /}= ( _)) _) _)r?   