
    hIx                       S SK Jr  S SKJrJrJrJr  S SKrS SKJ	r	  S SK
Jr  S SKJrJr  S SKr\(       a6  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Jr  S S	KJrJ r   S S
K!J"r"  S SK#J$r$  / SQr%SSS jjr&  S       SS jjr'  S       S S jjr( S!   S"S jjr) " S S5      r*1 Skr+S#S jr,S$S%S jjr-S$S&S jjr.        S'S jr/S$S(S jjr0 " S S5      r1g))    )annotations)TYPE_CHECKINGIterableMappingOptionalN)
TABLENAMES)Tags)BoundaryPathTypeEdgeType)DXFTag)InsertMText
LWPolylinePolylineSplineLeader	DimensionImageMeshHatchMPolygonWipeout)	DXFEntityLinetype)
DXFPolygon)BlockLayout)entities_to_codeblock_to_codetable_entries_to_codeblackc                V    SSK nUR                  5       nXl        UR                  XUS9$ )a  Returns the source `code` as a single string formatted by `Black`_

Requires the installed `Black`_ formatter::

    pip3 install black

Args:
    code: source code
    line_length: max. source code line length
    fast: ``True`` for fast mode, ``False`` to check that the reformatted
        code is valid

Raises:
    ImportError: Black is not available

.. _black: https://pypi.org/project/black/

r   N)fastmode)r    FileModeline_lengthformat_file_contents)coder%   r"   r    r#   s        G/var/www/html/env/lib/python3.13/site-packages/ezdxf/addons/dxf2code.pyr    r    (   s/    ( >>D"%%dD%AA    Codec                J    [        US9nUR                  XS9  UR                  $ )aJ  
Translates DXF entities into Python source code to recreate this entities
by ezdxf.

Args:
    entities: iterable of DXFEntity
    layout: variable name of the layout (model space or block) as string
    ignore: iterable of entities types to ignore as strings
        like ``['IMAGE', 'DIMENSION']``

Returns:
    :class:`Code`

layoutignore_SourceCodeGeneratortranslate_entitiesr'   )entitiesr-   r/   r'   s       r(   r   r   C   s)    &  v.DH499r)   c                   U R                   c   e[        U R                   R                  5       5      nUR                  S5      nUR                  S5      n[	        SS9nSU SU SU S3nUR                  U5        UR                  [        US	S
95        UR                  S5        UR                  S5        UR                  XS9  UR                  $ )a'  
Translates a BLOCK into Python source code to recreate the BLOCK by ezdxf.

Args:
    block: block definition layout
    drawing: variable name of the drawing as string
    ignore: iterable of entities types to ignore as strings
        like ['IMAGE', 'DIMENSION']

Returns:
    :class:`Code`

name
base_pointbr,   zb = z.blocks.new("z", base_point=z, dxfattribs={   indentz    })r.   )
block_purge_handles
dxfattribspopr1   add_source_code_lineadd_source_code_lines_fmt_mappingr2   r'   )r<   drawingr/   r>   
block_namer6   r'   prologs           r(   r   r   [   s    $ ;;""" 6 6 89J'J-Js+DG9M*^J<_Ff%|JqABg&c"E199r)   c                N    [        US9nUR                  U 5        UR                  $ )Ndocr0   )r3   rC   r'   s      r(   r   r   {   s&      G,DH%99r)   c                      \ rS rSrSrSS jrSSS jjrSSS jjrSS jrSSS jjr	SS jr
SSS	 jjrSSS
 jjrSSS jjrSrg)r*      zSource code container.c                    / U l         [        5       U l        [        5       U l        [        5       U l        [        5       U l        [        5       U l        [        5       U l        g N)r'   setimportslayersstyles	linetypes	dimstylesblocksselfs    r(   __init__Code.__init__   s?    !	!$ # ##&5#&5 #r)   c                X   ^ SU-  mSR                  U4S jU R                   5       5      $ )zhReturns the source code as a single string.

Args:
    indent: source code indentation count by spaces

 
c              3  .   >#    U  H
  nTU-   v   M     g 7frL    .0linelead_strs     r(   	<genexpr> Code.code_str.<locals>.<genexpr>   s     ?YTDY   )joinr'   rU   r:   r`   s     @r(   code_strCode.code_str   s'     <yy?TYY???r)   c                6    [        U R                  5       U5      $ )zReturns the source code as a single string formatted by `Black`_

Args:
    line_length: max. source code line length

Raises:
    ImportError: Black is not available

)r    rf   )rU   r%   s     r(   black_code_strCode.black_code_str   s     T]]_k22r)   c                "    U R                  5       $ )z+Returns the source code as a single string.)rf   rT   s    r(   __str__Code.__str__   s     }}r)   c                X   ^ SU-  mSR                  U4S jU R                   5       5      $ )ziReturns required imports as a single string.

Args:
    indent: source code indentation count by spaces

rY   rZ   c              3  .   >#    U  H
  nTU-   v   M     g 7frL   r\   r]   s     r(   ra   "Code.import_str.<locals>.<genexpr>   s     B\TD\rc   )rd   rN   re   s     @r(   
import_strCode.import_str   s'     <yyBT\\BBBr)   c                :    U R                   R                  U5        g)zGAdd import statement, identical import statements are merged
together.
N)rN   addrU   	statements     r(   
add_importCode.add_import   s     	#r)   c                F    U R                   R                  SU-  U-   5        g)z9Add a single source code line without line ending ``\n``.rY   N)r'   appendrU   r'   r:   s      r(   add_lineCode.add_line   s    		v,-r)   c                4    U H  nU R                  X2S9  M     g)z:Add multiple source code lines without line ending ``\n``.r9   N)r|   )rU   r'   r:   r_   s       r(   	add_linesCode.add_lines   s    DMM$M. r)   c                   U R                   R                  UR                   5        U R                  R                  UR                  5        U R                  R                  UR                  5        U R                  R                  UR                  5        U R
                  R                  UR
                  5        U R                  R                  UR                  5        U R                  UR                  US9  g)z!Add another :class:`Code` object.r9   N)	rN   updaterO   rQ   rP   rR   rS   r   r'   r{   s      r(   merge
Code.merge   s     	DLL)4;;'dnn-4;;'dnn-4;;' 	tyy0r)   )rS   r'   rR   rN   rO   rQ   rP   N)returnNoner   )r:   intr   str)X   )r   r   rv   r   r   r   )r'   r   r:   r   r   r   )r'   Iterable[str]r:   r   r   r   )r'   r*   r:   r   r   r   )__name__
__module____qualname____firstlineno____doc__rV   rf   ri   rl   rq   rw   r|   r   r   __static_attributes__r\   r)   r(   r*   r*      s9     &@
3
C$./
1 1r)   >   ownerhandle
paperspacematerial_handleplotstyle_handlevisualstyle_handlec                p    U R                  5        VVs0 s H  u  pU[        ;  d  M  X_M     snn$ s  snnf )zPurge handles from DXF attributes which will be invalid in a new
document, or which will be set automatically by adding an entity to a
layout (paperspace).

Args:
    attribs: entity DXF attributes dictionary

)items_PURGE_DXF_ATTRIBUTES)attribskvs      r(   r=   r=      s0     %]]_O_TQ9N0NDAD_OOOs   22c              #    #    SU-  S-   nU R                  5        Hf  u  p4[        U[        5      (       d   e[        U[        5      (       a  [        R                  " U5      nO[        U5      nUR                  X45      v   Mh     g 7f)NrY   z	'{}': {},)r   
isinstancer   jsondumpsformat)mappingr:   fmtr   r   s        r(   rB   rB      sj     
,
$C!S!!!!a

1AAAjj  s   BBc              #     #    SS jnSU-  S-   nU  HP  n[        U[        [        [        45      (       d  [	        U" U5      5      nUR                  [        U5      5      v   MR     g 7f)Nc              3     #    U  H5  n[        U[        R                  5      (       a  [        U5      v   M1  Uv   M7     g 7frL   )r   npfloat64float)valuesvalues     r(   cleanup_fmt_list.<locals>.cleanup   s/     E%,,El"	 s   =?rY   z{},)r   r   r   r   )r   r   r   r   tupler   )lr:   r   r   r   s        r(   	_fmt_listr      sY      ,
C!eS#.//gaj!AjjQ   s   A%A'c                  ^^ [        U5      mT(       a  [        T5      O/ mSUU4S jjnU /nUR                  U" 5       5        UR                  S5        UR                  [	        TSS95        UR                  SS/5        U$ )Nc               3     >#    T Hf  n U T;  a  M  TR                  U 5      n[        U[        5      (       a  [        R                  " U5      nO[        U5      nSR                  X5      v   Mh     g 7f)N
    {}={},)r?   r   r   r   r   r   )argr   valuestrargs
attributess      r(   fmt_keywords#_fmt_api_call.<locals>.fmt_keywords  s^     C*$NN3'E%%%::e,u:%%c44 s   A.A1    dxfattribs={   r9       },r;   )r   r   )dictlistextendrz   rB   )	func_callr   r>   r   sr   s    `   @r(   _fmt_api_callr     s{     j!J4:2D	5 	5 
AHH\^HH HH\*Q/0HH	
 Hr)   c              #     #    SU-  S-   nU  Hf  u  p4[        U[        5      (       d   e[        U[        5      (       a  [        R                  " U5      nO[        U5      nUR                  X45      v   Mh     g 7f)NrY   zdxftag({}, {}),)r   r   r   r   r   r   )tagsr:   r   r'   r   s        r(   _fmt_dxf_tagsr   &  sf     
,*
*C$$$$$eS!!JJu%EJEjj%% s   A6A8c                  P   \ rS rSrSrS1S2S jjrS3S jr S4     S5S jjrS6S jrS7S jr	S8S	 jr
S9S
 jr   S:         S;S jjr   S<         S=S jjr S> S?S jjr S@       SAS jjr S@         SBS jjrSCS jrS3S jrS3S jrS3S jrS3S jrS3S jrS3S jrS3S jrS3S jrS3S jrS3S jrS3S jrS3S jrS3S jrSDS jrSES jr SFS  jr!SGS! jr"SHS" jr#SIS# jr$SJS$ jr%SKS% jr&SLS& jr'SMS' jr(SNS( jr)SOS) jr*SPS* jr+SQS+ jr,SRS, jr-SSS- jr.STS. jr/SUS/ jr0S0r1g)Vr1   i1  aP  
The :class:`_SourceCodeGenerator` translates DXF entities into Python source
code for creating the same DXF entity in another model space or block
definition.

:ivar code: list of source code lines without line endings
:ivar required_imports: list of import source code lines, which are required
    to create executable Python code.

c                :    X l         Xl        [        5       U l        g rL   )rH   r-   r*   r'   )rU   r-   rH   s      r(   rV   _SourceCodeGenerator.__init__=  s    F	r)   c                    UR                  5       n [        U SUR                  5       -   5      nU" U5        g! [         a    U R	                  SU S35         gf = f)zTranslates one DXF entity into Python source code. The generated
source code is appended to the attribute `source_code`.

Args:
    entity: DXFEntity object

_z# unsupported DXF entity ""N)dxftypegetattrlowerAttributeErrorr@   )rU   entityr   entity_translators       r(   translate_entity%_SourceCodeGenerator.translate_entityB  sb     .."	& 'cGMMO.C D f%  	O%%(B7)1&MN	Os   8 AANc                    U(       a  [        U5      O	[        5       nU H*  nUR                  5       U;  d  M  U R                  U5        M,     g)a  Translates multiple DXF entities into Python source code. The
generated source code is appended to the attribute `source_code`.

Args:
    entities: iterable of DXFEntity
    ignore: iterable of entities types to ignore as strings
        like ['IMAGE', 'DIMENSION']

N)rM   r   r   )rU   r3   r/   r   s       r(   r2   '_SourceCodeGenerator.translate_entitiesR  s:     !'VCEF~~v-%%f- r)   c                v   SU;   a(  U R                   R                  R                  US   5        SU;   a(  U R                   R                  R                  US   5        SU;   a(  U R                   R                  R                  US   5        SU;   a)  U R                   R
                  R                  US   5        gg)zRegister used resources like layers, line types, text styles and
dimension styles.

Args:
    dxfattribs: DXF attributes dictionary

layerlinetypestyledimstyleN)r'   rO   rt   rQ   rP   rR   )rU   r>   s     r(   add_used_resources'_SourceCodeGenerator.add_used_resourcesf  s     j II  G!45#II##Jz$:;j II  G!45#II##Jz$:; $r)   c                :    U R                   R                  U5        g rL   )r'   rw   ru   s     r(   add_import_statement)_SourceCodeGenerator.add_import_statementw  s    		Y'r)   c                :    U R                   R                  U5        g rL   )r'   r|   rU   r'   s     r(   r@   )_SourceCodeGenerator.add_source_code_linez  s    		4 r)   c                h    [        U[        5      (       a   eU R                  R                  U5        g rL   )r   r   r'   r   r   s     r(   rA   *_SourceCodeGenerator.add_source_code_lines}  s'    dC((((		D!r)   c                    SU-  S-   nU R                  UR                  U5      5        U R                  [        USU-   S95        U R                  UR                  U5      5        g NrY   z{}r8   r9   )r@   r   rA   r   )rU   r   rE   epilogr:   fmt_strs         r(   add_list_source_code)_SourceCodeGenerator.add_list_source_code  sY     ,%!!'.."89""9VAJ#GH!!'.."89r)   c                    SU-  S-   nU R                  UR                  U5      5        U R                  [        USU-   S95        U R                  UR                  U5      5        g r   )r@   r   rA   rB   )rU   r   rE   r   r:   r   s         r(   add_dict_source_code)_SourceCodeGenerator.add_dict_source_code  sY     ,%!!'.."89""<F
#KL!!'.."89r)   c                    SU-  S-   nU R                  UR                  U5      5        U R                  [        USU-   S95        U R                  UR                  U5      5        g r   )r@   r   rA   r   )rU   r   rE   r   r:   r   s         r(   add_tags_source_code)_SourceCodeGenerator.add_tags_source_code  sY     ,%!!'.."89""=a&j#IJ!!'.."89r)   c                    [        U5      nU R                  U5        U U R                   S3SU S3S/nUR                  [	        USS95        UR                  SS/5        U$ )	zReturns the source code strings to create a DXF entity by a generic
`new_entity()` call.

Args:
    dxftype: DXF entity type as string, like 'LINE'
    dxfattribs: DXF attributes dictionary
    prefix: prefix string like variable assignment 'e = '

z.new_entity(z    '',r   r   r9   r   r;   )r=   r   r-   r   rB   )rU   r   r>   prefixr   s        r(   generic_api_call%_SourceCodeGenerator.generic_api_call  sw     $J/

+ht{{m<0G9B

 	
j34		
 r)   c                V    [        U5      nU U R                   SU 3n[        XRU5      $ )a  Returns the source code strings to create a DXF entity by the
specialised API call.

Args:
    api_call: API function call like 'add_line('
    args: DXF attributes to pass as arguments
    dxfattribs: DXF attributes dictionary
    prefix: prefix string like variable assignment 'e = '

.)r=   r-   r   )rU   api_callr   r>   r   r   s         r(   r   _SourceCodeGenerator.api_call  s3    " $J/
ht{{m1XJ7	Yj99r)   c                    U R                    S[        U    3n[        U5      nUR                  S5      nSU SU S3SU S3SU S	3S
/nUR	                  [        USS95        UR	                  SS/5        U$ )zReturns the source code strings to create a new table entity by
ezdxf.

Args:
    dxftype: table entry type as string, like 'LAYER'
    dxfattribs: DXF attributes dictionary

r   r5   zif 'z	' not in :z    t = z.new(z	        'r   z        dxfattribs={   r9   z
        },z    ))rH   r   r=   r?   r   rB   )rU   r   r>   tabler5   r   s         r(   new_table_entry$_SourceCodeGenerator.new_table_entry  s     88*Aj123#J/
~~f%4&	%*ugU#vR "	
 	
j45		
 r)   c                h    U R                  U R                  SSS/UR                  5       5      5        g )Nz	add_line(startendrA   r   r>   rU   r   s     r(   _line_SourceCodeGenerator._line  s.    ""MM+'79J9J9LM	
r)   c                f    U R                  U R                  SS/UR                  5       5      5        g )Nz
add_point(locationr  r  s     r(   _point_SourceCodeGenerator._point  s+    ""MM,f6G6G6IJ	
r)   c                h    U R                  U R                  SSS/UR                  5       5      5        g )Nzadd_circle(centerradiusr  r  s     r(   _circle_SourceCodeGenerator._circle  s1    ""MM(3V5F5F5H	
r)   c                h    U R                  U R                  S/ SQUR                  5       5      5        g )Nzadd_arc()r  r  start_angle	end_angler  r  s     r(   _arc_SourceCodeGenerator._arc   s.    ""MM@!!#	
r)   c                f    U R                  U R                  SS/UR                  5       5      5        g )Nz	add_text(textr  r  s     r(   _text_SourceCodeGenerator._text	  s+    ""MM+x1B1B1DE	
r)   c                b    U R                  U R                  SUR                  5       5      5        g )NSOLIDrA   r   r>   r  s     r(   _solid_SourceCodeGenerator._solid  )    ""!!'6+<+<+>?	
r)   c                b    U R                  U R                  SUR                  5       5      5        g )NTRACEr  r  s     r(   _trace_SourceCodeGenerator._trace  r  r)   c                b    U R                  U R                  SUR                  5       5      5        g )N3DFACEr  r  s     r(   _3dface_SourceCodeGenerator._3dface  )    ""!!(F,=,=,?@	
r)   c                h    U R                  U R                  S/ SQUR                  5       5      5        g )Nz
add_shape()r5   insertsizer  r  s     r(   _shape_SourceCodeGenerator._shape  s-    ""MM8&:K:K:M	
r)   c                h    U R                  U R                  S/ SQUR                  5       5      5        g )Nzadd_attrib()tagr  r*  r  r  s     r(   _attrib_SourceCodeGenerator._attrib$  s-    ""MM8&:K:K:M	
r)   c                b    U R                  U R                  SUR                  5       5      5        g )NATTDEFr  r  s     r(   _attdef_SourceCodeGenerator._attdef+  r(  r)   c                h    U R                  U R                  S/ SQUR                  5       5      5        g )Nzadd_ellipse()r  
major_axisratiostart_param	end_paramr  r  s     r(   _ellipse_SourceCodeGenerator._ellipse0  s.    ""MMM!!#	
r)   c                    U R                  U R                  SUR                  5       5      5        U R                  S5        g )NVIEWPORTzm# Set valid handles or remove attributes ending with "_handle", otherwise the DXF file is invalid for AutoCAD)rA   r   r>   r@   r  s     r(   	_viewport_SourceCodeGenerator._viewport9  s>    ""!!*f.?.?.AB	
 	!!<	
r)   c           	        U R                   R                  R                  UR                  R                  5        U R                  U R                  SSS/UR                  5       5      5        [        UR                  5      (       a|  UR                   Hk  nUR                  5       nUR                  R                  US'   U R                  U R                  SUR                  5       SS95        U R                  S5        Mm     g g )	Nzadd_blockref(r5   r*  r   ATTRIBza = )r   ze.attribs.append(a))r'   rS   rt   dxfr5   rA   r   r>   lenr   r   r   r@   )rU   r   attribr>   s       r(   _insert_SourceCodeGenerator._insertD  s    		VZZ__-""MM&(!3V5F5F5H	

 v~~ ..#..0
 JJ$$  **)) &"3"3"5f * 
 ))*?@ ) r)   c                    U R                  U R                  SUR                  5       5      5        U R                  SR	                  [
        R                  " UR                  5      5      5        g )NMTEXTze.text = {})rA   r   r>   r@   r   r   r   r  r  s     r(   _mtext_SourceCodeGenerator._mtextX  sQ    ""!!'6+<+<+>?	

 	!!-"6"6tzz&++7N"OPr)   c                    U R                  U R                  SUR                  5       5      5        U R                  UR	                  5       SSS9  g )N
LWPOLYLINEze.set_points([])rE   r   )rA   r   r>   r   
get_pointsr  s     r(   _lwpolyline _SourceCodeGenerator._lwpolyline`  sO    ""!!,0A0A0CD	
 	!!(8 	" 	
r)   c                   U R                  U R                  SS/UR                  5       5      5        [        UR                  5      (       a  U R                  UR                  SSS9  [        UR                  5      (       a  U R                  UR                  SSS9  [        UR                  5      (       a  U R                  UR                  SSS9  [        UR                  5      (       a  U R                  UR                  SSS9  g g )	Nzadd_spline(degreeze.fit_points = []rO  ze.control_points = [ze.knots = [ze.weights = [)	rA   r   r>   rD  
fit_pointsr   control_pointsknotsweightsr  s     r(   _spline_SourceCodeGenerator._splinei  s    ""MM-(V5F5F5HI	
 v  !!%%!!*<S &  v$$%%%%%%.DS &  v||%%]3 &  v~~%%s &  r)   c                0   U R                  U R                  SUR                  5       5      5        UR                   HW  n[	        UR                  5       5      nUR                  S5      nSU;   a  US	 U R                  S[        U5       SU S35        MY     g )NPOLYLINEr	  r   ze.append_vertex(z, dxfattribs=r;   )rA   r   r>   verticesr=   r?   r@   r   )rU   r   r   r   r	  s        r(   	_polyline_SourceCodeGenerator._polyline  s    ""!!*f.?.?.AB	
 A$Q\\^4G{{:.H'!
 %%"3x=/wiqI !r)   c                    U R                  S5        U R                  U R                  SUR                  5       5      5        U R	                  UR
                  SSS9  g )N8# Dimension style attribute overriding is not supported!LEADERze.set_vertices([rN  rO  )r@   rA   r   r>   r   r^  r  s     r(   _leader_SourceCodeGenerator._leader  s]    !!F	
 	""!!(F,=,=,?@	
 	!!OO$6t 	" 	
r)   c                    U R                  S5        U R                  S5        U R                  U R                  SUR	                  5       5      5        U R                  / SQ5        g )Nz3from ezdxf.dimstyleoverride import DimStyleOverriderb  	DIMENSION)z?# You have to create the required graphical representation for zA# the DIMENSION entity as anonymous block, otherwise the DXF filez0# is invalid for AutoCAD (but not for BricsCAD):z# DimStyleOverride(e).render() )r   r@   rA   r   r>   r  s     r(   
_dimension_SourceCodeGenerator._dimension  sd    !!A	
 	!!F	
 	""!!+v/@/@/BC	
 	""	
r)   c                   U R                  S5        U R                  U R                  SUR                  5       5      5        [	        UR
                  5      (       a"  U R                  S UR
                   5       SSS9  U R                  S5        g )NzM# Image requires IMAGEDEF and IMAGEDEFREACTOR objects in the OBJECTS section!IMAGEc              3  $   #    U  H  ov   M     g 7frL   r\   r^   r   s     r(   ra   ._SourceCodeGenerator._image.<locals>.<genexpr>       10q0   e.set_boundary_path([rN  rO  zh# Set valid image_def_handle and image_def_reactor_handle, otherwise the DXF file is invalid for AutoCAD)r@   rA   r   r>   rD  boundary_pathr   r  s     r(   _image_SourceCodeGenerator._image  s    !!	
 	""!!'6+<+<+>?	
 v##$$%%1F001. & 
 	!!<	
r)   c                    U R                  U R                  SUR                  5       5      5        [        UR                  5      (       a#  U R                  S UR                   5       SSS9  g g )NWIPEOUTc              3  $   #    U  H  ov   M     g 7frL   r\   rn  s     r(   ra   0_SourceCodeGenerator._wipeout.<locals>.<genexpr>  rp  rq  rr  rN  rO  )rA   r   r>   rD  rs  r   r  s     r(   _wipeout_SourceCodeGenerator._wipeout  sh    ""!!)V->->-@A	
 v##$$%%1F001. &  %r)   c                *   U R                  U R                  S/ UR                  5       5      5        [        UR                  5      (       a  U R                  UR                  SSS9  [        UR                  5      (       a"  U R                  S UR                   5       SSS9  [        UR                  5      (       a"  U R                  S UR                   5       SSS9  [        UR                  5      (       a  U R                  UR                  S	SS9  g g )
Nz	add_mesh(ze.vertices = [rU  rO  c              3  8   #    U  H  n[        U5      v   M     g 7frL   r   )r^   es     r(   ra   -_SourceCodeGenerator._mesh.<locals>.<genexpr>       0<aq<   ze.edges = [c              3  8   #    U  H  n[        U5      v   M     g 7frL   r~  )r^   fs     r(   ra   r    r  r  ze.faces = [ze.creases = [)	rA   r   r>   rD  r^  r   edgesfacescreasesr  s     r(   _mesh_SourceCodeGenerator._mesh  s    ""MM+r6+<+<+>?	
 v%%(8 &  v||%%06<<0$ & 
 v||%%06<<0$ & 
 v~~%%s &  r)   c                    UR                  5       nSUS'   U R                  U R                  SS/U5      5        U R                  U5        g )Nr   associativez
add_hatch(color)r>   rA   r   _polygonrU   r   r>   s      r(   _hatch_SourceCodeGenerator._hatch  sH    &&(
$%
=!""MM,	:>	
 	fr)   c                   UR                  5       nU R                  U R                  SS/U5      5        UR                  R                  (       a)  U R                  SUR                  R                   S35        U R                  U5        g )Nzadd_mpolygon(r  ze.set_solid_fill(color=z)
)r>   rA   r   rC  
solid_fillr@   
fill_colorr  r  s      r(   	_mpolygon_SourceCodeGenerator._mpolygon  sr    &&(
""MM/G9jA	
 ::  %%)&***?*?)@D 	fr)   c                   U R                   n[        UR                  5      (       a  U" SUR                   S35        UR                  (       aD  U R	                  [        [        UR                  R                  5      SSS9  U R                  S5        SnUR                  Gb  UR                  nU" S5        U" UR                  S	[        UR                  5      5      5        U" UR                  S
[        UR                  5      5      5        U" UR                  SUR                  5      5        U" UR                  SUR                  5      5        U" UR                  SUR                  5      5        U" UR                  S[        R                   " UR"                  5      5      5        U" S5        [%        UR&                  SS9 GH!  u  pVUR(                  [*        R,                  :X  a  U" SR                  U5      5        U R	                  UR.                  SSS9  U" UR                  S[        UR0                  5      5      5        U" UR                  S[        UR2                  5      5      5        U" S5        M  U" SU S35        U" SUR2                   S35        UR4                   GH8  nUR(                  [6        R8                  :X  a.  U" SUR:                   S[        UR<                  5       S35        MP  UR(                  [6        R>                  :X  a  U" S5        U" UR                  S[        UR@                  5      5      5        U" UR                  SURB                  5      5        U" UR                  SURD                  5      5        U" UR                  SURF                  5      5        U" UR                  S URH                  5      5        U" S5        GM4  UR(                  [6        RJ                  :X  a  U" S!5        U" UR                  S[        UR@                  5      5      5        U" UR                  S"[        URL                  5      5      5        U" UR                  S#URN                  5      5        U" UR                  SURD                  5      5        U" UR                  SURF                  5      5        U" UR                  S URH                  5      5        U" S5        GMC  UR(                  [6        RP                  :X  d  GMd  U" S$5        URR                  (       a;  U" UR                  S%[        URR                   Vs/ s H  oPM     sn5      5      5        URT                  (       a;  U" UR                  S&[        URT                   V	s/ s H  oPM     sn	5      5      5        URV                  (       a+  U" UR                  S'[        URV                  5      5      5        URX                  (       a+  U" UR                  S([        URX                  5      5      5        U" UR                  S)URZ                  5      5        U" UR                  S*UR\                  5      5        UR^                  b+  U" UR                  S+[        UR^                  5      5      5        UR`                  b+  U" UR                  S,[        UR`                  5      5      5        U" S5        GM;     GM$     g s  snf s  sn	f )-Nze.set_seed_points(r;   ze.set_pattern_definition([rN  rO  ze.dxf.solid_fill = 0r   ze.set_gradient(color1color2rotationcentered	one_colorr5      )r  z# {}. polyline pathze.paths.add_polyline_path([z    ],	is_closedflagsz# z,. edge path: associative hatch not supportedz!ep = e.paths.add_edge_path(flags=zep.add_line(z, zep.add_arc(r  r  r  r  ccwzep.add_ellipse(r7  r8  zep.add_spline(rV  rW  knot_valuesrY  rT  periodicstart_tangentend_tangent)1r@   rD  seedspatternr   mapr   linesgradientr   r  r  r  r  r  r   r   r5   	enumeratepathstyper
   r]  r^  r  path_type_flagsr  r   LINEr  r  ARCr  r  r  r  r  ELLIPSEr7  r8  SPLINErV  rW  r  rY  rT  r  r  r  )
rU   r   r|   r   gcountpathedgefpcps
             r(   r  _SourceCodeGenerator._polygon  s-   ,,v||)&,,q9:>>%%C--.3 & 
 %%&<=??&A&'SZZ#ahh-89SZZ#ahh-89SZZ
AJJ78SZZ
AJJ78SZZQ[[9:SZZ

166(:;<SM$V\\;KEyy,555.55e<=))MM8# * 
 KT^^1DEFGS1E1E-FGHKL 78L8L7MQO !JJDyyHMM1 <

|2c$((m_A!NOhll2 !/ Hc$++6F!GH Hdkk!BC M4;K;K!LM K!HI E488!<= h&6&66 !!23 Hc$++6F!GH L#doo:N!OP GTZZ!@A M4;K;K!LM K!HI E488!<= hoo5 !12??$ #

$0$'doo(Foo(F$G!"  ..$ #

$4$'d6I6I(J6I6I(J$K!"  ++$ #

=#d>N>N:O P  <<$SZZ	3t||;L%MN Hdkk!BC J!FG--9$ #

$3S9K9K5L!"
  ++7$ #

=#d>N>N:O P !u '% <` )G )Ks   [+[0c                b    U R                  U R                  SUR                  5       5      5        g )NLAYERrA   r   r>   )rU   r   s     r(   _layer_SourceCodeGenerator._layere  )    ""  %*:*:*<=	
r)   c                6   U R                  S5        U R                  S5        U R                  S5        U R                  U R                  SUR                  5       5      5        U R	                  UR
                  R                  SSSS9  U R                  S	5        g )
Nz!from ezdxf.lldxf.tags import Tagsz$from ezdxf.lldxf.types import dxftagz0from ezdxf.entities.ltype import LinetypePatternLTYPEztags = Tags([rN  r8   )rE   r   r:   z*    t.pattern_tags = LinetypePattern(tags))r   rA   r   r>   r   pattern_tagsr   r@   )rU   ltypes     r(   _ltype_SourceCodeGenerator._ltypej  s    !!"EF!!"HI!!>	
 	""  %*:*:*<=	
 	!!##"	 	" 	
 	!!"NOr)   c                b    U R                  U R                  SUR                  5       5      5        g )NSTYLEr  )rU   r   s     r(   _style_SourceCodeGenerator._style{  r  r)   c                b    U R                  U R                  SUR                  5       5      5        g )NDIMSTYLEr  )rU   r   s     r(   	_dimstyle_SourceCodeGenerator._dimstyle  s)    ""  X-@-@-BC	
r)   c                b    U R                  U R                  SUR                  5       5      5        g )NAPPIDr  )rU   appids     r(   _appid_SourceCodeGenerator._appid  r  r)   )r'   rH   r-   )r-   rH   )r-   r   rH   r   )r   r   r   r   rL   )r3   Iterable[DXFEntity]r/   Optional[Iterable[str]]r   r   )r>   r   r   r   r   )r'   r   r   r   )r'   r   r   r   )[rU  r   )
r   r   rE   r   r   r   r:   r   r   r   ){}r   )
r   r   rE   r   r   r   r:   r   r   r   )ztags = Tags(r;   r8   )r   r	   )ze = )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   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   )r   r   )r  r   )2r   r   r   r   r   rV   r   r2   r   r   r@   rA   r   r   r   r   r   r   r  r
  r  r  r  r  r"  r&  r,  r0  r4  r;  r?  rF  rJ  rQ  rZ  r_  rd  ri  rt  rz  r  r  r  r  r  r  r  r  r  r   r\   r)   r(   r1   r1   1  s   	
&& +/.%. (. 
	.(<"(!" 
:
: 
: 	
:
 
: 

: 
:
: 
: 	
:
 
: 

: EF:: =C(,69	B :: : 	:
 : 
:*:



















A(Q
2$	

(
&	6	c&L

P"




r)   r1   )r   T)r'   r   r"   boolr   r   )r-   N)r3   r  r-   r   r/   r  r   r*   )rH   N)r<   r   rC   r   r/   r  r   r*   rG   )r3   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   z	list[str])r   zIterable[DXFTag]r:   r   )2
__future__r   typingr   r   r   r   r   ezdxf.sections.tablesr   ezdxf.lldxf.tagsr	   ezdxf.entitiesr
   r   numpyr   ezdxf.lldxf.typesr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ezdxf.entities.polygonr   ezdxf.layoutsr   __all__r    r   r   r   r*   r   r=   rB   r   r   r   r1   r\   r)   r(   <module>r     s)   # = =  , ! 5 (    31)B: &*! $ 
	4 &* $ 
	B ,1!	Q1 Q1h 	P	!'59<&W	
 W	
r)   