
    OgIx                       d dl mZ d dlmZmZmZmZ d dlZd dlm	Z	 d dl
mZ d dlmZmZ d dlZer6d dlmZ d dlmZmZmZmZmZmZmZmZmZmZmZmZ d d	lmZm Z  d d
l!m"Z" d dl#m$Z$ g dZ%dddZ&	 	 d	 	 	 	 	 	 	 ddZ'	 	 d	 	 	 	 	 	 	 d dZ(	 d!	 	 	 d"dZ) G d d      Z*h dZ+d#dZ,d$d%dZ-d$d&dZ.	 	 	 	 	 	 	 	 d'dZ/d$d(dZ0 G d d      Z1y))    )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                `    ddl }|j                         }||_        |j                  | ||      S )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        Z/var/www/html/public_html/myphp/venv/lib/python3.12/site-packages/ezdxf/addons/dxf2code.pyr    r    (   s3    ( >>D"D%%dD%AA    Codec                X    t        |      }|j                  | |       |j                  S )ar  
    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HV499r)   c                   | j                   J t        | j                   j                               }|j                  d      }|j                  d      }t	        d      }d| d| d| d}|j                  |       |j                  t        |d	
             |j                  d       |j                  d       |j                  | |       |j                  S )aK  
    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                T    t        |      }|j                  |        |j                  S )Ndocr0   )r3   rC   r'   s      r(   r   r   {   s&      G,DH%99r)   c                  d    e Zd ZdZddZdddZdddZddZdddZddZ	dddZ
ddd	Zddd
Zy)r*   zSource code container.c                    g | _         t               | _        t               | _        t               | _        t               | _        t               | _        t               | _        y N)r'   setimportslayersstyles	linetypes	dimstylesblocksselfs    r(   __init__zCode.__init__   s?    !	!$ # ##&5#&5 #r)   c                V    d|z  dj                  fd| j                  D              S )zReturns the source code as a single string.

        Args:
            indent: source code indentation count by spaces

         
c              3  (   K   | ]	  }|z     y wrK    .0linelead_strs     r(   	<genexpr>z Code.code_str.<locals>.<genexpr>   s     ?TD?   )joinr'   rT   r:   r^   s     @r(   code_strzCode.code_str   s'     <yy?TYY???r)   c                6    t        | j                         |      S )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    rc   )rT   r%   s     r(   black_code_strzCode.black_code_str   s     T]]_k22r)   c                "    | j                         S )z+Returns the source code as a single string.)rc   rS   s    r(   __str__zCode.__str__   s     }}r)   c                V    d|z  dj                  fd| j                  D              S )zReturns required imports as a single string.

        Args:
            indent: source code indentation count by spaces

        rW   rX   c              3  (   K   | ]	  }|z     y wrK   rZ   r[   s     r(   r_   z"Code.import_str.<locals>.<genexpr>   s     BTDBr`   )ra   rM   rb   s     @r(   
import_strzCode.import_str   s'     <yyBT\\BBBr)   c                :    | j                   j                  |       y)zWAdd import statement, identical import statements are merged
        together.
        N)rM   addrT   	statements     r(   
add_importzCode.add_import   s     	#r)   c                F    | j                   j                  d|z  |z          y)z9Add a single source code line without line ending ``\n``.rW   N)r'   appendrT   r'   r:   s      r(   add_linezCode.add_line   s    		v,-r)   c                8    |D ]  }| j                  ||        y)z:Add multiple source code lines without line ending ``\n``.r9   N)rs   )rT   r'   r:   r]   s       r(   	add_lineszCode.add_lines   s!     	/DMM$vM.	/r)   c                   | j                   j                  |j                          | j                  j                  |j                         | j                  j                  |j                         | j                  j                  |j                         | j
                  j                  |j
                         | j                  j                  |j                         | j                  |j                  |       y)z!Add another :class:`Code` object.r9   N)	rM   updaterN   rP   rO   rQ   rR   ru   r'   rr   s      r(   mergez
Code.merge   s     	DLL)4;;'dnn-4;;'dnn-4;;' 	tyy0r)   N)returnNoner   )r:   intry   str)X   )ry   r}   rn   r}   ry   rz   )r'   r}   r:   r|   ry   rz   )r'   Iterable[str]r:   r|   ry   rz   )r'   r*   r:   r|   ry   rz   )__name__
__module____qualname____doc__rU   rc   re   rg   rj   ro   rs   ru   rx   rZ   r)   r(   r*   r*      s4     &@
3
C$./
1r)   >   ownerhandle
paperspacematerial_handleplotstyle_handlevisualstyle_handlec                h    | j                         D ci c]  \  }}|t        vs|| c}}S c c}}w )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=      s.     %]]_OTQ9N0NAqDOOOs   ..c              #     K   d|z  dz   }| j                         D ]\  \  }}t        |t              sJ t        |t              rt        j                  |      }nt        |      }|j                  ||       ^ y w)NrW   z	'{}': {},)r   
isinstancer}   jsondumpsformat)mappingr:   fmtr   r   s        r(   rB   rB      sn     
,
$C 1!S!!!a

1AAAjjAs   A9A;c              #     K   dd}d|z  dz   }| D ]J  }t        |t        t        t        f      st	         ||            }|j                  t        |             L y w)Nc              3  r   K   | D ].  }t        |t        j                        rt        |       +| 0 y wrK   )r   npfloat64float)valuesvalues     r(   cleanupz_fmt_list.<locals>.cleanup   s2      	E%,El"		s   57rW   z{},)r   r   ry   r   )r   r   r|   r}   tupler   )lr:   r   r   r   s        r(   	_fmt_listr      s\      ,
C !!eS#./gaj!AjjQ  !s   AAc                    t        |      rt              ng dfd}| g}|j                   |              |j                  d       |j                  t	        d             |j                  ddg       |S )Nc               3     K   D ]]  } | vrj                  |       }t        |t              rt        j                  |      }nt        |      }dj                  | |       _ y w)N
    {}={},)r?   r   r}   r   r   r   )argr   valuestrargs
attributess      r(   fmt_keywordsz#_fmt_api_call.<locals>.fmt_keywords  sc      	5C*$NN3'E%%::e,u:%%c844	5s   A$A'    dxfattribs={   r9       },r;   )ry   r   )dictlistextendrq   rB   )	func_callr   r>   r   sr   s    `   @r(   _fmt_api_callr     sv     j!J4:2D	5 
AHH\^HH HH\*Q/0HH	
 Hr)   c              #     K   d|z  dz   }| D ]\  \  }}t        |t              sJ t        |t              rt        j                  |      }nt        |      }|j                  ||       ^ y w)NrW   zdxftag({}, {}),)r   r|   r}   r   r   r   )tagsr:   r   r'   r   s        r(   _fmt_dxf_tagsr   &  sj     
,*
*C &e$$$$eS!JJu%EJEjju%%&s   A+A-c                     e Zd ZdZd/d0dZd1dZ	 d2	 	 	 	 	 d3dZd4dZd5dZd6dZ	d7d	Z
	 	 	 d8	 	 	 	 	 	 	 	 	 d9d
Z	 	 	 d:	 	 	 	 	 	 	 	 	 d;dZ	 d<	 d=dZ	 d>	 	 	 	 	 	 	 d?dZ	 d>	 	 	 	 	 	 	 	 	 d@dZdAdZd1dZd1dZd1dZd1dZd1dZd1dZd1dZd1dZd1dZd1dZd1dZd1dZd1dZdBdZdCdZdDdZ dEd Z!dFd!Z"dGd"Z#dHd#Z$dId$Z%dJd%Z&dKd&Z'dLd'Z(dMd(Z)dNd)Z*dOd*Z+dPd+Z,dQd,Z-dRd-Z.dSd.Z/y)Tr1   al  
    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                >    || _         || _        t               | _        y rK   )rH   r-   r*   r'   )rT   r-   rH   s      r(   rU   z_SourceCodeGenerator.__init__=  s    F	r)   c                    |j                         }	 t        | d|j                         z         } ||       y# t        $ r | j	                  d| d       Y yw xY w)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@   )rT   entityr   entity_translators       r(   translate_entityz%_SourceCodeGenerator.translate_entityB  sb     .."	& 'cGMMO.C D f%  	O%%(B7)1&MN	Os   8 AANc                    |rt        |      n	t               }|D ]&  }|j                         |vs| j                  |       ( y)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)rL   r   r   )rT   r3   r/   r   s       r(   r2   z'_SourceCodeGenerator.translate_entitiesR  s?     !'VCE 	.F~~v-%%f-	.r)   c                f   d|v r(| j                   j                  j                  |d          d|v r(| j                   j                  j                  |d          d|v r(| j                   j                  j                  |d          d|v r)| j                   j
                  j                  |d          yy)zRegister used resources like layers, line types, text styles and
        dimension styles.

        Args:
            dxfattribs: DXF attributes dictionary

        layerlinetypestyledimstyleN)r'   rN   rl   rP   rO   rQ   )rT   r>   s     r(   add_used_resourcesz'_SourceCodeGenerator.add_used_resourcesf  s     j II  G!45#II##Jz$:;j II  G!45#II##Jz$:; $r)   c                :    | j                   j                  |       y rK   )r'   ro   rm   s     r(   add_import_statementz)_SourceCodeGenerator.add_import_statementw  s    		Y'r)   c                :    | j                   j                  |       y rK   )r'   rs   rT   r'   s     r(   r@   z)_SourceCodeGenerator.add_source_code_linez  s    		4 r)   c                ^    t        |t              rJ | j                  j                  |       y rK   )r   r}   r'   ru   r   s     r(   rA   z*_SourceCodeGenerator.add_source_code_lines}  s$    dC(((		D!r)   c                    d|z  dz   }| j                  |j                  |             | j                  t        |d|z                | j                  |j                  |             y NrW   z{}r8   r9   )r@   r   rA   r   )rT   r   rE   epilogr:   fmt_strs         r(   add_list_source_codez)_SourceCodeGenerator.add_list_source_code  sY     ,%!!'.."89""9VAJ#GH!!'.."89r)   c                    d|z  dz   }| j                  |j                  |             | j                  t        |d|z                | j                  |j                  |             y r   )r@   r   rA   rB   )rT   r   rE   r   r:   r   s         r(   add_dict_source_codez)_SourceCodeGenerator.add_dict_source_code  sY     ,%!!'.."89""<F
#KL!!'.."89r)   c                    d|z  dz   }| j                  |j                  |             | j                  t        |d|z                | j                  |j                  |             y r   )r@   r   rA   r   )rT   r   rE   r   r:   r   s         r(   add_tags_source_codez)_SourceCodeGenerator.add_tags_source_code  sY     ,%!!'.."89""=a&j#IJ!!'.."89r)   c                    t        |      }| j                  |       | | j                   dd| ddg}|j                  t	        |d             |j                  ddg       |S )	a)  Returns 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   )rT   r   r>   prefixr   s        r(   generic_api_callz%_SourceCodeGenerator.generic_api_call  sw     $J/

+ht{{m<0G9B

 	
j34		
 r)   c                X    t        |      }| | j                   d| }t        |||      S )aW  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   )rT   api_callr   r>   r   r   s         r(   r   z_SourceCodeGenerator.api_call  s5    " $J/
ht{{m1XJ7	Yj99r)   c                    | j                    dt        |    }t        |      }|j                  d      }d| d| dd| dd| d	d
g}|j	                  t        |d             |j	                  ddg       |S )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   )rT   r   r>   tabler5   r   s         r(   new_table_entryz$_SourceCodeGenerator.new_table_entry  s     88*Aj123#J/
~~f%4&	%*ugU#vR "	
 	
j45		
 r)   c                h    | j                  | j                  dddg|j                                      y )Nz	add_line(startendrA   r   r>   rT   r   s     r(   _linez_SourceCodeGenerator._line  s.    ""MM+'79J9J9LM	
r)   c                f    | j                  | j                  ddg|j                                      y )Nz
add_point(locationr   r   s     r(   _pointz_SourceCodeGenerator._point  s+    ""MM,f6G6G6IJ	
r)   c                h    | j                  | j                  dddg|j                                      y )Nzadd_circle(centerradiusr   r   s     r(   _circlez_SourceCodeGenerator._circle  s1    ""MM(3V5F5F5H	
r)   c                h    | j                  | j                  dg d|j                                      y )Nzadd_arc()r   r   start_angle	end_angler   r   s     r(   _arcz_SourceCodeGenerator._arc   s.    ""MM@!!#	
r)   c                f    | j                  | j                  ddg|j                                      y )Nz	add_text(textr   r   s     r(   _textz_SourceCodeGenerator._text	  s+    ""MM+x1B1B1DE	
r)   c                b    | j                  | j                  d|j                                      y )NSOLIDrA   r   r>   r   s     r(   _solidz_SourceCodeGenerator._solid  )    ""!!'6+<+<+>?	
r)   c                b    | j                  | j                  d|j                                      y )NTRACEr   r   s     r(   _tracez_SourceCodeGenerator._trace  r   r)   c                b    | j                  | j                  d|j                                      y )N3DFACEr   r   s     r(   _3dfacez_SourceCodeGenerator._3dface  )    ""!!(F,=,=,?@	
r)   c                h    | j                  | j                  dg d|j                                      y )Nz
add_shape()r5   insertsizer   r   s     r(   _shapez_SourceCodeGenerator._shape  s-    ""MM8&:K:K:M	
r)   c                h    | j                  | j                  dg d|j                                      y )Nzadd_attrib()tagr   r  r   r   s     r(   _attribz_SourceCodeGenerator._attrib$  s-    ""MM8&:K:K:M	
r)   c                b    | j                  | j                  d|j                                      y )NATTDEFr   r   s     r(   _attdefz_SourceCodeGenerator._attdef+  r  r)   c                h    | j                  | j                  dg d|j                                      y )Nzadd_ellipse()r   
major_axisratiostart_param	end_paramr   r   s     r(   _ellipsez_SourceCodeGenerator._ellipse0  s.    ""MMM!!#	
r)   c                    | j                  | j                  d|j                                      | j                  d       y )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(   	_viewportz_SourceCodeGenerator._viewport9  s>    ""!!*f.?.?.AB	
 	!!<	
r)   c                   | j                   j                  j                  |j                  j                         | j                  | j                  dddg|j                                      t        |j                        r}|j                  D ]m  }|j                         }|j                  j                  |d<   | j                  | j                  d|j                         d             | j                  d       o y y )	Nzadd_blockref(r5   r  r   ATTRIBza = )r   ze.attribs.append(a))r'   rR   rl   dxfr5   rA   r   r>   lenr   r   r   r@   )rT   r   attribr>   s       r(   _insertz_SourceCodeGenerator._insertD  s    		VZZ__-""MM&(!3V5F5F5H	

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

 	!!-"6"6tzz&++7N"OPr)   c                    | j                  | j                  d|j                                      | j                  |j	                         dd       y )N
LWPOLYLINEze.set_points([])rE   r   )rA   r   r>   r   
get_pointsr   s     r(   _lwpolylinez _SourceCodeGenerator._lwpolyline`  sO    ""!!,0A0A0CD	
 	!!(8 	" 	
r)   c                    | j                  | j                  ddg|j                                      t        |j                        r| j                  |j                  dd       t        |j                        r| j                  |j                  dd       t        |j                        r| j                  |j                  dd       t        |j                        r| j                  |j                  dd       y y )	Nzadd_spline(degreeze.fit_points = []r#  ze.control_points = [ze.knots = [ze.weights = [)	rA   r   r>   r  
fit_pointsr   control_pointsknotsweightsr   s     r(   _splinez_SourceCodeGenerator._splinei  s    ""MM-(V5F5F5HI	
 v  !%%!!*<S &  v$$%%%%%.DS &  v||%%]3 &  v~~%%s &  r)   c                (   | j                  | j                  d|j                                      |j                  D ]T  }t	        |j                               }|j                  d      }d|v r|d= | j                  dt        |       d| d       V y )NPOLYLINEr   r   ze.append_vertex(z, dxfattribs=r;   )rA   r   r>   verticesr=   r?   r@   r}   )rT   r   r   r   r   s        r(   	_polylinez_SourceCodeGenerator._polyline  s    ""!!*f.?.?.AB	
  	A$Q\\^4G{{:.H'!
 %%"3x=/wiqI	r)   c                    | j                  d       | j                  | j                  d|j                                      | j	                  |j
                  dd       y )N8# Dimension style attribute overriding is not supported!LEADERze.set_vertices([r"  r#  )r@   rA   r   r>   r   r0  r   s     r(   _leaderz_SourceCodeGenerator._leader  s]    !!F	
 	""!!(F,=,=,?@	
 	!!OO$6t 	" 	
r)   c                    | j                  d       | j                  d       | j                  | j                  d|j	                                      | j                  g d       y )Nz3from ezdxf.dimstyleoverride import DimStyleOverrider3  	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(   
_dimensionz_SourceCodeGenerator._dimension  sd    !!A	
 	!!F	
 	""!!+v/@/@/BC	
 	""	
r)   c                   | j                  d       | j                  | j                  d|j                                      t	        |j
                        r%| j                  d |j
                  D        dd       | j                  d       y )NzM# Image requires IMAGEDEF and IMAGEDEFREACTOR objects in the OBJECTS section!IMAGEc              3      K   | ]  }|  y wrK   rZ   r\   r   s     r(   r_   z._SourceCodeGenerator._image.<locals>.<genexpr>       1q1   e.set_boundary_path([r"  r#  zh# Set valid image_def_handle and image_def_reactor_handle, otherwise the DXF file is invalid for AutoCAD)r@   rA   r   r>   r  boundary_pathr   r   s     r(   _imagez_SourceCodeGenerator._image  s    !!	
 	""!!'6+<+<+>?	
 v##$%%1F001. & 
 	!!<	
r)   c                    | j                  | j                  d|j                                      t        |j                        r&| j                  d |j                  D        dd       y y )NWIPEOUTc              3      K   | ]  }|  y wrK   rZ   r=  s     r(   r_   z0_SourceCodeGenerator._wipeout.<locals>.<genexpr>  r>  r?  r@  r"  r#  )rA   r   r>   r  rA  r   r   s     r(   _wipeoutz_SourceCodeGenerator._wipeout  se    ""!!)V->->-@A	
 v##$%%1F001. &  %r)   c                   | j                  | j                  dg |j                                      t        |j                        r| j                  |j                  dd       t        |j                        r%| j                  d |j                  D        dd       t        |j                        r%| j                  d |j                  D        dd       t        |j                        r| j                  |j                  d	d       y y )
Nz	add_mesh(ze.vertices = [r(  r#  c              3  2   K   | ]  }t        |        y wrK   r   )r\   es     r(   r_   z-_SourceCodeGenerator._mesh.<locals>.<genexpr>       0aq0   ze.edges = [c              3  2   K   | ]  }t        |        y wrK   rI  )r\   fs     r(   r_   z-_SourceCodeGenerator._mesh.<locals>.<genexpr>  rK  rL  ze.faces = [ze.creases = [)	rA   r   r>   r  r0  r   edgesfacescreasesr   s     r(   _meshz_SourceCodeGenerator._mesh  s    ""MM+r6+<+<+>?	
 v%%(8 &  v||%%06<<0$ & 
 v||%%06<<0$ & 
 v~~%%s &  r)   c                    |j                         }d|d<   | j                  | j                  ddg|             | j                  |       y )Nr   associativez
add_hatch(color)r>   rA   r   _polygonrT   r   r>   s      r(   _hatchz_SourceCodeGenerator._hatch  sH    &&(
$%
=!""MM,	:>	
 	fr)   c                
   |j                         }| j                  | j                  ddg|             |j                  j                  r)| j                  d|j                  j                   d       | j                  |       y )Nzadd_mpolygon(rU  ze.set_solid_fill(color=z)
)r>   rA   r   r  
solid_fillr@   
fill_colorrV  rW  s      r(   	_mpolygonz_SourceCodeGenerator._mpolygon  sr    &&(
""MM/G9jA	
 ::  %%)&***?*?)@D 	fr)   c                   | j                   }t        |j                        r |d|j                   d       |j                  rG| j	                  t        t        |j                  j                        dd       | j                  d       d}|j                  |j                  } |d        ||j                  d	t        |j                                      ||j                  d
t        |j                                      ||j                  d|j                                ||j                  d|j                                ||j                  d|j                                ||j                  dt        j                   |j"                                      |d       t%        |j&                  d      D ]  \  }}|j(                  t*        j,                  k(  r |dj                  |             | j	                  |j.                  dd        ||j                  dt        |j0                                      ||j                  dt        |j2                                      |d        |d| d        |d|j2                   d       |j4                  D ]  }|j(                  t6        j8                  k(  r- |d|j:                   dt        |j<                         d       N|j(                  t6        j>                  k(  r |d        ||j                  dt        |j@                                      ||j                  d|jB                                ||j                  d|jD                                ||j                  d|jF                                ||j                  d |jH                                |d       0|j(                  t6        jJ                  k(  r |d!        ||j                  dt        |j@                                      ||j                  d"t        |jL                                      ||j                  d#|jN                                ||j                  d|jD                                ||j                  d|jF                                ||j                  d |jH                                |d       =|j(                  t6        jP                  k(  s\ |d$       |jR                  r9 ||j                  d%t        |jR                  D cg c]  }| c}                   |jT                  r9 ||j                  d&t        |jT                  D 	cg c]  }	|	 c}	                   |jV                  r+ ||j                  d't        |jV                                     |jX                  r+ ||j                  d(t        |jX                                      ||j                  d)|jZ                                ||j                  d*|j\                               |j^                  + ||j                  d+t        |j^                                     |j`                  + ||j                  d,t        |j`                                      |d         y c c}w c c}	w )-Nze.set_seed_points(r;   ze.set_pattern_definition([r"  r#  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(r  r  zep.add_spline(r)  r*  knot_valuesr,  r'  periodicstart_tangentend_tangent)1r@   r  seedspatternr   mapr}   linesgradientr   r^  r_  r`  ra  rb  r   r   r5   	enumeratepathstyper
   r/  r0  rd  path_type_flagsrO  r   LINEr   r   ARCr   r   r   r   rf  ELLIPSEr  r  SPLINEr)  r*  rg  r,  r'  rh  ri  rj  )
rT   r   rs   r   gcountpathedgefpcps
             r(   rV  z_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\\; L	&KE4yy,555.55e<=))MM8# * 
 KT^^1DEFGS1E1E-FGHKL 78L8L7MQO !JJ :&D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(F(F$G!"  ..$ #

$4$'d6I6I(J(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:&%L	&` )G )Ks   5	[:	[c                b    | j                  | j                  d|j                                      y )NLAYERrA   r   r>   )rT   r   s     r(   _layerz_SourceCodeGenerator._layere  )    ""  %*:*:*<=	
r)   c                <   | j                  d       | j                  d       | j                  d       | j                  | j                  d|j                                      | j	                  |j
                  j                  ddd       | j                  d	       y )
Nz!from ezdxf.lldxf.tags import Tagsz$from ezdxf.lldxf.types import dxftagz0from ezdxf.entities.ltype import LinetypePatternLTYPEztags = Tags([r"  r8   )rE   r   r:   z*    t.pattern_tags = LinetypePattern(tags))r   rA   r   r>   r   pattern_tagsr   r@   )rT   ltypes     r(   _ltypez_SourceCodeGenerator._ltypej  s    !!"EF!!"HI!!>	
 	""  %*:*:*<=	
 	!!##"	 	" 	
 	!!"NOr)   c                b    | j                  | j                  d|j                                      y )NSTYLEr  )rT   r   s     r(   _stylez_SourceCodeGenerator._style{  r  r)   c                b    | j                  | j                  d|j                                      y )NDIMSTYLEr  )rT   r   s     r(   	_dimstylez_SourceCodeGenerator._dimstyle  s)    ""  X-@-@-BC	
r)   c                b    | j                  | j                  d|j                                      y )NAPPIDr  )rT   appids     r(   _appidz_SourceCodeGenerator._appid  r  r)   )r-   rH   )r-   r}   rH   r}   )r   r   ry   rz   rK   )r3   Iterable[DXFEntity]r/   Optional[Iterable[str]]ry   rz   )r>   r   ry   rz   r   )r'   r}   ry   rz   )r'   r   ry   rz   )[r(  r   )
r   r   rE   r}   r   r}   r:   r|   ry   rz   ){}r   )
r   r   rE   r}   r   r}   r:   r|   ry   rz   )ztags = Tags(r;   r8   )r   r	   )ze = )r   r}   r>   r   r   r}   ry   r   )
r   r}   r   r   r>   r   r   r}   ry   r   )r   r}   r>   r   ry   r   )r   r   ry   rz   )r   r   ry   rz   )r   r   ry   rz   )r   r   ry   rz   )r   r   ry   rz   )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   )0r   r   r   r   rU   r   r2   r   r   r@   rA   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r
  r  r  r  r  r  r%  r-  r1  r5  r9  rB  rF  rR  rX  r\  rV  r  r  r  r  r  rZ   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"   boolry   r}   )r-   N)r3   r  r-   r}   r/   r  ry   r*   )rH   N)r<   r   rC   r}   r/   r  ry   r*   rG   )r3   r  ry   r*   )r   r   ry   r   r{   )r   r   r:   r|   ry   r   )r   r   r:   r|   ry   r   )r   r}   r   r   r>   r   ry   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   rZ   r)   r(   <module>r     s)   # = =  , ! 5 (    31)B: &*! $ 
	4 &* $ 
	B ,1!	Q1 Q1h 	P	!'59<&W	
 W	
r)   