
    h                       S SK Jr  S SKJrJrJrJrJrJrJ	r	J
r
JrJrJr  S SKrS SKrS SKrS SKrS SKrS SK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  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 SK'J(r(J)r)  S SK*J+r+  S SK,J-r-  S SK.J/r/J0r0J1r1J2r2J3r3J4r4J5r5J6r6  S SK,J7r7  S SK8J9r9J:r:J;r;J<r<  S SK=J>r>  S SK?J@r@  S SKAJBrBJCrC  S SKDJErE  S SKFJGrG  S SKHJIrIJJrJ  S SKKJLrL  S SKMJNrN  S SKOJPrP  S SKQJRrR  S SKSJTrTJUrU  S SKVJWrW  S SKXJYrYJZrZ  S S KJ[r[J\r\  \R                  " S!5      r^\(       a:  S S"K_J`r`JaraJbrbJcrc  S S#KdJere  S S$K'Jfrf  S S%KgJhrh  S S&KiJjrj  S S'KOJkrkJlrlJmrmJnrnJoroJprpJqrqJrrrJsrs  S(rtS)ruS*rvS+rwS,rxS<S- jry " S. S/5      rz " S0 S1\R                  5      r|S2 r} " S3 S4\|5      r~ " S5 S6\|5      rS=S>S7 jjrS?S8 jrS@S9 jrSASBS: jjrSCS; jrg)D    )annotations)TYPE_CHECKINGTextIOBinaryIOIterableIteratorUnionCallablecastOptionalSequenceAnyN)datetimetimezone)chain)Auditor)GroupCollection)MaterialCollection)MLeaderStyleCollection)MLineStyleCollection)EntityDB)groupby)
Modelspace
Paperspace)Layouts)const)BLK_XREFBLK_EXTERNALDXF13DXF14DXF2000DXF2007DXF12DXF2013)loader)AbstractTagWriter	TagWriterBinaryTagWriterJSONTagWriter)EntityQuery)DimensionRenderer)AcDsDataSectionnew_acds_data_section)BlocksSection)ClassesSection)EntitySectionStoredSection)HeaderSection)ObjectsSection)TablesSection)guid)
tocodepage
toencoding)
juliandate)safe_stringMAX_STR_LEN)	messengermsgtypesezdxf)	DXFEntityLayerVPort
Dictionary)GenericLayoutType)Layout)Tags)DXFTag)	
LayerTableLinetypeTableTextstyleTableDimStyleTable
AppIDTableUCSTable	ViewTableViewportTableBlockRecordTablez&{00000000-0000-0000-0000-000000000000}z&0.0 @ 2000-01-01T00:00:00.000000+00:00CREATED_BY_EZDXFWRITTEN_BY_EZDXF
EZDXF_METAc                l    SSK Jn  U c  Un  [        U S5      nUS:  a  Un U $ ! [         a    Un  U $ f = f)Nr   )START_HANDLE      )ezdxf.tools.handlerS   int
ValueError)seedrS   vs      @/var/www/html/env/lib/python3.13/site-packages/ezdxf/document.py_validate_handle_seedr\   a   sM    /|bMq5D K  Ks   # 33c                     \ rS rSr\4S\S jjr\\4S]S jj5       rS rS r	S r
S rS rS	 rS
 rS rS rS rS rS r\S^S j5       r\R,                  S_S j5       r\S`S j5       r\S 5       r\SaS j5       r\R,                  SbS j5       rScS jrSdS jr\SeS j5       r\SfS j5       r\SgS j5       rShS jrSiS jr S r!S r"S r#  Sj       SkS! jjr$SjSlS" jjr%SmS# jr&SnSoS$ jjr'SpS% jr(SqS& jr)S\S' jr*S\S( jr+S) r,S* r-S+ r.S, r/SrS- jr0S. r1S/ r2SsStS0 jjr3S1 r4\S^S2 j5       r5\SuS3 j5       r6\SvS4 j5       r7\SwS5 j5       r8\SxS6 j5       r9\SyS7 j5       r:\SzS8 j5       r;\S{S9 j5       r<\S|S: j5       r=\S}S; j5       r>\S~S< j5       r?\SS= j5       r@\@R,                  SS> j5       r@SS? jrASSS@ jjrBSSSA jjrCSSB jrDSSC jrESSD jrFSE rGSF rH\SSG j5       rI\SSH j5       rJSSI jrKSSSJ jjrLSSSK jjrMSSL jrNSSM jrOSSN jrPSSSO jjrQ   S     SSP jjrRSSQ jrSSSSR jjrTSSSS jjrUSsST jrV S     SSU jjrW\X\Y-  4     SSV jjrZSSW jr[SSSX jjr\SS SY.SSZ jjjr]S[r^g )Drawingo   c                   [        5       U l        [        R                  " U 5      U l        UR	                  5       n[
        R                  R                  X"5      U l        U R                  [
        R                  ;  a$  [
        R                  " SU R                   S35      eS U l        SU l        SU l        S U l        S U l        S U l        S U l        S U l        S U l        S U l        S U l        S U l        / U l        S U l        S U l        S U l        S U l        S U l        SU l        [?        5       U l         [C        5       U l"        / U l#        [I        U R                  5      S:X  d   eg )NUnsupported DXF version "".Fcp1252Tr   )%r   entitydbr;   	Messengerupperr   acad_release_to_dxf_versionget_dxfversionversions_supported_by_newDXFVersionError
dxfversion_loaded_dxfversion
is_loadingencodingfilenamerootdictheaderclassestablesblocksentitiesobjectsacdsdatastored_sectionslayoutsgroups	materialsmleader_stylesmline_styles_acad_compatibleset_acad_incompatibility_reasonr+   _dimension_renderer_post_init_commandslen)selfrl   target_dxfversions      r[   __init__Drawing.__init__p   sO    
",,T2&,,. % A A E E!
 5#B#BB''*CDOOCTTV(WXX 26  %'+ %) &*'+%)%)'+'+ *.46 $'+-16:26 !%69e) $5#6  46  4==!Q&&&    c                V    U " U5      nUR                  5         UR                  5         U$ )zdCreate new drawing. Package users should use the factory function
:func:`ezdxf.new`. (internal API)
)_setup_create_ezdxf_metadata)clsrl   docs      r[   newDrawing.new   s'    
 *o

""$
r   c                   [         R                  " 5       U l        [        U 5      U l        [        U 5      U l        [        U 5      U l        [        U 5      U l
        [        U 5      U l        [        U 5      U l        U R                  R                  U l        U R                  R!                  U R                  5        ["        R$                  " U 5      U l        U R)                  5         g N)r2   r   rr   r/   rs   r4   rt   r.   ru   r0   rv   r3   rw   r-   rx   rq   setup_object_management_tablesr   setuprz   _finalize_setupr   s    r[   r   Drawing._setup   s    #'')%d+#D)#D)%d+%d+-d3--33DMMB}}T*r   c                   [        U 5      U l        [        U 5      U l        [	        U 5      U l        U R                  5         [        U 5      U l        U R                  5         U R                  5         U R                  5         g)z3Common setup tasks for new and loaded DXF drawings.N)r   r{   r   r|   r   r~   _create_required_table_entriesr   r}   _set_required_layer_attributes_setup_metadata_execute_post_init_commandsr   s    r[   r   Drawing._finalize_setup   sh    %d++D106 	++- 5T:++-((*r   c                <    U R                    H
  nU" 5         M     U ? g r   )r   )r   cmds     r[   r   #Drawing._execute_post_init_commands   s    ++CE ,$r   c                    U R                  5         U R                  5         U R                  5         U R                  5         U R	                  5         U R                  5         g r   )_create_required_vports_create_required_linetypes_create_required_layers_create_required_styles_create_required_appids_create_required_dimstylesr   s    r[   r   &Drawing._create_required_table_entries   sJ    $$&'')$$&$$&$$&'')r   c                J    U R                    H  nUR                  5         M     g r   )layersset_required_attributes)r   layers     r[   r   &Drawing._set_required_layer_attributes   s    [[E))+ !r   c                \    SU R                   ;  a  U R                   R                  S5        g g )N*Active)	viewportsr   r   s    r[   r   Drawing._create_required_vports   s%    DNN*NNy) +r   c                \    SU R                   ;  a  U R                   R                  S5        g g )NACADappidsr   r   s    r[   r   Drawing._create_required_appids   s#    $KKOOF# %r   c                ^    U R                   nS H  nX!;  d  M
  UR                  U5        M     g )N)ByBlockByLayer
Continuous)	linetypesr   )r   r   names      r[   r   "Drawing._create_required_linetypes   s'    NN	8D$d# 9r   c                \    SU R                   ;  a  U R                   R                  S5        g g NStandard)	dimstylesr   r   s    r[   r   "Drawing._create_required_dimstyles   s%    T^^+NNz* ,r   c                \    SU R                   ;  a  U R                   R                  S5        g g r   )stylesr   r   s    r[   r   Drawing._create_required_styles   s#    T[[(KKOOJ' )r   c                    U R                   nSU;  a  UR                  S5        SU;  a  UR                  SSS0S9  g SUR                  S5      R                  l        g )N0	Defpointsplotr   
dxfattribs)r   r   rh   dxfr   )r   r   s     r[   r   Drawing._create_required_layers   sS    fJJsOf$JJ{{J; 01FJJ{#'',r   c                n   U R                   U R                  S'   [        [        R                  " 5       5      U R                  S'   U R                  R                  S[        5      [        :X  a  U R                  5         U R                  R                  S[        5      [        :X  a  U R                  5         g g )N$ACADVER	$TDCREATE$FINGERPRINTGUID$VERSIONGUID)	rl   rr   r8   r   nowrh   
CONST_GUIDreset_fingerprint_guidreset_version_guidr   s    r[   r   Drawing._setup_metadata  sz    "&//J#-hlln#=K ;;??-z:jH'');;??>:6*D##% Er   c                    U R                   $ )zGet current DXF version.)ri   r   s    r[   rl   Drawing.dxfversion  s     r   c                L    U R                  U5      U l        XR                  S'   g)zSet current DXF version.r   N)_validate_dxf_versionri   rr   r   versions     r[   rl   r     s#      55g>")Jr   c                    U R                   $ r   )rm   r   s    r[   loaded_dxfversionDrawing.loaded_dxfversion  s    &&&r   c                F    U R                   [        :  a  S$ U R                  $ )zIReturns required output encoding for writing document to a text
streams.
zutf-8)rl   r"   ro   r   s    r[   output_encodingDrawing.output_encoding  s    
 //W4wG$--Gr   c                :    U R                   R                  SS5      $ )zGet and set the document/modelspace base units as enum, for more
information read this: :ref:`dxf units`. Requires DXF R2000 or newer.

	$INSUNITSr   )rr   rh   r   s    r[   unitsDrawing.units$  s     {{{A..r   c                    SUs=::  a  S:  a;  O  O8U R                   [        :  a  [        R                  S5        XR                  S'   g [        SU 35      e)Nr      z7Drawing units ($INSUNITS) are not exported for DXF R12.r   zInvalid units enum: )rl   r!   loggerwarningrr   rX   )r   	unit_enums     r[   r   r   ,  sK    	B(M (1KK$3I;?@@r   c                   UR                  5       n[        R                  R                  X5      nU[        R                  ;  a  [        R
                  " SU S35      eU[        :X  a9  U R                  [        :  a#  [        R                  SU R                   S35        U$ XR                  :  a7  [        R                  SU R                   S[        R                  U    S35        U$ )Nra   rb   zDowngrade from DXF z' to R12 may create an invalid DXF file.z to z can cause lost of features.)rf   r   rg   rh   versions_supported_by_saverk   r#   ri   r   r   acad_releaseinfor   s     r[   r   Drawing._validate_dxf_version7  s    --/3377I%:::''*CG9B(OPPe%')$*;*;)< =+ ,  '''KK%d&7&7%8%%g.//KM r   c                    U R                   (       d  [        R                  " S5      $ [        R                  " U R                   5      R                  5       $ )z.Returns the absolute filepath of the document..)rp   pathlibPathresolver   s    r[   get_abs_filepathDrawing.get_abs_filepathJ  s4    }}<<$$||DMM*2244r   c                @    SSK Jn  U" U5      nU R                  U5      $ )a-  Open an existing drawing. Package users should use the factory
function :func:`ezdxf.read`. To preserve possible binary data in
XRECORD entities use :code:`errors='surrogateescape'` as error handler
for the import stream.

Args:
     stream: text stream yielding text (unicode) strings by readline()

rU   )ascii_tags_loader)lldxf.taggerr   load)r   streamr   
tag_loaders       r[   readDrawing.readP  s      	4&v.
xx
##r   c                R    SSK Jn  U" U5      nU " 5       nUR                  U5        U$ )zyLoad DXF document from a DXF tag loader, in general an external
untrusted source.

Args:
    tag_loader: DXF tag loader

rU   )tag_compiler)r   r  _load)r   r   r  r   s       r[   r   Drawing.load`  s)     	/!*-
e		*
r   c                2    U " 5       nUR                  US9  U$ )z5Create new drawing from compiled tags. (internal API))tagger)r  )r   compiled_tagsr   s      r[   	from_tagsDrawing.from_tagsp  s     e			'
r   c                r    SU l         [        R                  " U5      nSU;   a  US	 U R                  U5        g )NTTHUMBNAILIMAGE)rn   r%   load_dxf_structure_load_section_dict)r   r  sectionss      r[   r  Drawing._loadw  s8    ,,V4x')*)r   c                   SU l         UR                  S/ 5      nU(       a  [        R                  " US   5      U l        O[        R
                  " [        S9U l        U R                  R                  S[        5      U l        U R                  U l        [        U R                  R                  SS5      5      U l
        U R                  R                  S[        U R                  R                  5      5      nU R                  R                  R                  [        U5      5        [         R"                  " X5        [%        XR                  S	S
5      5      U l        [)        XR                  SS
5      5      U l        U R-                  5         [/        XR                  SS
5      5      U l        [3        XR                  SS
5      5      U l        [7        XR                  SS
5      5      U l        [;        XR                  SS
5      5      U l        UR?                  5        H?  u  pEU[@        RB                  ;  d  M  U RD                  RG                  [I        U5      5        MA     U RK                  5         U RL                  [        :  a   [N        RQ                  S5        [        U l&        U RL                  [        :X  a  U R*                  RS                  5         U RL                  [T        [V        4;   a0  [N        RQ                  S5        [X        U l&        U R[                  5         U R8                  R\                  nUR^                  S:w  a#  [@        R`                  " S[        U5       S35      eX`l.        U R8                  Rc                  U R\                  5        [d        R                  " U 5      U l3        SU l         U Ri                  5         g
)z8Internal API to load a DXF document from a section dict.THEADERr   )rl   r   $DWGCODEPAGE	ANSI_1252	$HANDSEEDCLASSESNTABLESBLOCKSENTITIESOBJECTSACDSDATAzDXF version upgrade to DXF R12.z!DXF version upgrade to DXF R2000.
DICTIONARYzinvalid root dictionary entity  F)5rn   rh   r2   r   rr   r   r#   ri   rm   r7   ro   strrd   handlesresetr\   r%   load_and_bind_dxf_contentr/   rs   r4   rt   _create_required_block_recordsr.   ru   r0   rv   r3   rw   r,   rx   itemsr   MANAGED_SECTIONSry   appendr1   _2nd_loading_stagerl   r   r   create_table_handlesr   r    r!   create_all_arrow_blocksrq   DXFTYPEDXFStructureErrorr   r   rz   r   )r   r  header_entitiesrY   r   datarq   s          r[   r  Drawing._load_section_dict  s   &.ll8R&@',,_Q-?@DK (++u=DK;;??:u= #'"2"2 #4;;??>;#OP KKOOKT]]5J5J1KL##$9$$?@ 	((8 &,,y$/
 $D,,x*FG 	++- $D,,x*FG%,,z40
 &,,y$/

 (,,z40

 #..*JD5111$$++M$,?@ +
 	! ??U"KK9:#DO??e#KK,,.??uen,KK;<%DO((* <<((|+))1#h-B  ! 	33DMMB ||D)  r   c                    U R                   nUR                  5        H4  nUR                  U 5      nUc  M  U R                  R	                  U5        M6     g)zrLoad additional resources from entity database into DXF entities.

e.g. convert handles into DXFEntity() objects

N)rd   valuespost_load_hookr   r$  )r   dbentityr   s       r[   r%  Drawing._2nd_loading_stage  sH     ]]iikF ''-C((//4 "r   c                n    SSK Jn  UR                   H  nUR                  U R                  U5        M!     g)ay  For upgrading DXF R12/13/14 files to R2000, it is necessary to
create all used arrow blocks before saving the DXF file, else $HANDSEED
is not the next available handle, which is a problem for AutoCAD.

Create all known AutoCAD arrows to be on the safe side, because
references to arrow blocks can be in DIMSTYLE, DIMENSION override,
LEADER override and maybe other locations.

r   ARROWSN)ezdxf.render.arrowsr5  __acad__create_blockru   )r   r5  
arrow_names      r[   r'  Drawing.create_all_arrow_blocks  s)     	/ //JZ8 *r   c                    SU R                   ;  a  U R                   R                  S5        SU R                   ;  a  U R                   R                  S5        g g )Nz*Model_Spacez*Paper_Space)block_recordsr   r   s    r[   r!  &Drawing._create_required_block_records  sK    !3!33"">2!3!33"">2 4r   Nc                B    [        U5      U l        U R                  X#S9  g)a  Set :class:`Drawing` attribute :attr:`filename` to `filename` and
write drawing to the file system. Override file encoding by argument
`encoding`, handle with care, but this option allows you to create DXF
files for applications that handles file encoding different than
AutoCAD.

Args:
    filename: file name as string
    encoding: override default encoding as Python encoding string like ``'utf-8'``
    fmt: ``'asc'`` for ASCII DXF (default) or ``'bin'`` for Binary DXF

)ro   fmtN)r  rp   save)r   rp   ro   r?  s       r[   saveasDrawing.saveas  s    $ H		8	-r   c                z   Uc  U R                   nOUnUR                  S5      (       a"  [        R                  " U R                  SUSS9nO<UR                  S5      (       a  [        U R                  S5      nO[        SU S	35      e U R                  XBS
9  UR                  5         g! UR                  5         f = f)a  Write drawing to file-system by using the :attr:`filename` attribute
as filename. Override file encoding by argument `encoding`, handle with
care, but this option allows you to create DXF files for applications
that handle file encoding different from AutoCAD.

Args:
    encoding: override default encoding as Python encoding string like ``'utf-8'``
    fmt: ``'asc'`` for ASCII DXF (default) or ``'bin'`` for Binary DXF

Nascwt
dxfreplace)modero   errorsbinwbUnknown output format: ''.)r?  )r   
startswithioopenrp   rX   writeclose)r   ro   r?  encfps        r[   r@  Drawing.save  s      &&C C>>%  D3|B ^^E""dmmT*B7uB?@@	JJrJ#HHJBHHJs   B( (B:c                6    UR                  U R                  SS9$ )z:Encode string `s` with correct encoding and error handler.rF  )ro   rH  )encoder   )r   ss     r[   rV  Drawing.encode7  s    xx!5!5lxKKr   c                   U R                  5         U R                  nU[        :X  a&  [        U R                  R                  SS5      5      nOSnU[        :  a  U R                  R                  U5        U R                  5         UR                  S5      (       a  [        UUUS9nOLUR                  S5      (       a'  [        UUUU R                  S9nUR                  5         O[        SU S	35      eU R                  U5        g
)a  Write drawing as ASCII DXF to a text stream or as Binary DXF to a
binary stream. For DXF R2004 (AC1018) and prior open stream with
drawing :attr:`encoding` and :code:`mode='wt'`. For DXF R2007 (AC1021)
and later use :code:`encoding='utf-8'`, or better use the later added
:class:`Drawing` property :attr:`output_encoding` which returns the
correct encoding automatically. The correct and required error handler
is :code:`errors='dxfreplace'`!

If writing to a :class:`StringIO` stream, use :meth:`Drawing.encode` to
encode the result string from :meth:`StringIO.get_value`::

    binary = doc.encode(stream.get_value())

Args:
    stream: output text stream or binary stream
    fmt: "asc" for ASCII DXF (default) or "bin" for binary DXF

z	$HANDLINGr   TrD  )write_handlesrl   rI  )rZ  rl   ro   rK  rL  N)commit_pending_changesrl   r#   boolrr   rh   rs   add_required_classes
update_allrM  r'   r(   r   write_signaturerX   export_sections)r   r   r?  rl   r  	tagwriters         r[   rP  Drawing.write;  s    , 	##%__
4;;??;:;GGLL--j9>>%  !%%I
 ^^E""'%%--	I %%'7uB?@@Y'r   c                    [         R                  " 5       nU R                  U5        U R                  UR	                  5       5      n[
        R                  " UR                  SS5      5      $ )z3Returns DXF document as base64 encoded binary data.   
s   
)rN  StringIOrP  rV  getvaluebase64encodebytesreplace)r   r   binary_datas      r[   encode_base64Drawing.encode_base64o  sL    

6kk&//"34!!+"5"5eW"EFFr   c                `   UR                   nU R                  R                  U5        U[        :  a  U R                  R                  U5        U R
                  R                  U5        U R                  R                  U5        U R                  R                  U5        U[        :  a  U R                  R                  U5        U R                  R                  (       a  U R                  R                  U5        U R                   H  nUR                  U5        M     UR                  SS5        g)z#DXF export sections. (internal API)r   EOFN)rl   rr   
export_dxfr#   rs   rt   ru   rv   rw   rx   is_validry   
write_tag2)r   ra  rl   sections       r[   r`  Drawing.export_sectionsx  s    ))
y)LL##I.y)y)  +LL##I.==!!MM$$Y/++Gy) , 	Q&r   c                V    U R                   R                  [        R                  5        g r   )r;   	broadcastr<   COMMIT_PENDING_CHANGESr   s    r[   r[  Drawing.commit_pending_changes  s      !@!@Ar   c                   U R                   [        :  a%  U R                  R                  U R                   5        U R	                  5         U R                  5         U R                  5         U R                  5         U R                  5         g r   )	rl   r#   rs   r]  _create_appids_update_header_varsupdate_extentsupdate_limits_update_metadatar   s    r[   r^  Drawing.update_all  s`    ??U"LL--doo>  "r   c                   U R                  5       nUR                  R                  nUR                  R                  n[	        U5      (       a,  [	        U5      (       a  X R
                  S'   X0R
                  S'   U R                  5       nUR                  R                  U R
                  S'   UR                  R                  U R
                  S'   g )Nz$EXTMINz$EXTMAXz$PEXTMINz$PEXTMAX)
modelspacer   extminextmaxr\  rr   active_layout)r   mspr  r  r  s        r[   r{  Drawing.update_extents  s    oo<<DLL%+KK	"%+KK	"**,"/"3"3":":J"/"3"3":":Jr   c                \   U R                  5       nUR                  R                  U R                  S'   UR                  R                  U R                  S'   U R                  5       nUR                  R                  U R                  S'   UR                  R                  U R                  S'   g )Nz$LIMMINz$LIMMAXz$PLIMMINz$PLIMMAX)r  r   limminrr   limmaxr  )r   r  r  s      r[   r|  Drawing.update_limits  s|    oo!$I!$I**,"/"3"3":":J"/"3"3":":Jr   c                   SSK Jn  U R                  R                  U R                  R                  SS 5      5      nUb  UR                  5       S:w  a  SnSU R                  ;   a0  U R                  R                  S5      R                  R                  nO?SU R                  ;   a/  U R                  R                  S5      R                  R                  nX0R                  S'   UR                  U R                  S5      U R                  S'   g )	Nr   )acad_maint_verz
$CMATERIALMATERIALr   r   Global$ACADMAINTVER)
ezdxf.lldxf.constr  rd   rh   rr   dxftyper|   r   handlerl   )r   r  materialr  s       r[   rz  Drawing._update_header_vars  s    4 ==$$T[[__\4%HIx//1Z?FDNN*++I6::AAT^^+++H599@@(.KK%'5'9'9$//1'MO$r   c           	     f   U R                  5         [        R                  R                  (       aw  [	        [        SSSSS5      5      nXR                  S'   XR                  S'   XR                  S'   XR                  S'   [        U R                  S'   [        U R                  S	'   O=[
        R                  " 5       n[	        U5      U R                  S'   U R                  5         [        U R                  R                  5      U R                  S
'   [        U R                  5      U R                  S'   g )Ni  rU   r   r   z
$TDUCREATEz	$TDUPDATEz
$TDUUPDATEr   r   r  r  )_update_ezdxf_metadatar=   options!write_fixed_meta_data_for_testingr8   r   rr   r   r   r   r  rd   r  r6   ro   )r   
fixed_dater   s      r[   r}  Drawing._update_metadata  s    ##%==::#HT1aA$>?J'1KK$(2KK%'1KK$(2KK%*4DKK'.8DKK*+,,.C'1#DKK$##%#&t}}'<'<#=K &0&?N#r   c                V    U R                   [        ::  a  [        U 5      $ [        U 5      $ )zReturns the *ezdxf* :class:`ezdxf.document.MetaData` object, which
manages  *ezdxf* and custom metadata in DXF files.
For more information see:  :ref:`ezdxf_metadata`.

)rl   r#   R12MetaDataR2000MetaDatar   s    r[   ezdxf_metadataDrawing.ezdxf_metadata  s%     %)OOu$<{4 U-PTBUUr   c                F    U R                  5       n[        5       U[        '   g r   )r  ezdxf_marker_stringrO   r   
ezdxf_metas     r[   r   Drawing._create_ezdxf_metadata      ((*
':'<
#$r   c                F    U R                  5       n[        5       U[        '   g r   )r  r  rP   r  s     r[   r  Drawing._update_ezdxf_metadata  r  r   c                `    XR                   ;  a  U R                   R                  USU05        g g )Nflagsr   )r   r   r  s      r[   _create_appid_if_not_exist"Drawing._create_appid_if_not_exist  s(    {{"KKOOD7E"23 #r   c                L    U R                  SS5        U R                  SS5        g )NHATCHBACKGROUNDCOLORr   EZDXF)r  r   s    r[   ry  Drawing._create_appids  s#    ''(>B''3r   c                V    [         R                  R                  U R                  S5      $ )z?Returns the AutoCAD release abbreviation like "R12" or "R2000".unknown)r   r   rh   rl   r   s    r[   r   Drawing.acad_release  s!     !!%%dooyAAr   c                .    U R                   R                  $ r   )rt   r   r   s    r[   r   Drawing.layers      {{!!!r   c                .    U R                   R                  $ r   )rt   r   r   s    r[   r   Drawing.linetypes      {{$$$r   c                .    U R                   R                  $ r   )rt   r   r   s    r[   r   Drawing.styles  r  r   c                .    U R                   R                  $ r   )rt   r   r   s    r[   r   Drawing.dimstyles  r  r   c                .    U R                   R                  $ r   )rt   ucsr   s    r[   r  Drawing.ucs  s    {{r   c                .    U R                   R                  $ r   )rt   r   r   s    r[   r   Drawing.appids  r  r   c                .    U R                   R                  $ r   )rt   viewsr   s    r[   r  Drawing.views  s    {{   r   c                .    U R                   R                  $ r   )rt   r<  r   s    r[   r<  Drawing.block_records  s    {{(((r   c                .    U R                   R                  $ r   )rt   r   r   s    r[   r   Drawing.viewports  r  r   c                     U R                   S   $ )NACAD_PLOTSTYLENAME)rq   r   s    r[   
plotstylesDrawing.plotstyles  s    }}122r   c                    U R                   $ r   r   r   s    r[   dimension_rendererDrawing.dimension_renderer  s    '''r   c                    Xl         g)zT
Set your own dimension line renderer if needed.

see also: ezdxf.render.dimension

Nr  )r   renderers     r[   r  r    s
     $, r   c                6    U R                   R                  5       $ )z|Returns the modelspace layout, displayed as "Model" tab in CAD
applications, defined by block record named "\*Model_Space".
)rz   r  r   s    r[   r  Drawing.modelspace  s     ||&&((r   c                8    U R                   R                  U5      $ )zReturns paperspace layout `name` or the first layout in tab-order
if no name is given.

Args:
    name: paperspace name or empty string for the first paperspace in
        tab-order

Raises:
    KeyError: layout `name` does not exist

)rz   rh   r   r   s     r[   layoutDrawing.layout#  s     ||%%r   c                    U(       a=  U R                   R                  U5      n[        U[        5      (       a  U$ [	        S5      eU R                  5       $ )zReturns paperspace layout `name` or the active paperspace if no
name is given.

Args:
    name: paperspace name or empty string for the active paperspace

Raises:
    KeyError: if the modelspace was acquired or layout `name` does not exist

z2use method modelspace() to acquire the modelspace.)rz   rh   
isinstancer   KeyErrorr  )r   r   psps      r[   
paperspaceDrawing.paperspace1  sH     ,,""4(C#z**
OPP%%''r   c                6    U R                   R                  5       $ )zTReturns the active paperspace layout, defined by block record name
"\*Paper_Space".
)rz   r  r   s    r[   r  Drawing.active_layoutD  s     ||))++r   c                H    [        U R                  R                  5       5      $ )z,Returns all layout names in arbitrary order.)listrz   namesr   s    r[   layout_namesDrawing.layout_namesJ  s    DLL&&())r   c                H    [        U R                  R                  5       5      $ )zHReturns all layout names in tab-order, "Model" is always the first name.)r  rz   names_in_taborderr   s    r[   layout_names_in_taborder Drawing.layout_names_in_taborderN  s    DLL22455r   c                2    [        5       U R                  S'   g)zReset fingerprint GUID.r   Nr5   rr   r   s    r[   r   Drawing.reset_fingerprint_guidR  s    *.&&'r   c                2    [        5       U R                  S'   g)zReset version GUID.r   Nr  r   s    r[   r   Drawing.reset_version_guidV  s    &*fN#r   c                    U R                   $ )zPReturns ``True`` if the current state of the document is compatible to
AutoCAD.
)r   r   s    r[   is_acad_compatibleDrawing.is_acad_compatibleZ  s    
 $$$r   c                ,    [        U R                  5      $ )zIReturns a list of reasons why this document is not compatible to AutoCAD.)r  r   r   s    r[   acad_incompatibility_reasons$Drawing.acad_incompatibility_reasonsa  s     D5566r   c                    SU l         XR                  ;  a5  U R                  R                  U5        [        R	                  SU S35        gg)zLAdd a reason why this document is not compatible to AutoCAD.
(internal API)
Fz+DXF document is not compatible to AutoCAD! r   N)r   r   addr   r   )r   msgs     r[    add_acad_incompatibility_message(Drawing.add_acad_incompatibility_messagef  sG     !&777--11#6NNHQOP 8r   c                6    [        U R                  5       U5      $ )zEntity query over all layouts and blocks, excluding the OBJECTS section and
the resource tables of the TABLES section.

Args:
    query: query string

.. seealso::

    :ref:`entity query string` and :ref:`entity queries`

)r*   chain_layouts_and_blocks)r   querys     r[   r  Drawing.queryo  s     488:EBBr   c                6    [        U R                  5       X5      $ )a  Groups DXF entities of all layouts and blocks (excluding the
OBJECTS section) by a DXF attribute or a key function.

Args:
    dxfattrib: grouping DXF attribute like "layer"
    key: key function, which accepts a :class:`DXFEntity` as argument
        and returns a hashable grouping key or ``None`` to ignore
        this entity.

.. seealso::

    :func:`~ezdxf.groupby.groupby` documentation

)r   r  )r   	dxfattribkeys      r[   r   Drawing.groupby}  s     t446	GGr   c                `    [        U R                  5       5      n[        R                  " U5      $ )znChain entity spaces of all layouts and blocks. Yields an iterator
for all entities in all layouts and blocks.
)r  layouts_and_blocksr   from_iterable)r   rz   s     r[   r   Drawing.chain_layouts_and_blocks  s(     t..01""7++r   c                ,    [        U R                  5      $ )zOIterate over all layouts (modelspace and paperspace) and all block definitions.)iterru   r   s    r[   r  Drawing.layouts_and_blocks  s    DKK  r   c                    XR                   ;  a  [        R                  " SU S35      eU R                   R                  U5        g)zDelete paper space layout `name` and all entities owned by this layout.
Available only for DXF R2000 or later, DXF R12 supports only one
paperspace, and it can't be deleted.
Layout 'z' does not exist.N)rz   r   DXFValueErrordeleter  s     r[   delete_layoutDrawing.delete_layout  s;    
 ||#%%6G&HIILL%r   c                    XR                   ;   a  [        R                  " SU S35      eU R                   R                  X5      $ )a  Create a new paperspace layout `name`. Returns a :class:`~ezdxf.layouts.Paperspace`
object. DXF R12 (AC1009) supports only one paperspace layout, only the active
paperspace layout is saved, other layouts are dismissed.

Args:
    name: unique layout name
    dxfattribs: additional DXF attributes for the
        :class:`~ezdxf.entities.layout.DXFLayout` entity

Raises:
    DXFValueError: paperspace layout `name` already exist

r	  z' already exists.)rz   r   r
  r   )r   r   r   s      r[   
new_layoutDrawing.new_layout  s>     <<%%6G&HII<<##D55r   c                B   SSK Jn  U R                  S:X  a  [        R                  " S5      e XB   u  pVnU(       d  Xvpv U R                  U5      nUR                  Xg4SUS9  U$ ! [
         a    [        SU 35      ef = f! [
         a    U R                  U5      n NMf = f)a  Creates a new paperspace layout if `name` does not exist or reset the
existing layout.  This method requires DXF R2000 or newer.
The paper format name `fmt` defines one of the following paper sizes,
measures in landscape orientation:

=========== ======= ======= =======
Name        Units   Width   Height
=========== ======= ======= =======
ISO A0      mm      1189    841
ISO A1      mm      841     594
ISO A2      mm      594     420
ISO A3      mm      420     297
ISO A4      mm      297     210
ANSI A      inch    11      8.5
ANSI B      inch    17      11
ANSI C      inch    22      17
ANSI D      inch    34      22
ANSI E      inch    44      34
ARCH C      inch    24      18
ARCH D      inch    36      24
ARCH E      inch    48      36
ARCH E1     inch    42      30
Letter      inch    11      8.5
Legal       inch    14      8.5
=========== ======= ======= =======

The layout uses the associated units of the paper format as drawing
units, has no margins or offset defined and the scale of the paperspace
layout is 1:1.

Args:
    name: paperspace layout name
    fmt: paper format
    landscape: ``True`` for landscape orientation, ``False`` for portrait
        orientation

r   )
PAGE_SIZESR12z$method call no supported for DXF R12zunknown paper format: )r   r   r   r   )sizemarginsr   )
ezdxf.tools.standardsr  r   r   rk   r  rX   r  r  
page_setup)	r   r   r?  	landscaper  r   widthheightr  s	            r[   r  Drawing.page_setup  s    V 	5%''(NOO	=#-? E& "6	(//$'C 	UO\O
  	=5cU;<<	=  	(//$'C	(s   A$ B  $A= BBc                    SSK Jn  UR                  U5      (       d  UR                  U5      (       a  UR	                  U R
                  U5        gXR
                  ;  a  [        R                  " SU S35      eg)zFor standard AutoCAD and ezdxf arrows create block definitions if
required, otherwise check if block `name` exist. (internal API)

r   r4  zArrow block "z" does not exist.N)r6  r5  is_acad_arrowis_ezdxf_arrowr8  ru   r   r
  )r   r   r5  s      r[   acquire_arrowDrawing.acquire_arrow  sf    
 	/%%)>)>t)D)DT2$%%dV;L&MNN %r   c                    SU R                   ;  a  U R                  R                  SSSS9  Uc  UnU R                  R                  XU5      $ )a#  Add an image definition to the objects section.

Add an :class:`~ezdxf.entities.image.ImageDef` entity to the drawing
(objects section). `filename` is the image file name as relative or
absolute path and `size_in_pixel` is the image size in pixel as (x, y)
tuple. To avoid dependencies to external packages, `ezdxf` can not
determine the image size by itself. Returns a
:class:`~ezdxf.entities.image.ImageDef` entity which is needed to
create an image reference. `name` is the internal image name, if set to
``None``, name is auto-generated.

Absolute image paths works best for AutoCAD but not perfect, you
have to update external references manually in AutoCAD, which is not
possible in TrueView. If the drawing units differ from 1 meter, you
also have to use: :meth:`set_raster_variables`.

Args:
    filename: image file name (absolute path works best for AutoCAD)
    size_in_pixel: image size in pixel as (x, y) tuple
    name: image name for internal use, None for using filename as name
        (best for AutoCAD)

.. seealso::

    :ref:`tut_image`

ACAD_IMAGE_VARSr   rU   mframequalityr   )rq   rw   set_raster_variablesadd_image_def)r   rp   size_in_pixelr   s       r[   r(  Drawing.add_image_def  sJ    8 DMM1LL--Aq-L<D||))(4HHr   c                8    U R                   R                  XUS9  g)aG  Set raster variables.

Args:
    frame: 0 = do not show image frame; 1 = show image frame
    quality: 0 = draft; 1 = high
    units: units for inserting images. This defines the real world unit
        for one drawing unit for the purpose of inserting and scaling
        images with an associated resolution.

        ===== ===========================
        mm    Millimeter
        cm    Centimeter
        m     Meter (ezdxf default)
        km    Kilometer
        in    Inch
        ft    Foot
        yd    Yard
        mi    Mile
        ===== ===========================

r$  N)rw   r'  )r   r%  r&  r   s       r[   r'  Drawing.set_raster_variables#  s    , 	))e)Tr   c                    U R                   R                  US9  U R                  R                  S5      nUR	                  S[        U5      5        g)z\Set wipeout variables.

Args:
    frame: 0 = do not show image frame; 1 = show image frame

)r%  AcDbVariableDictionaryWIPEOUTFRAMEN)rw   set_wipeout_variablesrq   get_required_dictset_or_add_dict_varr  )r   r%  var_dicts      r[   r0  Drawing.set_wipeout_variables;  sB     	***7==223KL$$^SZ@r   c                P    US:X  a  USS nU R                   R                  XU5      $ )a!  Add an :class:`~ezdxf.entities.underlay.UnderlayDef` entity to the drawing
(OBJECTS section). The `filename` is the underlay file name as relative or
absolute path and `fmt` as string (pdf, dwf, dgn).
The underlay definition is required to create an underlay reference.

Args:
    filename: underlay file name
    fmt: file format as string "pdf"|"dwf"|"dgn" or "ext"
        for getting file format from filename extension
    name: pdf format = page number to display; dgn format = "default"; dwf: ????

.. seealso::

    :ref:`tut_underlay`

extN)rw   add_underlay_def)r   rp   r?  r   s       r[   r8  Drawing.add_underlay_defF  s-    & %<23-C||,,XDAAr   c                <    U R                   R                  X#US.S9  g)zAdd an external reference (xref) definition to the blocks section.

Args:
    filename: external reference filename
    name: name of the xref block
    flags: block flags

)r  	xref_path)r   r   N)ru   r   )r   rp   r   r  s       r[   add_xref_defDrawing.add_xref_def]  s     	TH.UVr   c                <    [        U 5      nUR                  5         U$ )a  Checks document integrity and fixes all fixable problems, not
fixable problems are stored in :attr:`Auditor.errors`.

If you are messing around with internal structures, call this method
before saving to be sure to export valid DXF documents, but be aware
this is a long-running task.

)r   run)r   auditors     r[   auditDrawing.auditj  s     $-r   c                   U R                  5       nU(       aZ  UR                  5         UR                  5         U R                  (       d)  [	        S5        U R
                   H  n[	        U5        M     [        UR                  5      S:H  $ )a  Simple way to run an audit process. Fixes all fixable problems,
return ``False`` if not fixable errors occurs. Prints a report of resolved and
unrecoverable errors, if requested.

Args:
    print_report: print report to stdout

Returns: ``False`` if unrecoverable errors exist

z'DXF document is not AutoCAD compatible:r   )rA  print_fixed_errorsprint_error_reportr  printr  r   rH  )r   print_reportr@  r  s       r[   validateDrawing.validatew  sg     **,&&(&&(**?@<<C#J =7>>"a''r   r   c               @   U R                   R                  S5        [        U=(       d    0 5      n[        SU R                   R	                  SUS95      nX$R
                  l        XR
                  l        UR                  5         U R                  R                  5         U$ )a  Set initial view/zoom location for the modelspace, this replaces
the current "\*Active" viewport configuration
(:class:`~ezdxf.entities.VPort`) and reset the coordinate system to the
:ref:`WCS`.

Args:
     height: modelspace area to view
     center: modelspace location to view in the center of the CAD
        application window.
     dxfattribs: additional DXF attributes for the VPORT entity

r   r@   r   )
r   delete_configdictr   r   r   centerr  	reset_wcsrr   )r   r  rM  r   vports        r[   set_modelspace_vportDrawing.set_modelspace_vport  sx     	$$Y/**+
Wdnn00z0RS!		!		r   )r   r   r   ri   rm   r   rx   ru   rs   rl   ro   rv   rd   rp   r{   rr   rn   rz   r|   r;   r}   r~   rw   rq   ry   rt   returnNone)rl   r  rS  r^   )rS  r  )r   r  rS  rT  )rS  Optional[str])rS  rW   )r   rW   rS  rT  )r   r  rS  r  )rS  zpathlib.Path)r   r   rS  r^   )r   Iterable[DXFTag]rS  r^   )r  rV  rS  r^   )r  rV  rS  rT  )r  zloader.SectionDictrS  rT  )NrD  )rp   zUnion[os.PathLike, str]ro   rU  r?  r  rS  rT  )ro   rU  r?  r  rS  rT  )rW  r  rS  bytes)rD  )r   zUnion[TextIO, BinaryIO]r?  r  rS  rT  )rS  rW  )ra  r&   rS  rT  )rS  MetaData)r   )r   r  r  rW   rS  rT  )rS  rF   )rS  rG   )rS  rH   )rS  rI   )rS  rK   )rS  rJ   )rS  rL   )rS  rN   )rS  rM   )rS  rA   )rS  r+   )r  r+   rS  rT  )rS  r    )r   r  rS  rC   )r   r  rS  r   )rS  r   )rS  zIterable[str])rS  r\  )rS  	list[str])r  r  )*)r  r  rS  r*   )rZ  NrS  rL  )rS  zIterator[DXFEntity])rS  zIterator[GenericLayoutType])r   r  rS  rT  r   )Layout1zISO A3T)r   r  r?  r  rS  r   r   r  )rp   r  r)  ztuple[int, int])r   rU   r#  )r%  rW   r&  rW   r   r  )r6  N)rp   r  r?  r  r   rU  )rp   r  r   r  r  rW   )rS  r   T))r   r   )rS  r@   )___name__
__module____qualname____firstlineno__r$   r   classmethodr   r   r   r   r   r   r   r   r   r   r   r   r   propertyrl   setterr   r   r   r   r   r   r   r  r  r  r%  r'  r!  rA  r@  rV  rP  rk  r`  r[  r^  r{  r|  rz  r}  r  r   r  r  ry  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  r  r  r  r  r  r(  r'  r0  r8  r   r   r<  rA  rH  rP  __static_attributes__ r   r[   r^   r^   o   s   ") ;'z #*  + %
*,*$$+(1&     * *
 ' ' H H / / \\A A&5 $ $    *Zx593 #'	.).  . 	.
 
.*"HL2(hG'$B 
;;N@"V==44 B B " " % % " " % %   " " ! ! ) ) % % 3 3 ( ( , ,)&(&,*61- % % 7 7QCH",!&6* 	== =
 
=~
O IDU0	A FJBB"%B5BB0 6>5LWW#&W/2W(*  r   r^   c                      \ rS rSrSr\R                  SS j5       rSSS jjr\R                  SS j5       r	\R                  SS j5       r
\R                  SS j5       rSS jrS	rg
)rX  i  zvManage ezdxf meta-data by dict-like interface. Values are limited to
strings with a maximum length of 254 characters.
c                    g)zPReturns the value for self[`key`].

Raises:
     KeyError: `key` does not exist
Nri  r   r  s     r[   __getitem__MetaData.__getitem__       	r   c                f     U R                  U5      $ ! [         a    [        U[        5      s $ f = f)zBReturns the value for `key`. Returns `default` if `key` not exist.)rm  r  r9   r:   )r   r  defaults      r[   rh   MetaData.get  s4    	5##C(( 	5w44	5s    00c                    g)zSet self[`key`] to `value`.Nri  r   r  values      r[   __setitem__MetaData.__setitem__       	r   c                    g)zADelete self[`key`].

Raises:
     KeyError: `key` does not exist
Nri  rl  s     r[   __delitem__MetaData.__delitem__  ro  r   c                    g)zReturns `key` ``in`` self.Nri  rl  s     r[   __contains__MetaData.__contains__  rx  r   c                H     U R                  U5        g! [         a     gf = f)zARemove `key`, does **not** raise an exception if `key` not exist.N)rz  r  rl  s     r[   discardMetaData.discard  s'    	S! 		s    
!!ri  Nr  r  rS  r  rY  )r  r  rq  r  rS  r  r  r  ru  r  rS  rT  r  r  rS  rT  r  r  rS  r\  )ra  rb  rc  rd  __doc__abcabstractmethodrm  rh   rv  rz  r}  r  rh  ri  r   r[   rX  rX    sy     	 5 	  	  	 r   rX  c                     [         R                  R                  (       a  [        $ [        R
                  " [        R                  S9n [         R                  S-   U R                  5       -   $ )N)tzz @ )
r=   r  r  CONST_MARKER_STRINGr   r   r   utc__version__	isoformat)r   s    r[   r  r    sC    }}66""llhll+  5(3==?::r   c                  ^    \ rS rSrSrSS jrSS jrSS jrSS jrSS jr	SS jr
SS	 jrS
rg)r  i  zsManage ezdxf meta data for DXF version R12 as XDATA of layer "0".

Layer "0" is mandatory and can not be deleted.

c                    UR                  5       R                  R                  U l        U R	                  5       U l        g r   )r  block_recordblock
_msp_blockr  _datar   r   s     r[   r   R12MetaData.__init__  s)    ..*77==ZZ\
r   c                <    [        U[        5      U R                  ;   $ r   r9   r:   r  rl  s     r[   r}  R12MetaData.__contains__      3,

::r   c                <    U R                   [        U[        5         $ r   )r  r9   r:   rl  s     r[   rm  R12MetaData.__getitem__  s    zz+c;788r   c                p    [        U[        5      U R                  [        U5      '   U R                  5         g r   )r9   r:   r  _commitrt  s      r[   rv  R12MetaData.__setitem__  s%    '25+'F

;s#$r   c                Z    U R                   [        U[        5      	 U R                  5         g r   )r  r9   r:   r  rl  s     r[   rz  R12MetaData.__delitem__  s    JJ{345r   c                    / nU R                   R                  5        H=  u  p#UR                  S[        U5      45        UR                  S[        U5      45        M?     U R                  R                  SU5        g )Ni  r  )r  r"  r$  r  r  	set_xdata)r   tagsr  ru  s       r[   r  R12MetaData._commit  s`    ****,JCKKs3x()KKs5z*+ - 	!!'40r   c                   [        5       nU R                  R                  S5      (       a]  U R                  R                  S5      nSn[	        U5      S-
  nX4:  a-  X#   R
                  nX#S-      R
                  X'   US-  nX4:  a  M-  U$ )Nr  r   rU      )rL  r  	has_xdata	get_xdatar   ru  )r   r+  xdataindexcountr   s         r[   r  R12MetaData._load  s    v??$$W--OO--g6EEJNE-|))"19-33

 - r   )r  r  Nr   r^   r  r  r  r  rR  r]  )ra  rb  rc  rd  r  r   r}  rm  rv  rz  r  r  rh  ri  r   r[   r  r    s*    "
;91
r   r  c                  J    \ rS rSrSrS
S jrSS jrSS jrSS jrSS jr	Sr
g	)r  i
  zSManage ezdxf metadata for DXF version R2000+ as DICTIONARY object in
the rootdict.
c                J    UR                   R                  [        SS9U l        g )NT)
hard_owned)rq   r1  rQ   r  r  s     r[   r   R2000MetaData.__init__  s#    !$!?!?4 "@ "

r   c                <    [        U[        5      U R                  ;   $ r   r  rl  s     r[   r}  R2000MetaData.__contains__  r  r   c                t    U R                   [        U[        5         nUR                  R	                  SS5      $ )Nru  rZ  )r  r9   r:   r   rh   )r   r  rZ   s      r[   rm  R2000MetaData.__getitem__  s,    JJ{345uuyy"%%r   c                t    U R                   R                  [        U[        5      [        U[        5      5        g r   )r  r2  r9   r:   rt  s      r[   rv  R2000MetaData.__setitem__  s'    

&&[);uk+J	
r   c                V    U R                   R                  [        U[        5      5        g r   )r  remover9   r:   rl  s     r[   rz  R2000MetaData.__delitem__   s    

+c;78r   )r  Nr  r  r  r  r  )ra  rb  rc  rd  r  r   r}  rm  rv  rz  rh  ri  r   r[   r  r  
  s     

;&

9r   r  c                
  ^^^^ SSK Jn  SSKJm  S=S>U4S jjjnS?S@UU4S jjjnSASBU4S jjjnSAS@UU4S jjjnU R                  mU R
                  n	U	c  U R                  n	/ mTR                  S	U R                   S
35        TR                  SU 35        XR                  :w  aF  SU	 3n
[        R                  R                  U	S5      nU(       a	  U
SU S3-  n
TR                  U
5        TR                  SU R                   35        TR                  SU R                   35        T(       a$  TR                  STR                  SS5       35        TR                  STR                  SS5       35        TR                  SU R                   35        TR                  S5        TR                  U R                  5        Vs/ s H	  nSU S3PM     sn5        TR                  SS5      (       a  SOSnT(       a  TR                  SU 35        TR                  SU" U R                  5       35        U" S 5        U" S!5        U" S"5        U" S#5        TR                  U" S$S%95        TR                  U" S&S%95        TR                    H  u  pTR                  S'U S(U S
35        M     U R#                  5       n[$        U;   a(  TR                  S)UR                  [$        5       35        OT(       a  TR                  S*5        [&        U;   a(  TR                  S+UR                  [&        5       35        OT(       a  TR                  S,5        U(       Ga  TR                  S-5        U" U R(                  S.5        U" U R*                  S/5        U" U R,                  S05        U" U R.                  S15        U" U R0                  S25        U" U R2                  S35        U" U R4                  S45        U" U R6                  S55        U" U R8                  S65        U R                  [:        :  a  U" [=        U R>                  5      S7S8S99  TR                  S:[A        U RC                  5       5       35        T(       a%  TR                  U" U RC                  5       5      5        TR                  S;[A        U RD                  5       35        T(       a!  TR                  U" U RD                  5      5        [G        U 5      n[A        U5      (       a;  TR                  S<[A        U5       35        T(       a  TR                  U" U5      5        T$ s  snf )CNr   )	unit_name)Counterc              3     >#    T" 5       nU  H  nX#R                  5       ==   S-  ss'   M     [        UR                  5       5       H  nU U SX$    S3v   M     g 7f)NrU    ())r  sortedkeys)rv   indentcounterer   r  s        r[   r  info.<locals>.count(  sY     "9AIIK A%  7<<>*DHTF"W]O155 +s   AAc           	       > SnTR                  U SU S[        U 5       35        T(       a  US:X  aj  / nU  Ha  nUR                  R                  nUS:X  a-  UR                  U SUR                  R                   S35        ML  UR                  U U 35        Mc     O)U  Vs/ s H  oS UR                  R                   3PM     nnUR                  5         TR                  U5        g g s  snf )N  r  z
 entries: STYLErZ  z*shape-file: "")r$  r   r   r   fontsortextend)tabler   	containerr  r  entryr+  verboses         r[   append_containerinfo.<locals>.append_container/  s    tfAi[
3u:,?@w#%"E 99>>Drzx~eiinn=MQ%OPxv%67 # CHH%8EIINN#34%HJJLKK  Is   !#C)rZ  c              3  p   >#    [        S5       H"  nU  US-    3nUT;   d  M  U U STU    3v   M$     g 7f)N   rU   =)range)kindr  ir   rr   s       r[   	user_varsinfo.<locals>.user_vars@  sE     qAVAaC5>Dv~at~66 s   66c           	     r   > TR                  U U  STR                  U S5      R                  5        35        g )Nz: <undefined>)r$  rh   strip)r   r  r+  rr   s     r[   append_header_varinfo.<locals>.append_header_varF  s3    vhtfBvzz$'F'L'L'N&OPQr   zFilename: "r  zFormat: z-Loaded content was upgraded from DXF Version r  r  z	Release: zDXF Version: zMaintenance Version: r  r  z
Codepage: r  r  z
Encoding: zLayouts:z  ''z$MEASUREMENTMetricImperialzUnit system: zModelspace units: z$LASTSAVEDBYr  r   r   z$USERI)r  z$USERRzCustom property "z": "zCreated by ezdxf: z'File was not created by ezdxf >= 0.16.4zWritten by ezdxf: z'File was not written by ezdxf >= 0.16.4zContent stats:LAYERLTYPEr  DIMSTYLEAPPIDUCSVIEWVPORTBLOCK_RECORDCLASSrr  )r  zEntities in modelspace: zEntities in OBJECTS section: zUnknown/unsupported entities: )r  )rS  Iterator[str])r  r_  rY  )r  r  rS  r  )$ezdxf.unitsr  collectionsr  rr   r   rl   r$  rp   r   r   rh   r   r  r  r   custom_varsr  rO   rP   r   r   r   r   r   r  r  r   r<  r#   r  rs   r   r  rw   _get_unknown_entities)r   r  contentr?  r  r  r  r  r  loaded_dxf_versionr  releaser   measurementru  r  unknown_entitiesr  r+  rr   s    `               @@@r[   r   r   $  s]   %#6 6 "7 7R R ZZF..! ^^DKK+cll^1-.KK(3% !^^+=>P=QR$$(();R@Ry?"CCKK)C,,-./KK-/01#FJJ$N#OP	
 	KK*VZZDEFGKK*S00123KK
KK3+G+G+IJ+I43tfA+IJK$jj;;(KmK=12(399)=(>?@.)+&,-.)I8,-I8,-!--KDKK+D6eWA>? . '')N>)(););<L)M(NOP	=>>)(););<L)M(NOP	=>$%W-0W-
3W-%(F+0**N;>>E!T#++.9M.s3>>3C/D.EFGKKcnn./03C4D3EFGKKckk*+05  KK8=M9N8OPQE"234Ke Ks   U c                    SSK JnJnJn  / nU R                  R                  5        H(  n[        XQX#45      (       d  M  UR                  U5        M*     U$ )Nr   )DXFTagStorageACADProxyEntity	OLE2Frame)ezdxf.entitiesr  r  r  rd   r.  r  r$  )r   r  r  r  r+  r1  s         r[   r  r    sG    HHD,,%%'foIJJKK ( Kr   c                    U R                   nU[        :w  a  SUl        U R                  5         U R	                  U5        g)z.Export a DXF document via a custom tag writer.TN)rl   r#   rZ  r^  r`  )r   ra  rl   s      r[   custom_exportr    s3    JU"&	NN	"r   c                    [         R                  " 5       n[        X R                  US9n[	        X5        UR                  5       $ )a  Export a DXF document as JSON formatted tags.

The `compact` format is a list of ``[group-code, value]`` pairs where each pair is
a DXF tag. The group-code has to be an integer and the value has to be a string,
integer, float or list of floats for vertices.

The `verbose` format (`compact` is ``False``) is a list of ``[group-code, value]``
pairs where each pair is a 1:1 representation of a DXF tag. The group-code has to be
an integer and the value has to be a string.

)rl   compact)rN  re  r)   rl   r  rf  )r   r   r   json_writers       r[   export_json_tagsr    s4     [[]F>>7SK##??r   c                D    SSK Jn  [        R                  U" U 5      5      $ )a  Load DXF document from JSON formatted tags.

The expected JSON format is a list of [group-code, value] pairs where each pair is
a DXF tag. The `compact` and the `verbose` format is supported.

Args:
    data: JSON data structure as a sequence of [group-code, value] pairs

r   )json_tag_loader)ezdxf.lldxf.taggerr  r^   r   )r+  r  s     r[   load_json_tagsr    s     3<<-..r   )rY   r  rS  r  )FFASCII)r   r^   rS  r[  )r   r^   rS  zlist[DXFEntity])r   r^   ra  r&   r`  )r   r^   rS  r  )r+  zSequence[Any]rS  r^   )
__future__r   typingr   r   r   r   r   r	   r
   r   r   r   r   r  rg  rN  loggingosr   r   r   	itertoolsr   r=   ezdxf.auditr   ezdxf.entities.dxfgroupsr   ezdxf.entities.materialr   ezdxf.entities.mleaderr   ezdxf.entities.mliner   ezdxf.entitydbr   ezdxf.groupbyr   ezdxf.layoutsr   r   ezdxf.layouts.layoutsr   ezdxf.lldxfr   r  r   r   r   r    r!   r"   r#   r$   r%   ezdxf.lldxf.tagwriterr&   r'   r(   r)   ezdxf.queryr*   ezdxf.render.dimensionr+   ezdxf.sections.acdsdatar,   r-   ezdxf.sections.blocksr.   ezdxf.sections.classesr/   ezdxf.sections.entitiesr0   r1   ezdxf.sections.headerr2   ezdxf.sections.objectsr3   ezdxf.sections.tablesr4   ezdxf.toolsr5   ezdxf.tools.codepager6   r7   ezdxf.tools.juliandater8   ezdxf.tools.textr9   r:   r;   r<   	getLoggerr   r  r>   r?   r@   rA   ezdxf.eztypesrB   rC   ezdxf.lldxf.tagsrD   ezdxf.lldxf.typesrE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   r   r  rO   rP   rQ   r\   r^   ABCrX  r  r  r  r   r  r  r  r  ri  r   r[   <module>r*     sS   #      	  	  '    4 6 9 5 # ! 0 ) 	 	 	   $ 4 J / 1 @ / 1 /  7 - 5 % 
		7	#BB/$%(
 
 
 6
> % % 
q qh!-sww -`;,( ,^9H 94m`#$/r   