Ë
    £èhË  ã                  ó~  — U d Z ddlmZ ddlmZmZmZmZ ddlm	Z	m
Z
 ddlZddlZddlZddlZddlZddlmZmZmZ ddlmZ ddlmZ dd	lmZ dd
lmZmZmZ ddlmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1 ddl2m3Z3m4Z4 ddl5m6Z6m7Z7 g d¢Z8 ejr                  d«      Z:dZ;h d£Z<dZ=dZ>ee!ge?f   Z@deAd<   eeBgef   ZCdeAd<   dRd„ZD G d„ deE«      ZF G d„ deF«      ZG G d„ deF«      ZH G d„ deF«      ZI G d„ d eF«      ZJ G d!„ d"ej–                  «      ZLdSd#„ZMdTdUd%„ZNdVd&„ZOd'd(d)d$d*œ	 	 	 	 	 	 	 	 	 	 	 	 	 dWd+„ZPdXd,„ZQd eR«       eLj¦                  d-œ	 	 	 	 	 	 	 dYd.„ZTd$d/œ	 	 	 	 	 dZd0„ZUd$d/œ	 	 	 	 	 d[d1„ZVd'd2œd\d3„ZWdeLj°                  f	 	 	 	 	 	 	 d]d4„ZYdeLj°                  f	 	 	 	 	 	 	 d^d5„ZZ G d6„ d7e	«      Z[ G d8„ d9e	«      Z\ G d:„ d;«      Z] G d<„ d=e]«      Z^d_d>„Z_ G d?„ d@e]«      Z` G dA„ dBe]«      Za G dC„ dDe]«      Zb G dE„ dF«      Zcd`dG„Zd G dH„ dI«      Ze G dJ„ dK«      ZfdadL„ZgdbdM„ZhdcdN„ZidddO„Zj G dP„ dQ«      Zky)ezN Resource management module for transferring DXF resources between documents.
é    )Úannotations)ÚOptionalÚSequenceÚCallableÚIterable)ÚProtocolÚ	TypeAliasN)ÚconstÚ	validatorÚtypes)ÚTags)ÚDXFInfo)ÚDrawing)Ú
BaseLayoutÚ
PaperspaceÚBlockLayout)Úis_graphic_entityÚis_dxf_objectÚ	DXFEntityÚDXFClassÚfactoryÚBlockRecordÚLayerÚLinetypeÚ	TextstyleÚDimStyleÚUCSTableEntryÚMaterialÚ
MLineStyleÚMLeaderStyleÚBlockÚEndBlkÚInsertÚ	DXFLayoutÚVisualStyle)ÚCopyStrategyÚCopySettings)ÚUVecÚVec3)ÚdefineÚattachÚembedÚdetachÚwrite_blockÚload_modelspaceÚload_paperspaceÚRegistryÚResourceMapperÚConflictPolicyÚLoaderÚdxf_infor   Ú	XrefErrorÚXrefDefinitionErrorÚEntityErrorÚLayoutErrorÚezdxfÚ0>   ÚBYBLOCKÚBYLAYERÚ
CONTINUOUSÚSTANDARDr	   ÚFilterFunctionÚLoadFunctionc                ó<   — | D ]  }t         j                  |«       Œ y ©N)ÚloggerÚdebug)ÚmessagesÚmsgs     ú*lib/python3.12/site-packages/ezdxf/xref.pyÚ_log_debug_messagesrI   J   s   € ÛˆÜ�‰�SÕñ ó    c                  ó   — e Zd ZdZy)r6   z"base exception for the xref moduleN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© rJ   rH   r6   r6   O   s   „ Ù,àrJ   r6   c                  ó   — e Zd Zy)r7   N©rL   rM   rN   rP   rJ   rH   r7   r7   U   ó   „ ØrJ   r7   c                  ó   — e Zd Zy)r8   NrR   rP   rJ   rH   r8   r8   Y   rS   rJ   r8   c                  ó   — e Zd Zy)r9   NrR   rP   rJ   rH   r9   r9   ]   rS   rJ   r9   c                  ó   — e Zd Zy)ÚInternalErrorNrR   rP   rJ   rH   rW   rW   a   rS   rJ   rW   c                  óv   — e Zd ZdZ ej
                  «       Z ej
                  «       Z ej
                  «       Zy)r3   aO  These conflict policies define how to handle resource name conflicts.

    .. versionadded:: 1.1

    Attributes:
        KEEP: Keeps the existing resource name of the target document and ignore the
            resource from the source document.
        XREF_PREFIX: This policy handles the resource import like CAD applications by
            **always** renaming the loaded resources to `<xref>$0$<name>`, where `xref`
            is the name of source document, the `$0$` part is a number to create a
            unique resource name and `<name>` is the name of the resource itself.
        NUM_PREFIX: This policy renames the loaded resources to `$0$<name>` only if the
            resource `<name>` already exists. The `$0$` prefix is a number to create a
            unique resource name and `<name>` is the name of the resource itself.

    N)	rL   rM   rN   rO   ÚenumÚautoÚKEEPÚXREF_PREFIXÚ
NUM_PREFIXrP   rJ   rH   r3   r3   e   s0   „ ñð" ˆ4�9‰9‹;€DØ�$—)‘)“+€KØ�—‘“�JrJ   r3   c                ó‚  — t        | «      } t        j                  | «      r;t        | d«      5 }|j	                  d«      }ddd«       t        j
                  «      S t        j                  | «      r-t        | dd¬«      5 }t        j                  |«      cddd«       S t        d«      ‚# 1 sw Y   ŒkxY w# 1 sw Y   yxY w)a  Scans the HEADER section of a DXF document and returns a :class:`DXFInfo`
    object, which contains information about the DXF version, text encoding, drawing
    units and insertion base point.

    Raises:
        IOError: not a DXF file or a generic IO error

    Úrbi    NÚrtÚignore)ÚerrorszNot a DXF files.)	Ústrr   Úis_binary_dxf_fileÚopenÚreadÚbinary_dxf_infoÚis_dxf_filer5   ÚIOError)ÚfilenameÚfpÚdatas      rH   r5   r5   |   sž   € ô �8‹}€HÜ×#Ñ# HÔ-Ü�(˜DÔ! Rà—7‘7˜4“=ˆD÷ "ô ×(Ñ(¨Ó.Ð.Ü×Ñ˜XÔ&ä�(˜D¨Õ2°bÜ×%Ñ% bÓ)÷ 3Ñ2ô Ð(Ó)Ð)÷ "Ð!ú÷ 3Ð2ús   ­B)Á?B5Â)B2Â5B>Fc                ó�   — || j                   v rt        d|› d�«      ‚| j                   j                  |t        |«      |dœ¬«       y)a±  Add an external reference (xref) definition to a document.

    XREF attachment types:

    - attached: the XREF that's inserted into this drawing is also present in a
      document to which this document is inserted as an XREF.
    - overlay: the XREF that's inserted into this document is **not** present in a
      document to which this document is inserted as an XREF.

    Args:
        doc: host document
        block_name: name of the xref block
        filename: external reference filename
        overlay: creates an XREF overlay if ``True`` and an XREF attachment otherwise

    Raises:
        XrefDefinitionError: block with same name exist

    .. versionadded:: 1.1

    zblock 'z' already exist)ÚflagsÚ	xref_path)ÚnameÚ
dxfattribsN)Úblocksr7   ÚnewÚmake_xref_flags)ÚdocÚ
block_namerj   Úoverlays       rH   r*   r*   Ñ   sL   € ð, �S—Z‘ZÑÜ! G¨J¨<°Ð"GÓHÐHØ‡J�J‡N�NØä$ WÓ-Ø!ñ
ð õ rJ   c                óŠ   — | r!t         j                  t         j                  z  S t         j                  t         j                  z  S rC   )r
   ÚBLK_XREF_OVERLAYÚBLK_EXTERNALÚBLK_XREF©rw   s    rH   rt   rt   ò   s1   € ÙÜ×%Ñ%¬×(:Ñ(:Ñ:Ð:ä�~‰~¤× 2Ñ 2Ñ2Ð2rJ   )r   r   r   ç      ð?g        )ÚinsertÚscaleÚrotationrw   c               óð   — t        | |||¬«       t        «       }|rt        |«      |d<   |dk7  rt        |«      }||d<   ||d<   ||d<   t        |«      }| j	                  «       }	|	j                  |||¬«      S )aª  Attach the file `filename` to the host document as external reference (XREF) and
    creates a default block reference for the XREF in the modelspace of the document.
    The function raises an :class:`XrefDefinitionError` exception if the block definition
    already exist, but an XREF can be inserted multiple times by adding additional block
    references::

        msp.add_blockref(block_name, insert=another_location)

    .. important::

        If the XREF has different drawing units than the host document, the scale
        factor between these units must be applied as a uniform scale factor to the
        block reference!  Unfortunately the XREF drawing units can only be detected by
        scanning the HEADER section of a document by the function :func:`dxf_info` and
        is therefore not done automatically by this function.
        Advice: always use the same units for all drawings of a project!

    Args:
        doc: host DXF document
        block_name: name of the XREF definition block
        filename: file name of the XREF
        insert: location of the default block reference
        scale: uniform scaling factor
        rotation: rotation angle in degrees
        overlay: creates an XREF overlay if ``True`` and an XREF attachment otherwise

    Returns:
        Insert: default block reference for the XREF

    Raises:
        XrefDefinitionError: block with same name exist

    .. versionadded:: 1.1

    r|   r€   r}   ÚxscaleÚyscaleÚzscale)r~   rq   )r*   ÚdictÚfloatr)   Ú
modelspaceÚadd_blockref)
ru   rv   rj   r~   r   r€   rw   rq   ÚlocationÚmsps
             rH   r+   r+   ù   s†   € ôZ ˆ3�
˜H¨gÕ6Ü“€JÙÜ!& x£ˆ
�:ÑØ�‚|Ü�e“ˆØ$ˆ
�8ÑØ$ˆ
�8ÑØ$ˆ
�8ÑÜ�F‹|€HØ
�.‰.Ó
€CØ×Ñ˜J¨xÀJÐÓOÐOrJ   c                ó\  — t        j                  | «      }|j                  «       r|S |j                  }|D ]`  }|j	                  «       s|j
                  }|j                  «       }|| z  }|j                  «       r|c S ||z  }|j                  «       sŒ^|c S  t        j                  | «      S )zØReturns the path of the XREF file.

    Args:
        xref_filename: filename of the XREF, absolute or relative path
        search_paths: search paths where to look for the XREF file

    .. versionadded:: 1.1

    )ÚpathlibÚPathÚexistsrp   Úis_dirÚparentÚresolve)Úxref_filenameÚsearch_pathsÚfilepathrp   ÚpathÚsearch_paths         rH   Ú	find_xrefr—   4  s”   € ô �|‰|˜MÓ*€Hà‡�ÔØˆà�=‰=€DÛˆØ�{‰{Œ}Ø—;‘;ˆDØ—l‘l“nˆà Ñ.ˆØ�?‰?ÔØŠOà Ñ%ˆØ�?‰?ÕØŠOð ô �<‰<˜Ó&Ð&rJ   )Úload_fnr“   Úconflict_policyc               óô  — t        | t        «      sJ d«       ‚| j                  }|€J d«       ‚| j                  }t        |t        «      sJ ‚|j
                  st        d«      ‚|j                  j                  dd«      }|st        d«      ‚|D �cg c]  }t        j                  |«      ‘Œ }}|j                  d|j                  «       «       t        ||«      }	|	j                  «       st        d	|	› d
�«      ‚|r |t!        |	«      «      }
nt#        j$                  |	«      }
|
j&                  |j&                  kD  rt)        j*                  d«      ‚t-        |
||¬«      }|j/                  | «       |j1                  | j2                  ¬«       |j5                  t(        j6                  t(        j8                  z  d¬«       |
j:                  j                  d«      }|rt=        |«      |j                  _        yyc c}w )a  Loads the modelspace of the XREF as content into a block layout.

    The loader function loads the XREF as `Drawing` object, by default the
    function :func:`ezdxf.readfile` is used to load DXF files. To load DWG files use the
    :func:`~ezdxf.addons.odafc.readfile` function from the :mod:`ezdxf.addons.odafc`
    add-on. The :func:`ezdxf.recover.readfile` function is very robust for reading DXF
    files with errors.

    If the XREF path isn't absolute the XREF is searched in the folder of the host DXF
    document and in the `search_path` folders.

    Args:
        xref: :class:`BlockLayout` of the XREF document
        load_fn: function to load the content of the XREF as `Drawing` object
        search_paths: list of folders to search for XREFS, default is the folder of the
            host document or the current directory if no filepath is set
        conflict_policy: how to resolve name conflicts

    Raises:
        XrefDefinitionError: argument `xref` is not a XREF definition
        FileNotFoundError: XREF file not found
        DXFVersionError: cannot load a XREF with a newer DXF version than the host
            document, try the :mod:`~ezdxf.addons.odafc` add-on to downgrade the XREF
            document or upgrade the host document

    .. versionadded:: 1.1

    z!expected BLOCK definition of XREFNúvalid DXF document requiredz(argument 'xref' is not a XREF definitionro   Ú zno xref path definedr   zfile not found: 'Ú'zCcannot embed a XREF with a newer DXF version into the host document©r™   )Úxref_prefixF)Ústateú$INSBASE) Ú
isinstancer   ru   Úblockr!   Úis_xrefr7   ÚdxfÚgetrŒ   r�   r~   Úget_abs_filepathr—   rŽ   ÚFileNotFoundErrorrc   r:   ÚreadfileÚ
dxfversionr
   ÚDXFVersionErrorr4   r/   Úexecuterp   Úset_flag_stater{   rz   Úheaderr)   Ú
base_point)Úxrefr˜   r“   r™   Ú
target_docr£   ro   ÚpÚ_search_pathsr”   Ú
source_docÚloaderÚorigins                rH   r,   r,   T  s³  € ôF �dœKÔ(ÐMÐ*MÓMÐ(Ø—‘€JØÐ!Ð@Ð#@Ó@Ð!Ø�J‰J€EÜ�eœUÔ#Ð#Ð#Ø�=Š=Ü!Ð"LÓMÐMà—Y‘Y—]‘] ;°Ó3€IÙÜ!Ð"8Ó9Ð9á.:Ó;©l¨”W—\‘\ !•_¨l€MÐ;Ø×Ñ˜˜J×7Ñ7Ó9Ô:ä˜ MÓ2€HØ�?‰?ÔÜÐ"3°H°:¸QÐ ?Ó@Ð@áÙœS ›]Ó+‰
ä—^‘^ HÓ-ˆ
Ø×Ñ˜z×4Ñ4Ò4Ü×#Ñ#ØQó
ð 	
ô �J 
¸OÔL€FØ
×Ñ˜4Ô Ø
‡N�N˜tŸy™y€NÔ)à	×ÑœŸ™¬%×*<Ñ*<Ñ<ÀEÐÔJà×Ñ×"Ñ" :Ó.€FÙÜ# F›|ˆ�	‰	Õð ùò- <s   ÂG5r|   c               ól  — | j                   }|€J d«       ‚t        j                  |j                  | j                  ¬«      }t        ||t        j                  ¬«      }|j                  | |j                  «       «       |j                  «        | j                  |j                  d<   t        | ||¬«       |S )aß  Write the content of `block` into the modelspace of a new DXF document and
    convert `block` to an external reference (XREF).  The new DXF document has to be
    written by the caller: :code:`xref_doc.saveas(xref_filename)`.
    This way it is possible to convert the DXF document to DWG by the
    :mod:`~ezdxf.addons.odafc` add-on if necessary::

        xref_doc = xref.detach(my_block, "my_block.dwg")
        odafc.export_dwg(xref_doc, "my_block.dwg")

    It's recommended to clean up the entity database of the host document afterwards::

        doc.entitydb.purge()

    The function does not create any block references. These references should already
    exist and do not need to be changed since references to blocks and XREFs are the
    same.

    Args:
        block: block definition to detach
        xref_filename: name of the external referenced file
        overlay: creates an XREF overlay if ``True`` and an XREF attachment otherwise

    .. versionadded:: 1.1

    r›   ©rª   Úunitsrž   r¡   r|   )ru   r:   rs   rª   r¹   r4   r3   r[   Úload_block_layout_intor‡   r¬   r¯   r®   Úblock_to_xref)r£   r’   rw   r´   r±   rµ   s         rH   r-   r-   �  s˜   € ð8 —‘€JØÐ!Ð@Ð#@Ó@Ð!Ü—‘ j×&;Ñ&;À5Ç;Á;ÔO€JÜ�J 
¼N×<OÑ<OÔP€FØ
×!Ñ! %¨×)>Ñ)>Ó)@ÔAØ
‡N�NÔØ$)×$4Ñ$4€J×Ñ�jÑ!Ü�%˜°Õ8ØÐrJ   c               ó¶   — | j                  «        | j                  }|€J d«       ‚t        |«      |j                  _        t        |«      |j                  _        y)zOConvert a block definition into an external reference.

    (internal API)
    Nzinvalid BlockLayout)Údelete_all_entitiesr£   rc   r¥   ro   rt   rn   )r£   r’   rw   Úblock_entitys       rH   r»   r»   Ä  sQ   € ð 
×ÑÔØ—;‘;€LØÐ#Ð:Ð%:Ó:Ð#Ü!$ ]Ó!3€L×ÑÔÜ,¨WÓ5€L×ÑÕrJ   )r¶   c               óÄ  — t        | «      dk(  rt        j                  «       S t        d„ | D «       «      rt	        d«      ‚| d   j
                  }|€J d«       ‚t        j                  |j                  |j                  ¬«      }t        ||«      }|j                  t        | |j                  «       «      «       |j                  «        t        |«      |j                  d<   |S )a“  Write `entities` into the modelspace of a new DXF document.

    This function is called "write_block" because the new DXF document can be used as
    an external referenced block.  This function is similar to the WBLOCK command in CAD
    applications.

    Virtual entities are not supported, because each entity needs a real database- and
    owner handle.

    Args:
        entities: DXF entities to write
        origin: block origin, defines the point in the modelspace which will be inserted
            at the insert location of the block reference

    Raises:
        EntityError: virtual entities are not supported

    .. versionadded:: 1.1

    r   c              3  óL   K  — | ]  }|j                   j                  d u –— Œ y ­wrC   )r¥   Úowner)Ú.0Úes     rH   Ú	<genexpr>zwrite_block.<locals>.<genexpr>é  s   è ø€ Ð
1© 1ˆ1�5‰5�;‰;˜$Ô©ùs   ‚"$z"virtual entities are not supportedz expected a valid source documentr¸   r¡   )Úlenr:   rs   Úanyr8   ru   rª   r¹   r4   Úadd_commandÚLoadEntitiesr‡   r¬   r)   r®   )Úentitiesr¶   r´   r±   rµ   s        rH   r.   r.   Ò  s¿   € ô* ˆ8ƒ}˜ÒÜ�y‰y‹{ÐÜ
Ñ
1©Ó
1Ô1ÜÐ>Ó?Ð?Ø˜!‘—‘€JØÐ!ÐEÐ#EÓEÐ!Ü—‘ j×&;Ñ&;À:×CSÑCSÔT€JÜ�J 
Ó+€FØ
×Ñ”| H¨j×.CÑ.CÓ.EÓFÔGØ
‡N�NÔÜ$(¨£L€J×Ñ�jÑ!ØÐrJ   c                ód   — t        | ||¬«      }|j                  |¬«       |j                  «        y)aÜ  Loads the modelspace content of the source document into the modelspace
    of the target document.  The filter function `filter_fn` gets every source entity as
    input and returns ``True`` to load the entity or ``False`` otherwise.

    Args:
        sdoc: source document
        tdoc: target document
        filter_fn: optional function to filter entities from the source modelspace
        conflict_policy: how to resolve name conflicts

    .. versionadded:: 1.1

    rž   ©Ú	filter_fnN)r4   r/   r¬   )ÚsdocÚtdocrÌ   r™   rµ   s        rH   r/   r/   õ  s-   € ô& �D˜$°Ô@€FØ
×Ñ YÐÔ/Ø
‡N�NÕrJ   c                ó¬   — | j                   |u rt        d«      ‚t        | j                   ||¬«      }|j                  | |¬«       |j	                  «        y)aÈ  Loads the paperspace layout `psp` into the target document.  The filter function
    `filter_fn` gets every source entity as input and returns ``True`` to load the
    entity or ``False`` otherwise.

    Args:
        psp: paperspace layout to load
        tdoc: target document
        filter_fn: optional function to filter entities from the source paperspace layout
        conflict_policy: how to resolve name conflicts

    .. versionadded:: 1.1

    z8Source paperspace layout cannot be from target document.rž   rË   N)ru   r9   r4   Úload_paperspace_layoutr¬   )ÚpsprÎ   rÌ   r™   rµ   s        rH   r0   r0     sJ   € ð& ‡w�w�$�ÜÐTÓUÐUÜ�C—G‘G˜T°?ÔC€FØ
×!Ñ! #°Ð!Ô;Ø
‡N�NÕrJ   c                  óX   — e Zd Zefdd„Zdd„Zdd„Zdd„Zdd„Zdd„Z	dd„Z
dd„Zdd	„Zy
)r1   c                 ó   — y rC   rP   )ÚselfÚentityÚ	block_keys      rH   Ú
add_entityzRegistry.add_entity(  ó   € ØrJ   c                 ó   — y rC   rP   )rÔ   Úblock_records     rH   Ú	add_blockzRegistry.add_block+  rØ   rJ   c                 ó   — y rC   rP   ©rÔ   Úhandles     rH   Ú
add_handlezRegistry.add_handle.  rØ   rJ   c                 ó   — y rC   rP   ©rÔ   rp   s     rH   Ú	add_layerzRegistry.add_layer1  rØ   rJ   c                 ó   — y rC   rP   rá   s     rH   Úadd_linetypezRegistry.add_linetype4  rØ   rJ   c                 ó   — y rC   rP   rá   s     rH   Úadd_text_stylezRegistry.add_text_style7  rØ   rJ   c                 ó   — y rC   rP   rá   s     rH   Úadd_dim_stylezRegistry.add_dim_style:  rØ   rJ   c                 ó   — y rC   rP   rá   s     rH   Úadd_block_namezRegistry.add_block_name=  rØ   rJ   c                 ó   — y rC   rP   rá   s     rH   Ú	add_appidzRegistry.add_appid@  rØ   rJ   N©rÕ   r   rÖ   rc   ÚreturnÚNone©rÚ   r   rî   rï   ©rÞ   zOptional[str]rî   rï   ©rp   rc   rî   rï   )rL   rM   rN   ÚNO_BLOCKr×   rÛ   rß   râ   rä   ræ   rè   rê   rì   rP   rJ   rH   r1   r1   '  s2   „ Ø=Eô óóóóóóóôrJ   r1   c                  óŒ   — e Zd Zddd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Z	dd„Z
ddd	„Z	 	 	 	 	 	 	 	 dd
„Zddœ	 	 	 	 	 	 	 dd„Zy)r2   c                 ó   — y rC   rP   ©rÔ   rÞ   Údefaults      rH   Ú
get_handlezResourceMapper.get_handleE  rØ   rJ   c                 ó   — y rC   rP   rÝ   s     rH   Úget_reference_of_copyz$ResourceMapper.get_reference_of_copyH  rØ   rJ   c                 ó   — y rC   rP   rá   s     rH   Ú	get_layerzResourceMapper.get_layerK  rØ   rJ   c                 ó   — y rC   rP   rá   s     rH   Úget_linetypezResourceMapper.get_linetypeN  rØ   rJ   c                 ó   — y rC   rP   rá   s     rH   Úget_text_stylezResourceMapper.get_text_styleQ  rØ   rJ   c                 ó   — y rC   rP   rá   s     rH   Úget_dim_stylezResourceMapper.get_dim_styleT  rØ   rJ   c                 ó   — y rC   rP   rá   s     rH   Úget_block_namezResourceMapper.get_block_nameW  rØ   rJ   c                 ó   — y rC   rP   ©rÔ   rÕ   s     rH   Úmap_resources_of_copyz$ResourceMapper.map_resources_of_copyZ  rØ   rJ   c                 ó   — y rC   rP   )rÔ   ÚtagsÚnew_owner_handles      rH   Úmap_pointerszResourceMapper.map_pointers]  rØ   rJ   c                 ó   — y rC   rP   )rÔ   Ú	dict_nameÚ
entry_namerÕ   s       rH   Úmap_acad_dict_entryz"ResourceMapper.map_acad_dict_entry`  ó   € ð 	rJ   F©Úoptionalc                ó   — y rC   rP   )rÔ   ÚsourceÚcloneÚattrib_namer  s        rH   Úmap_existing_handlez"ResourceMapper.map_existing_handlee  r  rJ   N©r;   ©rÞ   rc   rî   rc   ©rÞ   rc   rî   úOptional[DXFEntity]©rp   rc   rî   rc   ©rÕ   r   rî   rï   ©rœ   ©r	  r   r
  rc   rî   rï   ©r  rc   r  rc   rÕ   r   rî   ztuple[str, DXFEntity]©r  r   r  r   r  rc   rî   rï   )rL   rM   rN   rø   rú   rü   rþ   r   r  r  r  r  r  r  rP   rJ   rH   r2   r2   D  s€   „ ôóóóóóóóôðØðØ*-ðØ7@ðà	óð RWñØðØ(1ðØ@Cðà	ôrJ   r2   c                  ó   — e Zd Zdd„Zdd„Zy)ÚLoadingCommandc                 ó   — y rC   rP   )rÔ   Úregistrys     rH   Úregister_resourcesz!LoadingCommand.register_resourcesl  ó   € ØrJ   c                 ó   — y rC   rP   )rÔ   Útransfers     rH   r¬   zLoadingCommand.executeo  r'  rJ   N©r%  r1   rî   rï   ©r)  Ú	_Transferrî   rï   )rL   rM   rN   r&  r¬   rP   rJ   rH   r#  r#  k  s   „ óôrJ   r#  c                  ó4   — e Zd ZdZ	 	 	 	 	 	 dd„Zdd„Zdd„Zy)	rÈ   z0Loads all given entities into the target layout.c                ón   — || _         t        |t        «      st        dt	        |«      › �«      ‚|| _        y )Núinvalid target layout type: )rÉ   r¢   r   r9   ÚtypeÚtarget_layout)rÔ   rÉ   r1  s      rH   Ú__init__zLoadEntities.__init__v  s6   € ð !ˆŒÜ˜-¬Ô4ÜÐ <¼TÀ-Ó=PÐ<QÐRÓSÐSØ*ˆÕrJ   c                ót   — | j                   D ])  }|j                  ||j                  j                  ¬«       Œ+ y ©N)rÖ   )rÉ   r×   r¥   rÁ   ©rÔ   r%  rÃ   s      rH   r&  zLoadEntities.register_resources~  s+   € Ø—”ˆAØ×Ñ ¨Q¯U©U¯[©[ÐÕ9ñ rJ   c                óN  — | j                   }| j                  D ]n  }|j                  |«      }|€|j                  dt	        |«      › �«       Œ4t        |«      r|j                  |«       ŒQ|j                  dt	        |«      › d�«       Œp t        |t        «      rt        |«       y y )Nzxref:cannot copy úfound non-graphic entity ú as layout content)
r1  rÉ   Úget_entity_copyrE   rc   r   r×   r¢   r   Ú _reorganize_paperspace_viewports)rÔ   r)  r1  rÕ   r  s        rH   r¬   zLoadEntities.execute‚  s—   € Ø×*Ñ*ˆØ—m”mˆFØ×,Ñ,¨VÓ4ˆEØˆ}Ø—‘Ð!2´3°v³;°-Ð@ÔAØÜ  Ô'Ø×(Ñ(¨Õ/à—‘Ø/´°E³
¨|Ð;MÐNõð $ô �m¤ZÔ0Ü,¨]Õ;ð 1rJ   N)rÉ   úSequence[DXFEntity]r1  r   rî   rï   r*  r+  )rL   rM   rN   rO   r2  r&  r¬   rP   rJ   rH   rÈ   rÈ   s  s,   „ Ù:ð+Ø+ð+Ø<Fð+à	ó+ó:ô<rJ   rÈ   c                ó  — | j                  «       }|€| j                  «       }| j                  «       D ]2  }|j                  j                  dk(  sŒ||usŒ"| j                  |«       Œ4 | j                  |j                  j                  «       y )Né   )Úmain_viewportÚadd_new_main_viewportÚ	viewportsr¥   ÚidÚdelete_entityÚset_current_viewport_handlerÞ   )Ú
paperspaceÚmain_vpÚvps      rH   r:  r:  “  st   € Ø×&Ñ&Ó(€GØ€Ø×2Ñ2Ó4ˆà×"Ñ"Ö$ˆØ�6‰6�9‰9˜‹>˜b¨Ò/Ø×$Ñ$ RÕ(ð %ð ×*Ñ*¨7¯;©;×+=Ñ+=Õ>rJ   c                  ó0   — e Zd ZdZdd„Zdd„Zd	d„Zd
d„Zy)ÚLoadPaperspaceLayoutzéLoads a paperspace layout as a new paperspace layout into the target document.
    If a paperspace layout with same name already exists the layout will be renamed
    to  "<layout name> (x)" where x is 2 or the next free number.
    c                ón   — t        |t        «      st        dt        |«      › �«      ‚|| _        || _        y )Nú invalid paperspace layout type: )r¢   r   r9   r0  Úpaperspace_layoutrÌ   ©rÔ   rÑ   rÌ   s      rH   r2  zLoadPaperspaceLayout.__init__¤  s2   € Ü˜#œzÔ*ÜÐ @ÄÀcÃÀÐLÓMÐMØ!$ˆÔØ"ˆ�rJ   c                ó˜   — | j                   }|r#| j                  D �cg c]  } ||«      sŒ|‘Œ c}S t        | j                  «      S c c}w rC   )rÌ   rK  Úlist)rÔ   rÌ   rÃ   s      rH   Úsource_entitiesz$LoadPaperspaceLayout.source_entitiesª  sH   € Ø—N‘Nˆ	ÙØ#×5Ò5ÓFÑ5˜!¹À1½’AÐ5ÑFÐFä˜×.Ñ.Ó/Ð/ùò Gs
   �A«Ac                óÊ   — |j                  | j                  j                  «       | j                  j                  }| j	                  «       D ]  }|j                  ||¬«       Œ y r4  )r×   rK  Ú
dxf_layoutÚ
layout_keyrO  )rÔ   r%  rÖ   rÃ   s       rH   r&  z'LoadPaperspaceLayout.register_resources±  sS   € Ø×Ñ˜D×2Ñ2×=Ñ=Ô>Ø×*Ñ*×5Ñ5ˆ	Ø×%Ñ%Ö'ˆAØ×Ñ ¨YÐÕ7ñ (rJ   c                óì  — | j                   j                  }|j                  |j                  j                  «      }t        |t        «      sJ ‚|j                  j                  j                  |j                  j                  «      }| j                  «       D ]P  }|j                  |«      }|rt        |«      r|j                  |«       Œ3|j                  dt!        |«      › d�«       ŒR t#        |«       y )Nr7  r8  )rK  rQ  rú   r¥   rÞ   r¢   r$   r%  r±   rD  rp   rO  r9  r   r×   rE   rc   r:  )rÔ   r)  Úsource_dxf_layoutÚtarget_dxf_layoutr1  rÕ   r  s          rH   r¬   zLoadPaperspaceLayout.execute·  sÓ   € Ø ×2Ñ2×=Ñ=ÐØ$×:Ñ:Ð;L×;PÑ;P×;WÑ;WÓXÐÜÐ+¬YÔ7Ð7Ð7Ø ×)Ñ)×4Ñ4×?Ñ?Ø×!Ñ!×&Ñ&ó
ˆð ×*Ñ*Ö,ˆFØ×,Ñ,¨VÓ4ˆEÙÔ*¨5Ô1Ø×(Ñ(¨Õ/à—‘Ø/´°E³
¨|Ð;MÐNõð -ô 	)¨Õ7rJ   N©rÑ   r   rÌ   úOptional[FilterFunction]rî   rï   )rî   úlist[DXFEntity]r*  r+  )rL   rM   rN   rO   r2  rO  r&  r¬   rP   rJ   rH   rH  rH  ž  s   „ ñó
#ó0ó8ô8rJ   rH  c                  ó    — e Zd ZdZdd„Zdd„Zy)ÚLoadBlockLayoutzžLoads a block layout as a new block layout into the target document. If a block
    layout with the same name exists the conflict policy will be applied.
    c                ó`   — t        |t        «      st        dt        |«      › �«      ‚|| _        y )Núinvalid block layout type: )r¢   r   r9   r0  Úblock_layout)rÔ   r£   s     rH   r2  zLoadBlockLayout.__init__Î  s+   € Ü˜%¤Ô-ÜÐ ;¼DÀ»K¸=ÐIÓJÐJØ!ˆÕrJ   c                ót   — | j                   j                  }t        |t        «      r|j	                  |«       y y rC   )r]  rÚ   r¢   r   r×   )rÔ   r%  rÚ   s      rH   r&  z"LoadBlockLayout.register_resourcesÓ  s0   € Ø×(Ñ(×5Ñ5ˆÜ�l¤KÔ0Ø×Ñ Õ-ð 1rJ   N)r£   r   rî   rï   r*  ©rL   rM   rN   rO   r2  r&  rP   rJ   rH   rZ  rZ  É  s   „ ñó"ô
.rJ   rZ  c                  ó    — e Zd ZdZdd„Zdd„Zy)ÚLoadResourcesz†Loads table entries into the target document. If a table entry with the same name
    exists the conflict policy will be applied.
    c                ó   — || _         y rC   )rÉ   )rÔ   rÉ   s     rH   r2  zLoadResources.__init__Þ  s	   € Ø ˆ�rJ   c                óT   — | j                   D ]  }|j                  |t        ¬«       Œ y r4  )rÉ   r×   ró   r5  s      rH   r&  z LoadResources.register_resourcesá  s#   € Ø—”ˆAØ×Ñ ¬XÐÕ6ñ rJ   N)rÉ   r;  rî   rï   r*  r_  rP   rJ   rH   ra  ra  Ù  s   „ ñó!ô7rJ   ra  c                  óð   — e Zd ZdZej
                  f	 	 	 	 	 dd„Zdd„Z	 	 d	 	 	 	 	 dd„Z	 d	 	 	 	 	 dd„Z		 d	 	 	 	 	 	 	 dd„Z
	 	 	 	 dd„Z	 	 	 	 	 	 dd	„Zdd
„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zddd„Zy)r4   zçLoad entities and resources from the source DXF document `sdoc` into the
    target DXF document.

    Args:
        sdoc: source DXF document
        tdoc: target DXF document
        conflict_policy: :class:`ConflictPolicy`

    c                ó
  — t        |t        «      sJ d«       ‚t        |t        «      sJ d«       ‚||usJ d«       ‚|j                  |j                  k  rt        j	                  d«       || _        || _        || _        g | _        y )Nz$a valid source document is mandatoryz$a valid target document is mandatoryz-source and target document cannot be the samez>target document has older DXF version than the source document)	r¢   r   rª   rD   ÚwarningrÍ   rÎ   r™   Ú	_commands)rÔ   rÍ   rÎ   r™   s       rH   r2  zLoader.__init__ñ  s‚   € ô ˜$¤Ô(ÐPÐ*PÓPÐ(Ü˜$¤Ô(ÐPÐ*PÓPÐ(Ø˜4ÑÐPÐ!PÓPÐØ�?‰?˜TŸ_™_Ò,Ü�N‰NØPôð "ˆŒ	Ø!ˆŒ	Ø.ˆÔØ/1ˆ�rJ   c                ó:   — | j                   j                  |«       y rC   )rg  Úappend)rÔ   Úcommands     rH   rÇ   zLoader.add_command   s   € Ø�‰×Ñ˜gÕ&rJ   Nc                ó¾  — |€| j                   j                  «       }n't        |t        «      st	        dt        |«      › �«      ‚|j                  | j                   urt	        d«      ‚|€$t        | j                  j                  «       «      }n0| j                  j                  «       D �cg c]  } ||«      sŒ|‘Œ }}| j                  t        ||«      «       yc c}w )a  Loads the content of the modelspace of the source document into a layout of
        the target document, the modelspace of the target document is the default target
        layout. The filter function `filter_fn` is used to skip source entities, the
        function should return ``False`` for entities to ignore and ``True`` otherwise.

        Args:
            target_layout: target layout can be any layout: modelspace, paperspace
                layout or block layout.
            filter_fn: function to filter source entities

        Nr/  ú:given target layout does not belong to the target document)rÎ   r‡   r¢   r   r9   r0  ru   rN  rÍ   rÇ   rÈ   )rÔ   r1  rÌ   rÉ   rÃ   s        rH   r/   zLoader.load_modelspace  sÄ   € ð  Ð Ø ŸI™I×0Ñ0Ó2‰MÜ˜M¬:Ô6ÜÐ <¼TÀ-Ó=PÐ<QÐRÓSÐSØ×Ñ D§I¡IÑ-ÜØLóð ð ÐÜ˜DŸI™I×0Ñ0Ó2Ó3‰Hà#'§9¡9×#7Ñ#7Ô#9ÓJÑ#9˜a¹YÀq½\šÐ#9ˆHÐJØ×Ñœ h°Ó>Õ?ùò Ks   Â*CÂ8Cc                óâ   — t        |t        «      s!t        j                  dt	        |«      › �«      ‚|j
                  | j                  urt        d«      ‚| j                  t        ||«      «       y)a‡  Loads a paperspace layout as a new paperspace layout into the target document.
        If a paperspace layout with same name already exists the layout will be renamed
        to  "<layout name> (2)" or "<layout name> (3)" and so on.  The filter function
        `filter_fn` is used to skip source entities, the function should return ``False``
        for entities to ignore and ``True`` otherwise.

        The content of the modelspace which may be displayed through a VIEWPORT entity
        will **not** be loaded!

        Args:
            psp: the source paperspace layout
            filter_fn: function to filter source entities

        rJ  ú>given paperspace layout does not belong to the source documentN)
r¢   r   r
   ÚDXFTypeErrorr0  ru   rÍ   r9   rÇ   rH  rL  s      rH   rÐ   zLoader.load_paperspace_layout!  sc   € ô& ˜#œzÔ*Ü×$Ñ$Ð'GÌÈSË	À{Ð%SÓTÐTØ�7‰7˜$Ÿ)™)Ñ#ÜØPóð ð 	×ÑÔ-¨c°9Ó=Õ>rJ   c                ó¸  — t        |t        «      st        dt        |«      › �«      ‚t        |t        «      st        dt        |«      › �«      ‚|j
                  | j                  urt        d«      ‚|j
                  | j                  urt        d«      ‚|€t        |«      }n|D �cg c]  } ||«      sŒ|‘Œ }}| j                  t        ||«      «       yc c}w )ar  Loads the content of a paperspace layout into an existing layout of the target
        document.  The filter function `filter_fn` is used to skip source entities, the
        function should return ``False`` for entities to ignore and ``True`` otherwise.

        The content of the modelspace which may be displayed through a
        VIEWPORT entity will **not** be loaded!

        Args:
            psp: the source paperspace layout
            target_layout: target layout can be any layout: modelspace, paperspace
                layout or block layout.
            filter_fn: function to filter source entities

        rJ  r/  rn  rl  N)r¢   r   r9   r0  r   ru   rÍ   rÎ   rN  rÇ   rÈ   )rÔ   rÑ   r1  rÌ   rÉ   rÃ   s         rH   Úload_paperspace_layout_intoz"Loader.load_paperspace_layout_into<  sÑ   € ô( ˜#œzÔ*ÜÐ @ÄÀcÃÀÐLÓMÐMÜ˜-¬Ô4ÜÐ <¼TÀ-Ó=PÐ<QÐRÓSÐSØ�7‰7˜$Ÿ)™)Ñ#ÜØPóð ð ×Ñ D§I¡IÑ-ÜØLóð ð ÐÜ˜C“y‰Há#&Ó7¡3˜a©)°A­,š 3ˆHÐ7Ø×Ñœ h°Ó>Õ?ùò 8s   Â'CÂ5Cc                óÌ   — t        |t        «      st        dt        |«      › �«      ‚|j                  | j
                  urt        d«      ‚| j                  t        |«      «       y)a>  Loads a block layout (block definition) as a new block layout into the target
        document. If a block layout with the same name exists the conflict policy will
        be applied.  This method cannot load modelspace or paperspace layouts.

        Args:
            block_layout: the source block layout

        r\  ú9given block layout does not belong to the source documentN)r¢   r   r9   r0  ru   rÍ   rÇ   rZ  )rÔ   r]  s     rH   Úload_block_layoutzLoader.load_block_layoutb  s^   € ô ˜,¬Ô4ÜÐ ;¼DÀÓ<NÐ;OÐPÓQÐQØ×Ñ 4§9¡9Ñ,ÜØKóð ð 	×Ñœ¨Ó6Õ7rJ   c                ót  — t        |t        «      st        dt        |«      › �«      ‚t        |t        «      st        dt        |«      › �«      ‚|j
                  | j                  urt        d«      ‚|j
                  | j                  urt        d«      ‚| j                  t        t        |«      |«      «       y)a†  Loads the content of a block layout (block definition) into an existing layout
        of the target document.  This method cannot load the content of
        modelspace or paperspace layouts.

        Args:
            block_layout: the source block layout
            target_layout: target layout can be any layout: modelspace, paperspace
                layout or block layout.

        r\  r/  rs  rl  N)r¢   r   r9   r0  r   ru   rÍ   rÎ   rÇ   rÈ   rN  )rÔ   r]  r1  s      rH   rº   zLoader.load_block_layout_intov  s¬   € ô ˜,¬Ô4ÜÐ ;¼DÀÓ<NÐ;OÐPÓQÐQÜ˜-¬Ô4ÜÐ <¼TÀ-Ó=PÐ<QÐRÓSÐSØ×Ñ 4§9¡9Ñ,ÜØKóð ð ×Ñ D§I¡IÑ-ÜØLóð ð 	×Ñœ¤d¨<Ó&8¸-ÓHÕIrJ   c                óx   — t        || j                  j                  «      }| j                  t	        |«      «       y)zŸLoads the layers defined by the argument `names` into the target document.
        In the case of a name conflict the conflict policy will be applied.
        N)Ú_get_table_entriesrÍ   ÚlayersrÇ   ra  ©rÔ   ÚnamesrÉ   s      rH   Úload_layerszLoader.load_layers“  ó-   € ô & e¨T¯Y©Y×-=Ñ-=Ó>ˆØ×Ñœ xÓ0Õ1rJ   c                óx   — t        || j                  j                  «      }| j                  t	        |«      «       y)z¢Loads the linetypes defined by the argument `names` into the target document.
        In the case of a name conflict the conflict policy will be applied.
        N)rw  rÍ   Ú	linetypesrÇ   ra  ry  s      rH   Úload_linetypeszLoader.load_linetypesš  ó-   € ô & e¨T¯Y©Y×-@Ñ-@ÓAˆØ×Ñœ xÓ0Õ1rJ   c                óx   — t        || j                  j                  «      }| j                  t	        |«      «       y)z¤Loads the TEXT styles defined by the argument `names` into the target document.
        In the case of a name conflict the conflict policy will be applied.
        N)rw  rÍ   ÚstylesrÇ   ra  ry  s      rH   Úload_text_styleszLoader.load_text_styles¡  r|  rJ   c                óx   — t        || j                  j                  «      }| j                  t	        |«      «       y)z©Loads the DIMENSION styles defined by the argument `names` into the target
        document. In the case of a name conflict the conflict policy will be applied.
        N)rw  rÍ   Ú	dimstylesrÇ   ra  ry  s      rH   Úload_dim_styleszLoader.load_dim_styles¨  r€  rJ   c                óx   — t        || j                  j                  «      }| j                  t	        |«      «       y)z¥Loads the MLINE styles defined by the argument `names` into the target
        document. In the case of a name conflict the conflict policy will be applied.
        N)rw  rÍ   Úmline_stylesrÇ   ra  ry  s      rH   Úload_mline_styleszLoader.load_mline_styles¯  s-   € ô & e¨T¯Y©Y×-CÑ-CÓDˆØ×Ñœ xÓ0Õ1rJ   c                óx   — t        || j                  j                  «      }| j                  t	        |«      «       y)z«Loads the MULTILEADER styles defined by the argument `names` into the target
        document. In the case of a name conflict the conflict policy will be applied.
        N)rw  rÍ   Úmleader_stylesrÇ   ra  ry  s      rH   Úload_mleader_styleszLoader.load_mleader_styles¶  s-   € ô & e¨T¯Y©Y×-EÑ-EÓFˆØ×Ñœ xÓ0Õ1rJ   c                óx   — t        || j                  j                  «      }| j                  t	        |«      «       y)z¢Loads the MATERIALS defined by the argument `names` into the target
        document. In the case of a name conflict the conflict policy will be applied.
        N)rw  rÍ   Ú	materialsrÇ   ra  ry  s      rH   Úload_materialszLoader.load_materials½  r€  rJ   c                ó„  — t        | j                  | j                  «      }t        j                  j
                  }| j                  D ]  }|j                  |«       Œ |rt        |j                  «       t        | j                  «      }|j                  |j                  «       t        ||j                  |j                  |j                   | j"                  |j$                  ¬«      }|rt'        |«      |_        |j+                  |j                  «       |j-                  |j.                  «       |j1                  «        |j3                  «        |j5                  «        |j7                  «        |j9                  «        |j;                  «        | j                  D ]  }|j=                  |«       Œ |j?                  «        y)z¤Execute all loading commands. The `xref_prefix` string is used as XREF name
        when the conflict policy :attr:`ConflictPolicy.XREF_PREFIX` is applied.
        )r%  ÚcopiesÚobjectsÚhandle_mappingr™   Úcopy_errorsN) Ú	_RegistryrÍ   rÎ   r:   ÚoptionsrE   rg  r&  rI   Údebug_messagesÚCopyMachineÚcopy_blocksÚsource_blocksr,  r‘  r’  r“  r™   r”  rc   rŸ   Úadd_object_copiesÚregister_classesÚclassesÚregister_table_resourcesÚregister_object_resourcesÚredirect_handle_mappingÚmap_object_resourcesÚmap_entity_resourcesÚcopy_settingsr¬   Úfinalize)rÔ   rŸ   r%  rE   ÚcmdÚcpmr)  s          rH   r¬   zLoader.executeÄ  sN  € ô ˜TŸY™Y¨¯	©	Ó2ˆÜ—‘×#Ñ#ˆà—>”>ˆCØ×"Ñ" 8Õ,ð "ñ Ü × 7Ñ 7Ô8ä˜$Ÿ)™)Ó$ˆà�‰˜×.Ñ.Ô/ÜØØ—:‘:Ø—K‘KØ×-Ñ-Ø ×0Ñ0ØŸ™ô
ˆñ Ü#& {Ó#3ˆHÔ Ø×"Ñ" 3§;¡;Ô/Ø×!Ñ! #§+¡+Ô.Ø×)Ñ)Ô+Ø×*Ñ*Ô,Ø×(Ñ(Ô*Ø×%Ñ%Ô'Ø×%Ñ%Ô'Ø×ÑÔ à—>”>ˆCØ�K‰K˜Õ!ð "à×ÑÕrJ   ©rÍ   r   rÎ   r   rî   rï   )rj  r#  rî   rï   )NN)r1  zOptional[BaseLayout]rÌ   rW  rî   rï   rC   rV  )rÑ   r   r1  r   rÌ   rW  rî   rï   )r]  r   rî   rï   )r]  r   r1  r   rî   rï   )rz  zSequence[str]rî   rï   r  )rŸ   rc   rî   rï   )rL   rM   rN   rO   r3   r[   r2  rÇ   r/   rÐ   rq  rt  rº   r{  r  rƒ  r†  r‰  rŒ  r�  r¬   rP   rJ   rH   r4   r4   æ  s#  „ ñð =K×<OÑ<Oð2Øð2Ø#*ð2à	ó2ó'ð
 /3Ø.2ð@à+ð@ð ,ð@ð 
ó	@ðB /3ð?àð?ð ,ð?ð 
ó	?ð> /3ð	$@àð$@ð "ð$@ð ,ð	$@ð
 
ó$@ðL8à!ð8ð 
ó8ð(Jà!ðJð "ðJð 
ó	Jó:2ó2ó2ó2ó2ó2ó2õ%rJ   r4   c                ó”   — g }| D ]'  }	 |j                  |«      }|r|j                  |«       Œ) |S # t        j                  $ r Y ŒAw xY wrC   )r¦   ri  r
   ÚDXFTableEntryError)rz  ÚtablerÉ   rp   Úentrys        rH   rw  rw  ì  sT   € Ø "€HÛˆð	Ø—I‘I˜d“OˆEÙØ—‘ Ô&øð	 ð €Oøô ×'Ñ'ò 	Ùð	ús   ‰$1±AÁAc                  óh   — e Zd Zdd„Zdd„Zefdd„Zdd„Zdd„Zdd„Z	dd„Z
dd„Zdd	„Zdd
„Zdd„Zy)r•  c                óf   — || _         || _        t        i i| _        t	        «       | _        g | _        y rC   )r´   r±   ró   rš  ÚsetÚappidsr—  ©rÔ   rÍ   rÎ   s      rH   r2  z_Registry.__init__ù  s1   € ØˆŒØˆŒô @HÈ¸nˆÔÜ #£ˆŒØ)+ˆÕrJ   c                ó:   — | j                   j                  |«       y rC   ©r—  ri  ©rÔ   rG   s     rH   rE   z_Registry.debug  ó   € Ø×Ñ×"Ñ" 3Õ'rJ   c                ó°   — |€J d«       ‚| j                   j                  |i «      }|j                  j                  }||v ry |||<   |j	                  | «       y )Nzinternal error: entity is None)rš  Ú
setdefaultr¥   rÞ   r&  )rÔ   rÕ   rÖ   r£   Úentity_handles        rH   r×   z_Registry.add_entity  s^   € ØÐ!ÐCÐ#CÓCÐ!Ø×"Ñ"×-Ñ-¨i¸Ó<ˆØŸ
™
×)Ñ)ˆØ˜EÑ!ØØ%ˆˆmÑØ×!Ñ! $Õ'rJ   c                ó  — | j                  |«       |j                  j                  }| j                  |j                  |«       |j                  D ]  }| j                  ||«       Œ | j                  |j
                  |«       y rC   )r×   r¥   rÞ   r£   Úentity_spaceÚendblk)rÔ   rÚ   Úblock_handlerÕ   s       rH   rÛ   z_Registry.add_block  se   € à�‰˜Ô%à#×'Ñ'×.Ñ.ˆØ�‰˜×*Ñ*¨LÔ9Ø"×/Ô/ˆFØ�O‰O˜F LÕ1ð 0à�‰˜×+Ñ+¨\Õ:rJ   c                óô   — |�|dk(  ry| j                   j                  j                  |«      }|€| j                  d|› d�«       yt	        |«      rt        dt        |«      › �«      ‚| j                  |«       y)zšAdd resource by handle (table entry or object), cannot add graphic entities.

        Raises:
            EntityError: cannot add graphic entity

        Nr;   zsource entity #z does not existzcannot add graphic entity: )r´   Úentitydbr¦   rE   r   r8   rc   r×   )rÔ   rÞ   rÕ   s      rH   rß   z_Registry.add_handle  st   € ð ˆ>˜V sš]ØØ—‘×)Ñ)×-Ñ-¨fÓ5ˆØˆ>Ø�J‰J˜¨¨°Ð@ÔAØÜ˜VÔ$ÜÐ ;¼CÀ»K¸=ÐIÓJÐJØ�‰˜ÕrJ   c                óâ   — |t         k(  ry 	 | j                  j                  j                  |«      }| j	                  |«       y # t
        j                  $ r | j                  d|› d�«       Y y w xY w)Nzsource layer 'ú' does not exist)ÚDEFAULT_LAYERr´   rx  r¦   r×   r
   r©  rE   )rÔ   rp   Úlayers      rH   râ   z_Registry.add_layer/  sf   € Ø”=Ò àð	@Ø—O‘O×*Ñ*×.Ñ.¨tÓ4ˆEØ�O‰O˜EÕ"øÜ×'Ñ'ò 	@Ø�J‰J˜¨ vÐ-=Ð>Ö?ð	@ús   Œ6A Á(A.Á-A.c                óü   — |j                  «       t        v ry 	 | j                  j                  j	                  |«      }| j                  |«       y # t        j                  $ r | j                  d|› d�«       Y y w xY w)Nzsource linetype 'r¿  )	ÚupperÚDEFAULT_LINETYPESr´   r~  r¦   r×   r
   r©  rE   )rÔ   rp   Úlinetypes      rH   rä   z_Registry.add_linetype9  sn   € à�:‰:‹<Ô,Ñ,Øð	CØ—‘×0Ñ0×4Ñ4°TÓ:ˆHØ�O‰O˜HÕ%øÜ×'Ñ'ò 	CØ�J‰JÐ*¨4¨&Ð0@ÐAÖBð	Cús   ™6A Á(A;Á:A;c                óÎ   — 	 | j                   j                  j                  |«      }| j                  |«       y # t        j
                  $ r | j                  d|› d�«       Y y w xY w)Nzsource text style 'r¿  )r´   r‚  r¦   r×   r
   r©  rE   )rÔ   rp   Ú
text_styles      rH   ræ   z_Registry.add_text_styleC  s\   € ð	EØŸ™×/Ñ/×3Ñ3°DÓ9ˆJØ�O‰O˜JÕ'øÜ×'Ñ'ò 	EØ�J‰JÐ,¨T¨FÐ2BÐCÖDð	Eúó   ‚69 ¹(A$Á#A$c                óÎ   — 	 | j                   j                  j                  |«      }| j                  |«       y # t        j
                  $ r | j                  d|› d�«       Y y w xY w)Nzsource dimension style 'r¿  )r´   r…  r¦   r×   r
   r©  rE   )rÔ   rp   Ú	dim_styles      rH   rè   z_Registry.add_dim_styleJ  s\   € ð	JØŸ™×1Ñ1×5Ñ5°dÓ;ˆIØ�O‰O˜IÕ&øÜ×'Ñ'ò 	JØ�J‰JÐ1°$°Ð7GÐHÖIð	JúrÈ  c                óÎ   — 	 | j                   j                  j                  |«      }| j                  |«       y # t        j
                  $ r | j                  d|› d�«       Y y w xY w)Nzsource block 'r¿  )r´   Úblock_recordsr¦   r×   r
   r©  rE   )rÔ   rp   rÚ   s      rH   rê   z_Registry.add_block_nameQ  s[   € ð	@ØŸ?™?×8Ñ8×<Ñ<¸TÓBˆLØ�O‰O˜LÕ)øÜ×'Ñ'ò 	@Ø�J‰J˜¨ vÐ-=Ð>Ö?ð	@úrÈ  c                óV   — | j                   j                  |j                  «       «       y rC   )r¯  ÚaddrÃ  rá   s     rH   rì   z_Registry.add_appidX  s   € Ø�‰�‰˜Ÿ
™
›Õ%rJ   Nr§  ©rG   rc   rî   rï   rí   rð   rñ   rò   ©rî   rï   )rL   rM   rN   r2  rE   ró   r×   rÛ   rß   râ   rä   ræ   rè   rê   rì   rP   rJ   rH   r•  r•  ø  sD   „ ó,ó(ð >Fô (ó;ó ó"@óCóEóJó@ô&rJ   r•  c                  ó¢  — e Zd Zej                  dœ	 	 	 	 	 	 	 	 	 	 	 d,d„Zd-d„Zd.d/d„Zd0d„Zd1d„Z	d1d„Z
d1d„Zd1d	„Zd1d
„Zd2d„Zd3d„Zd4d5d„Z	 	 	 	 	 	 	 	 d6d„Zddœ	 	 	 	 	 	 	 d7d„Zd8d„Zd8d„Zd8d„Zd8d„Zd8d„Zd9d„Zd8d„Zd8d„Zd:d„Zd;d„Zd<d„Zd<d„Zd=d„Zd>d„Z d>d „Z!d?d!„Z"d3d"„Z#	 	 	 	 	 	 d@d#„Z$dAd$„Z%dBd%„Z&dCd&„Z'd'„ Z(d(„ Z)d)„ Z*d8d*„Z+y+)Dr,  rž   c               óî   — || _         || _        || _        || _        || _        t        |j                  «      | _        i | _        i | _	        i | _
        i | _        i | _        || _        i | _        g | _        y rC   )r%  Úcopied_blocksÚcopied_objectsr”  r™   Úget_xref_namer´   rŸ   Úlayer_mappingÚlinetype_mappingÚtext_style_mappingÚdim_style_mappingÚblock_name_mappingr“  Ú_replace_handlesr—  )rÔ   r%  r‘  r’  r“  r™   r”  s          rH   r2  z_Transfer.__init__]  s~   € ð !ˆŒà#ˆÔØ%ˆÔØ&ˆÔØ.ˆÔÜ(¨×)<Ñ)<Ó=ˆÔØ-/ˆÔØ02ˆÔØ24ˆÔØ13ˆÔØ24ˆÔØ.<ˆÔØ02ˆÔØ)+ˆÕrJ   c                ó:   — | j                   j                  |«       y rC   r²  r³  s     rH   rE   z_Transfer.debugw  r´  rJ   c                ó:   — | j                   j                  ||«      S rC   )r“  r¦   rö   s      rH   rø   z_Transfer.get_handlez  s   € Ø×"Ñ"×&Ñ& v¨wÓ7Ð7rJ   c                óœ   — | j                   j                  |«      }|r/| j                  j                  j                  j                  |«      S y rC   )r“  r¦   r%  r±   r½  )rÔ   rÞ   Úhandle_of_copys      rH   rú   z_Transfer.get_reference_of_copy}  s?   € Ø×,Ñ,×0Ñ0°Ó8ˆÙØ—=‘=×+Ñ+×4Ñ4×8Ñ8¸ÓHÐHØrJ   c                ó:   — | j                   j                  ||«      S rC   )rÖ  r¦   rá   s     rH   rü   z_Transfer.get_layerƒ  s   € Ø×!Ñ!×%Ñ% d¨DÓ1Ð1rJ   c                ó:   — | j                   j                  ||«      S rC   )r×  r¦   rá   s     rH   rþ   z_Transfer.get_linetype†  s   € Ø×$Ñ$×(Ñ(¨¨tÓ4Ð4rJ   c                ó:   — | j                   j                  ||«      S rC   )rØ  r¦   rá   s     rH   r   z_Transfer.get_text_style‰  ó   € Ø×&Ñ&×*Ñ*¨4°Ó6Ð6rJ   c                ó:   — | j                   j                  ||«      S rC   )rÙ  r¦   rá   s     rH   r  z_Transfer.get_dim_styleŒ  s   € Ø×%Ñ%×)Ñ)¨$°Ó5Ð5rJ   c                ó:   — | j                   j                  ||«      S rC   )rÚ  r¦   rá   s     rH   r  z_Transfer.get_block_name�  rã  rJ   c                ó–   — 	 | j                   |j                  j                     |j                  j                     S # t        $ r Y yw xY w)z%Returns the copy of graphic entities.N)rÓ  r¥   rÁ   rÞ   ÚKeyErrorr  s     rH   r9  z_Transfer.get_entity_copy’  sF   € ð	Ø×%Ñ% f§j¡j×&6Ñ&6Ñ7¸¿
¹
×8IÑ8IÑJÐJøÜò 	ØØð	ús   ‚9< ¼	AÁAc                ó²   — | j                  |«      }|r|j                  || «       y |j                  j                  | j                  v ry t        d|› d�«      ‚)Nzcopy of z
 not found)r9  Úmap_resourcesr¥   rÞ   r”  rW   )rÔ   rÕ   r  s      rH   r  z_Transfer.map_resources_of_copyš  sT   € Ø×$Ñ$ VÓ,ˆÙØ× Ñ  ¨Õ-Ø�Z‰Z×Ñ $×"2Ñ"2Ñ2Øä (¨6¨(°*Ð =Ó>Ð>rJ   c                óŽ  — t        |«      D ]·  \  }}t        j                  |«      sŒ| j                  |j                  d¬«      }t        j
                  |j                  |«      ||<   |sŒ_t        j                  |«      sŒu| j                  j                  j                  j                  |«      }|€Œ§||j                  _        Œ¹ y )Nr;   )r÷   )Ú	enumerater   Úis_translatable_pointerrø   ÚvalueÚDXFTagÚcodeÚis_hard_ownerr%  r±   r½  r¦   r¥   rÁ   )rÔ   r	  r
  ÚindexÚtagrÞ   Úcopied_objects          rH   r  z_Transfer.map_pointers£  s—   € Ü# Dž/‰JˆE�3Ü×,Ñ,¨SÕ1ØŸ™¨¯©¸C˜Ó@�Ü#Ÿl™l¨3¯8©8°VÓ<��U‘Ú#¬×(;Ñ(;¸CÕ(@Ø$(§M¡M×$<Ñ$<×$EÑ$E×$IÑ$IÈ&Ó$Q�MØ$Ð,Ø Ø.>�M×%Ñ%Õ+ñ *rJ   c                ór  — | j                   j                  }|j                  j                  |«      }|j	                  |«      }t        |t        «      r€| j                  t        j                  k(  r||fS | j                  t        j                  k(  rt        || j                  |«      }n*| j                  t        j                  k(  rt        |d|«      }| j                  |j                  j                   «      }|€d|fS |j#                  ||«       |j                  j                   |j                  _        ||fS )zdMap and add `entity` to a top level ACAD dictionary `dict_name` in root
        dictionary.
        rœ   )r%  r±   ÚrootdictÚget_required_dictr¦   r¢   r   r™   r3   r[   r\   Úget_unique_dict_keyrŸ   r]   rú   r¥   rÞ   rÎ  rÁ   )rÔ   r  r  rÕ   rÎ   Ú	acad_dictÚexisting_entryÚloaded_entrys           rH   r  z_Transfer.map_acad_dict_entry®  s
  € ð �}‰}×'Ñ'ˆØ—M‘M×3Ñ3°IÓ>ˆ	Ø"Ÿ™ zÓ2ˆô �n¤iÔ0Ø×#Ñ#¤~×':Ñ':Ò:Ø! >Ð1Ð1Ø×%Ñ%¬×)CÑ)CÒCÜ0Ø × 0Ñ 0°)ó‘
ð ×%Ñ%¬×)BÑ)BÒBÜ0°¸RÀÓK�
à×1Ñ1°&·*±*×2CÑ2CÓDˆØÐØ�v�:ÐØ�‰�j ,Ô/Ø!*§¡×!5Ñ!5ˆ×ÑÔØ˜<Ð'Ð'rJ   Fr  c               ó   — |j                   j                  |d«      }|sy| j                  |«      }|r"|dk7  r|j                   j                  ||«       y|r|j                   j	                  |«       y|j                   j                  |d«       y)zoMap handle attribute if the original handle exist and the references entity
        was really copied.
        rœ   Nr;   )r¥   r¦   rø   r®  Údiscard)rÔ   r  r  r  r  rÞ   Ú
new_handles          rH   r  z_Transfer.map_existing_handleË  so   € ð —‘—‘ ¨RÓ0ˆÙØØ—_‘_ VÓ,ˆ
Ù˜*¨Ò+Ø�I‰I�M‰M˜+ zÕ2áØ—	‘	×!Ñ! +Õ.à—	‘	—‘˜k¨3Õ/rJ   c                ó~  — | j                  «        | j                  t           j                  «       D �]  \  }}|j                  j
                  �Œt        |t        «      r| j                  |«       Œ@t        |t        «      r| j                  |«       Œbt        |t        «      r0|j                  r| j                  |«       Œ�| j                  |«       Œ¢t        |t        «      r| j!                  |«       ŒÄt        |t"        «      r| j%                  ||«       Œçt        |t&        «      sŒø| j)                  |«       �Œ y)zHRegister copied table-entries in resource tables of the target document.N)Úregister_appidsrÓ  ró   Úitemsr¥   rÁ   r¢   r   Úadd_layer_entryr   Úadd_linetype_entryr   Úis_shape_fileÚadd_shape_file_entryÚadd_text_style_entryr   Úadd_dim_style_entryr   Úadd_block_record_entryr   Úadd_ucs_entry)rÔ   Úsource_entity_handlerÕ   s      rH   rž  z"_Transfer.register_table_resourcesÝ  sò   € à×ÑÔà,0×,>Ñ,>¼xÑ,H×,NÑ,N×,PÑ(Ð  &Ø�z‰z×ÑÐ+Øô ˜&¤%Ô(Ø×$Ñ$ VÕ,Ü˜F¤HÔ-Ø×'Ñ'¨Õ/Ü˜F¤IÔ.Ø×'Ò'Ø×-Ñ-¨fÕ5à×-Ñ-¨fÕ5Ü˜F¤HÔ-Ø×(Ñ(¨Õ0Ü˜F¤KÔ0Ø×+Ñ+¨FÐ4HÕIÜ˜F¤MÕ2Ø×"Ñ" 6Ö*ñ' -QrJ   c                ó.  — | j                   j                  }| j                  j                  «       D ]â  \  }}t	        |t
        «      r!| j                  |j                  |h d£¬«       Œ7t	        |t        «      r$| j                  |j                  |t        h¬«       Œkt	        |t        «      r$| j                  |j                  |t        h¬«       ŒŸt	        |t        «      r| j                  |«       ŒÁt	        |t        «      sŒÒ| j!                  |«       Œä y)zERegister copied objects in object collections of the target document.>   ÚGLOBALr<   r=   )Úsystem_entriesN)r%  r±   rÔ  r   r¢   r   Úadd_collection_entryrŽ  r   rˆ  r?   r    r‹  r%   Úadd_visualstyle_entryr$   Úcreate_empty_paperspace_layout)rÔ   rÎ   Ú_rÕ   s       rH   rŸ  z#_Transfer.register_object_resourcesö  sò   € ð �}‰}×'Ñ'ˆØ×,Ñ,×2Ñ2Ö4‰IˆAˆvÜ˜&¤(Ô+Ø×)Ñ)Ø—N‘NØÚ#Cð *õ ô
 ˜F¤JÔ/Ø×)Ñ)Ø×%Ñ%Øä ð$ð *õ ô ˜F¤LÔ1Ø×)Ñ)Ø×'Ñ'Øä ð$ð *õ ô ˜F¤KÔ0Ø×*Ñ*¨6Õ2Ü˜F¤IÕ.Ø×3Ñ3°FÕ;ñ5 5rJ   c                ó"   — || j                   |<   y rC   )rÛ  )rÔ   Ú
old_targetÚ
new_targets      rH   Úreplace_handle_mappingz _Transfer.replace_handle_mapping   s   € Ø,6ˆ×Ñ˜jÒ)rJ   c                óÌ   — i }| j                   }| j                  j                  «       D ]  \  }}||v sŒ||   ||<   Œ |j                  «       D ]  \  }}|| j                  |<   Œ y)zuRedirect handle mapping from copied entity to a handle of an existing entity
        in the target document.
        N)rÛ  r“  r   )rÔ   Útemp_mappingÚreplace_handlesÚsource_handleÚtarget_handleÚnew_target_handles         rH   r   z!_Transfer.redirect_handle_mapping#  sv   € ð (*ˆØ×/Ñ/ˆà,0×,?Ñ,?×,EÑ,EÖ,GÑ(ˆM˜=Ø Ò/à.=¸mÑ.L�˜]Ò+ð -Hð
 1=×0BÑ0BÖ0DÑ,ˆMÐ,Ø1BˆD×Ñ Ò.ñ 1ErJ   c                óÐ   — | j                   j                  }| j                   j                  D ]  }	 |j                  j                  |«       Œ  y # t        j
                  $ r Y Œ7w xY wrC   )r%  r±   r¯  rs   r
   r©  )rÔ   rÎ   Úappids      rH   rÿ  z_Transfer.register_appids2  sT   € Ø�}‰}×'Ñ'ˆØ—]‘]×)Ô)ˆEðØ—‘—‘ Õ&ñ *øô ×+Ñ+ò Ùðús   ±AÁA%Á$A%c                ób   — | j                   j                  j                  j                  |«       y rC   )r%  r±   r�  Úregister)rÔ   r�  s     rH   rœ  z_Transfer.register_classes:  s    € Ø�‰× Ñ ×(Ñ(×1Ñ1°'Õ:rJ   c                ó8  — | j                   j                  j                  }| j                  j	                  «       D ]]  \  }}|j	                  «       D ]E  \  }}|j                  |«      }|€t        d«      ‚|€Œ'|j                  sŒ4|j                  || «       ŒG Œ_ y )Nz'database error, source entity not found)	r%  r´   r½  rÓ  r   r¦   rW   Úis_aliveré  )rÔ   Ú	source_dbrÖ   r£   r	  r  Úsource_entitys          rH   r¢  z_Transfer.map_entity_resources=  sˆ   € Ø—M‘M×,Ñ,×5Ñ5ˆ	Ø $× 2Ñ 2× 8Ñ 8Ö :ÑˆI�uØ/4¯{©{®}Ñ+Ð$ eØ )§¡Ð.BÓ C�Ø Ð(Ü'Ð(QÓRÐRØÑ$¨¯«Ø!×/Ñ/°°tÕ<ñ 0=ñ !;rJ   c                ó  — | j                   j                  j                  }| j                  j	                  «       D ]E  \  }}|j                  |«      }|€t        d«      ‚|€Œ'|j                  sŒ4|j                  || «       ŒG y )Nz'database error, source object not found)	r%  r´   r½  rÔ  r   r¦   rW   r   ré  )rÔ   r!  Úsource_object_handler  r"  s        rH   r¡  z_Transfer.map_object_resourcesG  st   € Ø—M‘M×,Ñ,×5Ñ5ˆ	Ø+/×+>Ñ+>×+DÑ+DÖ+FÑ'Ð  %Ø%ŸM™MÐ*>Ó?ˆMØÐ$Ü#Ð$MÓNÐNØÑ  U§^£^Ø×+Ñ+¨E°4Õ8ñ ,GrJ   c                óv  — | j                   j                  }|j                  j                  j	                  «       }|dv st        j                  |«      ri	 |j                  j                  |«      }|rK| j                  |j                  j                  |j                  j                  «       |j                  «        y |j                  j                  }| j                  |j                  |«       |j                  r$|j                  j                  | j                   |<   y y # t        j                  $ r d }Y ŒÇw xY w)N)r;   Ú	DEFPOINTS)r%  r±   r¥   rp   rÃ  r   Úis_adsk_special_layerrx  r¦   r
   r©  r  rÞ   ÚdestroyÚadd_table_entryr   rÖ  )rÔ   rÁ  rÎ   Ú
layer_nameÚspecialÚold_names         rH   r  z_Transfer.add_layer_entryP  sï   € Ø�}‰}×'Ñ'ˆØ—Y‘Y—^‘^×)Ñ)Ó+ˆ
ð Ð+Ñ+¬y×/NÑ/NØô0
ðØŸ+™+Ÿ/™/¨*Ó5�ñ à×+Ñ+¨E¯I©I×,<Ñ,<¸g¿k¹k×>PÑ>PÔQØ—‘”ØØ—9‘9—>‘>ˆØ×Ñ˜TŸ[™[¨%Ô0Ø�>Š>Ø+0¯9©9¯>©>ˆD×Ñ˜xÒ(ð øô ×+Ñ+ò Ø’ðús   ÁD  Ä D8Ä7D8c                ó<  — | j                   j                  }|j                  j                  j	                  «       t
        v rz|j                  j                  |j                  j                  «      }| j                  |j                  j                  |j                  j                  «       |j                  «        y |j                  j                  }| j                  |j                  |«       |j                  r$|j                  j                  | j                  |<   y y rC   )r%  r±   r¥   rp   rÃ  rÄ  r~  r¦   r  rÞ   r(  r)  r   r×  )rÔ   rÅ  rÎ   Ústandardr,  s        rH   r  z_Transfer.add_linetype_entryf  sÉ   € Ø�}‰}×'Ñ'ˆØ�<‰<×Ñ×"Ñ"Ó$Ô(9Ñ9Ø—~‘~×)Ñ)¨(¯,©,×*;Ñ*;Ó<ˆHØ×'Ñ'¨¯©×(;Ñ(;¸X¿\¹\×=PÑ=PÔQØ×ÑÔØØ—<‘<×$Ñ$ˆØ×Ñ˜TŸ^™^¨XÔ6Ø×ÒØ.6¯l©l×.?Ñ.?ˆD×!Ñ! (Ò+ð rJ   c                óô   — | j                   j                  }|j                  j                  }| j	                  |j
                  |«       |j                  r$|j                  j                  | j                  |<   y y rC   )r%  r±   r¥   rp   r)  r‚  r   rØ  )rÔ   rÇ  rÎ   r,  s       rH   r  z_Transfer.add_text_style_entryr  s\   € Ø�}‰}×'Ñ'ˆØ—>‘>×&Ñ&ˆØ×Ñ˜TŸ[™[¨*Ô5Ø×ÒØ0:·±×0CÑ0CˆD×#Ñ# HÒ-ð rJ   c                óF  — |j                   j                  }|sy | j                  j                  }|j                  j                  |«      }|€|j                  j                  |«      }| j                  |j                   j                  |j                   j                  «       y rC   )	r¥   Úfontr%  r±   r‚  Úfind_shxÚadd_shxr  rÞ   )rÔ   rÇ  Úshape_file_namerÎ   Ú
shape_files        rH   r  z_Transfer.add_shape_file_entryy  sx   € à$Ÿ.™.×-Ñ-ˆÙØØ�}‰}×'Ñ'ˆØ—[‘[×)Ñ)¨/Ó:ˆ
ØÐØŸ™×,Ñ,¨_Ó=ˆJØ×#Ñ# J§N¡N×$9Ñ$9¸:¿>¹>×;PÑ;PÕQrJ   c                óô   — | j                   j                  }|j                  j                  }| j	                  |j
                  |«       |j                  r$|j                  j                  | j                  |<   y y rC   )r%  r±   r¥   rp   r)  r…  r   rÙ  )rÔ   rÊ  rÎ   r,  s       rH   r  z_Transfer.add_dim_style_entry„  s\   € Ø�}‰}×'Ñ'ˆØ—=‘=×%Ñ%ˆØ×Ñ˜TŸ^™^¨YÔ7Ø×ÒØ/8¯}©}×/AÑ/AˆD×"Ñ" 8Ò,ð rJ   c                óT  — | j                   j                  }|j                  j                  j	                  «       }|j                  j                  }t        |«      dkD  rQ|d   dk(  rI|j                  j                  |d   «      |j                  _        |j                  j                  |«       n| j                  |j                  |«       |j                  rQ|j                  j                  | j                  |<   | j                  ||«       |j                  j                  |«       y y )Nr=  r   Ú*)r%  r±   r¥   rp   rÃ  rÅ   rr   Úanonymous_block_namerÌ  Ú	add_entryr)  r   rÚ  Úrestore_block_contentrÎ  )rÔ   rÚ   rÞ   rÎ   rv   r,  s         rH   r  z _Transfer.add_block_record_entry‹  sï   € Ø�}‰}×'Ñ'ˆØ!×%Ñ%×*Ñ*×0Ñ0Ó2ˆ
Ø×#Ñ#×(Ñ(ˆô ˆz‹?˜QÒ :¨a¡=°CÒ#7ð %)§K¡K×$DÑ$DÀZÐPQÁ]Ó$SˆL×ÑÔ!Ø×Ñ×(Ñ(¨Õ6ð
 × Ñ  ×!3Ñ!3°\ÔBà× Ò Ø0<×0@Ñ0@×0EÑ0EˆD×#Ñ# HÑ-Ø×&Ñ& |°VÔ<Ø�K‰K�O‰O˜LÕ)ð !rJ   c           	     ó*  — | j                   j                  |t        «       «      }d }d }|j                  «       D ]›  }t	        |t
        t        f«      rt	        |t
        «      r|}Œ,|}Œ/t        |«      r|j                  |«       ŒL|j                  j                  }d|› d|› dt        |«      › �}t        j                  |«       | j                  |«       Œ� t	        |t
        «      r#t	        |t        «      r|j                  ||«       y t!        d«      ‚)Nz1skipping non-graphic DXF entity in BLOCK_RECORD('z', #z): zinvalid BLOCK_RECORD copy)rÓ  r¦   r…   Úvaluesr¢   r!   r"   r   r×   r¥   rp   rc   Úloggingrf  rE   Ú	set_blockrW   )	rÔ   rÚ   rÞ   Úcontentr£   rº  rÕ   rp   rG   s	            rH   r;  z_Transfer.restore_block_content¢  së   € Ø×$Ñ$×(Ñ(¨´³Ó8ˆØ!%ˆØ#'ˆØ—n‘nÖ&ˆFÜ˜&¤5¬& /Ô2Ü˜f¤eÔ,Ø"‘Eà#‘FÜ" 6Ô*Ø×'Ñ'¨Õ/à#×'Ñ'×,Ñ,�ØIÈ$ÈÈtÐTZÐS[Ð[^Ô_bÐciÓ_jÐ^kÐl�Ü—‘ Ô$Ø—
‘
˜3•ð 'ô �eœUÔ#¬
°6¼6Ô(BØ×"Ñ" 5¨&Õ1äÐ ;Ó<Ð<rJ   c                óh   — | j                   j                  }| j                  |j                  |«       y rC   )r%  r±   r)  Úucs)rÔ   rB  rÎ   s      rH   r  z_Transfer.add_ucs_entry¸  s%   € à�}‰}×'Ñ'ˆØ×Ñ˜TŸX™X sÕ+rJ   c                ó‚  — |j                   j                  }| j                  t        j                  k(  rm|j                  |«      rê|j                  |«      }| j                  |j                   j                  |j                   j                  «       |j                  «        y | j                  t        j                  k(  r't        || j                  |«      |j                   _        nJ| j                  t        j                  k(  r-|j                  |«      rt        |d|«      |j                   _        |j                  |«       y ©Nrœ   )r¥   rp   r™   r3   r[   Ú	has_entryr¦   r  rÞ   r(  r\   Úget_unique_table_namerŸ   r]   r:  )rÔ   rª  rÕ   rp   rù  s        rH   r)  z_Transfer.add_table_entry½  sâ   € Ø�z‰z�‰ˆØ×Ñ¤>×#6Ñ#6Ò6Ø�‰˜tÔ$Ø!&§¡¨4£�Ø×+Ñ+Ø—J‘J×%Ñ% ~×'9Ñ'9×'@Ñ'@ôð —‘Ô ØØ×!Ñ!¤^×%?Ñ%?Ò?ä3°D¸$×:JÑ:JÈEÓRˆF�J‰J�OØ×!Ñ!¤^×%>Ñ%>Ò>Ø�‰˜tÔ$Ü"7¸¸bÀ%Ó"H�—
‘
”Ø�‰˜ÕrJ   c                óÌ  — |j                   j                  }|j                  «       |v rh|j                  j	                  |«      }|rK| j                  |j                   j                  |j                   j                  «       |j                  «        y | j                  t        j                  k(  r^|j	                  |«      }|rÙ| j                  |j                   j                  |j                   j                  «       |j                  «        y | j                  t        j                  k(  r't        || j                  |«      |j                   _        nJ| j                  t        j                  k(  r-|j                  |«      rt        |d|«      |j                   _        |j                  j!                  |j                   j                  |«       |j                  |j                   _        y rD  )r¥   rp   rÃ  Úobject_dictr¦   r  rÞ   r(  r™   r3   r[   r\   rF  rŸ   r]   rE  rÎ  rÁ   )rÔ   Ú
collectionr«  r  rp   r+  rù  s          rH   r  z_Transfer.add_collection_entryÏ  sR  € ð �y‰y�~‰~ˆØ�:‰:‹<˜>Ñ)Ø ×,Ñ,×0Ñ0°Ó6ˆGÙØ×+Ñ+¨E¯I©I×,<Ñ,<¸g¿k¹k×>PÑ>PÔQØ—‘”ØØ×Ñ¤>×#6Ñ#6Ò6Ø'Ÿ^™^¨DÓ1ˆNÙØ×+Ñ+¨E¯I©I×,<Ñ,<¸n×>PÑ>P×>WÑ>WÔXØ—‘”ØØ×!Ñ!¤^×%?Ñ%?Ò?ä2°4¸×9IÑ9IÈ:ÓVˆE�I‰I�NØ×!Ñ!¤^×%>Ñ%>Ò>Ø×#Ñ# DÔ)Ü!6°t¸RÀÓ!L�—	‘	”Ø×Ñ×"Ñ" 5§9¡9§>¡>°5Ô9à$×+Ñ+ˆ�	‰	�rJ   c                ón  — | j                   j                  j                  j                  d«      }|j                  j
                  }|j                  |«      }|rK| j                  |j                  j                  |j                  j                  «       |j                  «        y |j                  ||«       y )NÚACAD_VISUALSTYLE)r%  r±   rõ  rö  r¥   Údescriptionr¦   r  rÞ   r(  Útake_ownership)rÔ   ÚvisualstyleÚvisualstyle_dictrp   rù  s        rH   r  z_Transfer.add_visualstyle_entryð  s‘   € ØŸ=™=×3Ñ3×<Ñ<×NÑNØó
Ðð �‰×*Ñ*ˆØ)×-Ñ-¨dÓ3ˆÙØ×'Ñ'Ø—‘×&Ñ&¨×(:Ñ(:×(AÑ(Aôð ×ÑÕ!à×+Ñ+¨D°+Õ>rJ   c                ó|  — | j                   j                  }|j                  j                  «       }|j                  j                  |«      }|j                  |j                  _        |j                  j                  |j                  j                  _
        t        ||«      }|j                  j                  |«       y rC   )r%  r±   ÚlayoutsÚunique_paperspace_namerr   rs   Úblock_record_handler¥   rÞ   rÚ   Úlayoutr   Úappend_layout)rÔ   rT  rÎ   rv   r]  rD  s         rH   r  z(_Transfer.create_empty_paperspace_layoutþ  s…   € Ø�}‰}×'Ñ'ˆð —\‘\×8Ñ8Ó:ˆ
Ø—{‘{—‘ zÓ2ˆà)5×)IÑ)Iˆ�
‰
Ô&Ø/5¯z©z×/@Ñ/@ˆ×!Ñ!×%Ñ%Ô,ä ¨Ó-ˆ
Ø�‰×"Ñ" :Õ.rJ   c                ó¶   — | j                   j                  j                  }|j                  «       D ]&  \  }}|sŒ	|j                  sŒ|j                  |«       Œ( y)zEAdd copied DXF objects to the OBJECTS section of the target document.N)r%  r±   r’  r   r   Ú
add_object)rÔ   r‘  r’  r  Úobjs        rH   r›  z_Transfer.add_object_copies  sB   € à—-‘-×*Ñ*×2Ñ2ˆØ—l‘l–n‰FˆAˆsÚ�s—|“|Ø×"Ñ" 3Õ'ñ %rJ   c                óD   — | j                  «        | j                  «        y rC   )Úcopy_raster_varsÚcopy_wipeout_vars)rÔ   s    rH   r£  z_Transfer.copy_settings  s   € Ø×ÑÔØ×ÑÕ rJ   c                ó  — | j                   j                  }| j                   j                  }d|j                  vsd|j                  v ry |j                  j                  «       \  }}}|j                  j                  |||¬«       y )NÚACAD_IMAGE_VARS)ÚframeÚqualityr¹   )r%  r´   r±   rõ  r’  Úget_raster_variablesÚset_raster_variables)rÔ   rÍ   rÎ   r^  r_  r¹   s         rH   rZ  z_Transfer.copy_raster_vars  sm   € Ø�}‰}×'Ñ'ˆØ�}‰}×'Ñ'ˆà T§]¡]Ñ2Ø  D§M¡MÑ1àØ $§¡× AÑ AÓ CÑˆˆw˜Ø�‰×)Ñ)°¸wÈeÐ)ÕTrJ   c                óþ   — | j                   j                  }| j                   j                  }d|j                  vsd|j                  v ry |j                  j                  |j                  j                  «       ¬«       y )NÚACAD_WIPEOUT_VARS)r^  )r%  r´   r±   rõ  r’  Úset_wipeout_variablesÚget_wipeout_frame_settingr°  s      rH   r[  z_Transfer.copy_wipeout_vars!  sb   € Ø�}‰}×'Ñ'ˆØ�}‰}×'Ñ'ˆà t§}¡}Ñ4Ø" d§m¡mÑ3àØ�‰×*Ñ*Ø—,‘,×8Ñ8Ó:ð 	+õ 	
rJ   c                óÊ   — | j                   j                  j                  j                  «        | j                  D ]&  }t
        j                  t        j                  |«       Œ( y rC   )	r%  r±   r½  Úpurger—  rD   Úlogr>  ÚINFOr³  s     rH   r¤  z_Transfer.finalize-  s@   € à�‰× Ñ ×)Ñ)×/Ñ/Ô1Ø×&Ô&ˆCÜ�J‰J”w—|‘| SÕ)ñ 'rJ   N)r%  r•  r‘  údict[str, dict[str, DXFEntity]]r’  údict[str, DXFEntity]r“  zdict[str, str]r”  úset[str]rî   rï   rÏ  r  r  r  r  ©rÕ   r   rî   r  r  r  r  r   r!  rÐ  )r�  zSequence[DXFClass]rî   rï   )rÁ  r   rî   rï   )rÅ  r   rî   rï   )rÇ  r   rî   rï   )rÊ  r   rî   rï   )rÚ   r   rÞ   rc   rî   rï   )rB  r   rî   rï   )r«  r   r  rl  rî   rï   )rN  r%   rî   rï   )rT  r$   rî   rï   )r‘  rk  rî   rï   ),rL   rM   rN   r3   r[   r2  rE   rø   rú   rü   rþ   r   r  r  r9  r  r  r  r  rž  rŸ  r  r   rÿ  rœ  r¢  r¡  r  r  r  r  r  r  r;  r  r)  r  r  r  r›  r£  rZ  r[  r¤  rP   rJ   rH   r,  r,  \  sq  „ ð '×+Ñ+ñ,àð,ð 0ð,ð &ð	,ð
 'ð,ð ð,ð 
ó,ó4(ô8óó2ó5ó7ó6ó7óó?ô	?ð(Øð(Ø*-ð(Ø7@ð(à	ó(ð< RWñ0Øð0Ø(1ð0Ø@Cð0à	ó0ó$+ó2$<óT7óCóó;ó=ó9ó:ó,
@óDó	RóBó*ó.=ó,,ó
 ð$,Ø!*ð,Ø<Dð,à	ó,óB?ó/ó(ò!ò	Uò

ô*rJ   r,  c                ón   — | j                   r)t        j                  | j                   «      j                  S yrD  )rj   rŒ   r�   Ústem)ru   s    rH   rÕ  rÕ  4  s%   € Ø
‡|‚|Ü�|‰|˜CŸL™LÓ)×.Ñ.Ð.ØrJ   c                óD   — t        | «      dkD  xr | j                  d«      S )Nr=  r8  )rÅ   Ú
startswith)rp   s    rH   Úis_anonymous_block_namerr  :  s   € Üˆt‹9�q‰=Ò1˜TŸ_™_¨SÓ1Ð1rJ   c                óN   — d}	 |› d|› d| › �}|j                  |«      s|S |dz  }Œ#©Nr   Ú$r=  )rE  )rp   r°   rª  rñ  Únew_names        rH   rF  rF  >  s?   € Ø€EØ
Ø�V˜1˜U˜G 1 T FÐ+ˆØ�‰˜xÔ(ØˆOØ�‰
ˆð	 rJ   c                ó4   — d}	 |› d|› d| › �}||vr|S |dz  }Œrt  rP   )Úkeyr°   Ú
dictionaryrñ  Únew_keys        rH   r÷  r÷  G  s;   € Ø€EØ
Ø�F˜!˜E˜7 ! C 5Ð)ˆØ˜*Ñ$ØˆNØ�‰
ˆð	 rJ   c                  ó4   — e Zd Zdd„Zdd„Zd	d„Zd
d„Zdd„Zy)r˜  c                óœ   — || _         i | _        g | _        i | _        t	        «       | _        t        t        d¬«      «      | _        i | _	        y )NF)Úset_source_of_copy)
r±   r‘  r�  r’  r®  r”  r&   r'   Úcopy_strategyr“  )rÔ   rÎ   s     rH   r2  zCopyMachine.__init__Q  sD   € ØˆŒØ79ˆŒØ')ˆŒØ-/ˆŒÜ%(£UˆÔÜ)¬,È%Ô*PÓQˆÔð /1ˆÕrJ   c                óp   — |j                  «       D ]#  \  }}| j                  |«      | j                  |<   Œ% y rC   )r   Ú
copy_blockr‘  )rÔ   rr   rÞ   r£   s       rH   r™  zCopyMachine.copy_blocks\  s-   € Ø#Ÿ\™\ž^‰MˆF�EØ"&§/¡/°%Ó"8ˆD�K‰K˜Òñ ,rJ   c                óà  — i }| j                   }| j                  }|j                  «       D ]À  \  }}t        |t        «      r| j                  |«       Œ(| j                  |«      }|€Œ<t        j                  ||«       |j                  j                  ||<   t        |d«      r*| j                  j                  |j                  |«      «       t        |«      r|| j                  |<   Œ¼|||<   ŒÂ |S )NÚget_handle_mapping)r±   r“  r   r¢   r   Úcopy_dxf_classÚcopy_entityr   Úbindr¥   rÞ   ÚhasattrÚupdater‚  r   r’  )rÔ   r£   r‘  rÎ   r“  rÞ   rÕ   r  s           rH   r€  zCopyMachine.copy_block`  sÔ   € Ø')ˆØ�‰ˆØ×,Ñ,ˆà#Ÿk™kžm‰NˆF�FÜ˜&¤(Ô+Ø×#Ñ# FÔ+ØØ×$Ñ$ VÓ,ˆEØˆ}ØÜ�L‰L˜ Ô%Ø%*§Y¡Y×%5Ñ%5ˆN˜6Ñ"ä�vÐ3Ô4Ø×#Ñ#×*Ñ*¨6×+DÑ+DÀUÓ+KÔLä˜UÔ#Ø',�—‘˜VÒ$à!&��v’ð! ,ð" ˆrJ   c                óÌ   — 	 |j                  | j                  ¬«      S # t        j                  $ r2 | j                  j                  |j                  j                  «       Y y w xY w©N)r~  )Úcopyr~  r
   ÚDXFErrorr”  rÎ  r¥   rÞ   r  s     rH   r„  zCopyMachine.copy_entityx  sR   € ð	4Ø—;‘;¨T×-?Ñ-?�;Ó@Ð@øÜ�~‰~ò 	4Ø×Ñ× Ñ  §¡×!2Ñ!2Õ3Øð	4ús   ‚ žAA#Á"A#c                ón   — | j                   j                  |j                  | j                  ¬«      «       y r‰  )r�  ri  rŠ  r~  )rÔ   Úclss     rH   rƒ  zCopyMachine.copy_dxf_class  s%   € Ø�‰×Ñ˜CŸH™H°4×3EÑ3E˜HÓFÕGrJ   N)rÎ   r   rî   rï   )rr   rj  rî   rï   )r£   rk  rî   rk  rm  )r�  r   rî   rï   )rL   rM   rN   r2  r™  r€  r„  rƒ  rP   rJ   rH   r˜  r˜  P  s   „ ó	1ó9óó0ôHrJ   r˜  )rF   úIterable[str]rî   rï   )rj   ústr | os.PathLikerî   r   )F)ru   r   rv   rc   rj   rc   rî   rï   )rw   Úboolrî   Úint)ru   r   rv   rc   rj   rc   r~   r(   r   r†   r€   r†   rî   r#   )r’   rc   r“   zSequence[pathlib.Path]rî   zpathlib.Path)r°   r   r˜   zOptional[LoadFunction]r“   zIterable[pathlib.Path | str]rî   rï   )r£   r   r’   r�  rî   r   )r£   r   r’   r�  rî   rï   )rÉ   r;  r¶   r(   rî   r   )rÍ   r   rÎ   r   rÌ   rW  rî   rï   )rÑ   r   rÎ   r   rÌ   rW  rî   rï   )rD  r   rî   rï   )rz  rŽ  rî   rX  )ru   r   rî   rc   )rp   rc   rî   r�  )rp   rc   r°   rc   rî   rc   )rx  rc   r°   rc   rî   rc   )lrO   Ú
__future__r   Útypingr   r   r   r   Útyping_extensionsr   r	   rY   rŒ   r>  Úosr:   Úezdxf.lldxfr
   r   r   Úezdxf.lldxf.tagsr   Úezdxf.lldxf.validatorr   Úezdxf.documentr   Úezdxf.layoutsr   r   r   Úezdxf.entitiesr   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   Úezdxf.entities.copyr&   r'   Ú
ezdxf.mathr(   r)   Ú__all__Ú	getLoggerrD   ró   rÄ  rÀ  r?   r�  r@   Ú__annotations__rc   rA   rI   Ú	Exceptionr6   r7   r8   r9   rW   ÚEnumr3   r5   r*   rt   r+   r—   Útupler\   r,   r-   r»   r.   r[   r/   r0   r1   r2   r#  rÈ   r:  rH  rZ  ra  r4   rw  r•  r,  rÕ  rr  rF  r÷  r˜  rP   rJ   rH   Ú<module>r¤     s1  ðòå "ß 9Ó 9ß 1Û Û Û Û 	ã ß /Ñ /Ý !Ý )Ý "ß =Ñ =÷÷ ÷ ÷ ÷ ñ ÷* ;ß !ò€ð( 
ˆ×	Ñ	˜7Ó	#€Ø€Ú8Ð Ø€Ø€Ø$ i [°$Ð%6Ñ7€�	Ó 7Ø" C 5¨' >Ñ2€ˆiÓ 2ó
ô
	�	ô 	ô	˜)ô 	ô	�)ô 	ô	�)ô 	ô	�Iô 	ô�T—Y‘Yô ó.*ôjóB3ð ØØØñ8PØ	ð8Pð ð8Pð ð	8Pð
 ð8Pð ð8Pð ð8Pð ó8Póv'ðF '+Ù16³Ø"×.Ñ.ñF,Ø
ðF,ð $ðF,ð /ð	F,ð 
óF,ðT FKñ$Øð$Ø*;ð$àó$ðP FKñ6Øð6Ø'8ð6à	ó6ð BKõ  ðL +/Ø"×'Ñ'ð	Ø
ðà
ðð (ðð
 
óð6 +/Ø"×'Ñ'ð	Ø	ðà
ðð (ðð
 
óô4ˆxô ô:$�Xô $÷Nñ ô<�>ô <ó@?ô(8˜>ô (8ôV.�nô .ô 
7�Nô 
7÷Cñ CóL	÷a&ñ a&÷HU*ñ U*ópó2óó÷0Hò 0HrJ   