
    ^j+                    |    d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	m
Z
 ddlmZmZmZmZmZmZ  G d dee         Zy	)
a  
BuildSketch

name: build_sketch.py
by:   Gumyr
date: July 12th 2022

desc:
    This python module is a library used to build planar sketches.

license:

    Copyright 2022 Gumyr

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

    )annotations)BuilderWorkplaneList)Mode)LocationPlane)CompoundEdgeFace	ShapeListSketchWirec                       e Zd ZdZd ZdZeZeZ	e
j                  d	 	 	 d fdZedd       Zej                  dd       Zedd       Zej                  dd       Zed	        Zd
 Zd ZddZddddZ xZS )BuildSketcha  BuildSketch

    The BuildSketch class is a subclass of Builder for building planar 2D
    sketches (objects with area but not volume) from faces or lines.
    It has an _obj property that returns the current sketch being built.
    The sketch property consists of the sketch(es) applied to the input
    workplanes while the sketch_local attribute is the sketch constructed
    on Plane.XY. The class overrides the solids method of Builder since
    they don't apply to lines.

    Note that all sketch construction is done within sketch_local on Plane.XY.
    When objects are added to the sketch they must be coplanar to Plane.XY,
    usually handled automatically but may need user input for Edges and Wires
    since their construction plane isn't always able to be determined.

    Args:
        workplanes (Union[Face, Plane, Location], optional): objects converted to
            plane(s) to place the sketch on. Defaults to Plane.XY.
        mode (Mode, optional): combination mode. Defaults to Mode.ADD.
    sketch)modec               ^    || _         d | _        t               | _        t	        |   |d|i y )Nr   )r   _sketch_localr   pending_edgessuper__init__)selfr   
workplanes	__class__s      O/opt/ringagent/.cad-venv/lib/python3.12/site-packages/build123d/build_sketch.pyr   zBuildSketch.__init__@   s0    
 	,0.7k*040    c                    | j                   S )zGet the builder's objectr   r   s    r   sketch_localzBuildSketch.sketch_localJ        !!!r   c                    || _         y)zSet the builder's objectNr   r   values     r   r    zBuildSketch.sketch_localO        #r   c                    | j                   S )zAlias _obj to sketchr   r   s    r   _objzBuildSketch._objT   r!   r   c                    || _         y)zSet the current sketchNr   r#   s     r   r'   zBuildSketch._objY   r%   r   c                   | j                   r| j                   nt        j                         j                  }g }|D ],  }|j	                  |j                  | j                               . t        t        |      j                        S )z@The global version of the sketch - may contain multiple sketches)
exit_workplanesr   _get_contextr   appendfrom_local_coordsr'   r   r	   wrapped)r   r   global_objsplanes       r   r   zBuildSketch.sketch^   sz    
 ##   ++-88 	
  	CEu66tyyAB	Ch{+3344r   c                    t        d      )zsolids() not implementedz%solids() doesn't apply to BuildSketchNotImplementedErrorr   argss     r   solidszBuildSketch.solidsk   s    !"IJJr   c                    t        d      )zsolid() not implementedz$solid() doesn't apply to BuildSketchr2   r4   s     r   solidzBuildSketch.solido   s    !"HIIr   c                j    t        j                  | j                        }t        |      dkD  r|S |d   S )z*Unify pending edges into one or more Wires   r   )r   combiner   len)r   wiress     r   consolidate_edgeszBuildSketch.consolidate_edgess   s/    T//0E
Qu4E!H4r   N)
face_planec               T    |rt        d      | j                  j                  |       y)z<Integrate a sequence of objects into existing builder objectz,face_plane arg not supported for this methodN)r3   r   extend)r   r?   objectss      r   _add_to_pendingzBuildSketch._add_to_pendingx   s%    %&TUU!!'*r   )r   zFace | Plane | Locationr   r   )returnzSketch | None)r$   r   rD   None)rD   zWire | list[Wire])rB   r
   r?   zPlane | None)__name__
__module____qualname____doc___tag	_obj_namer   _shaper   
_sub_classr   ADDr   propertyr    setterr'   r   r6   r8   r>   rC   __classcell__)r   s   @r   r   r   %   s    * DIFJ
 XX1,1 1 " " # # " " 
[[# # 
5 
5KJ5
 JN + +r   r   N)rI   
__future__r   build123d.build_commonr   r   build123d.build_enumsr   build123d.geometryr   r   build123d.topologyr	   r
   r   r   r   r   r    r   r   <module>rX      s0   8 # 9 & . L LW+'&/ W+r   