
    ^j                        d Z ddlmZ ddlZddlZddlZddlZddlZddl	Z	ddl
mZ ddlmZmZ ddZddZedk(  r* e ee	j&                  d	   e	j&                  d
                yy)a!  Work order: the commercial paperwork the jeweler prints with the job.

Self-contained HTML: spec, exact dims, per-alloy weights, print/cast
instructions with the shrink-compensation warning, setting notes, and a QC
checklist. Volumes come from the exported STLs (trimesh): no CAD rebuild.
    )annotationsN)Path)DENSITYalloy_from_metalc                4   t         j                  j                  d|       }t         j                  j                  |      }t        j
                  j                  dt        | j                               |j                  j                  |       |j                  S )Ngen_modr   )	importlibutilspec_from_file_locationmodule_from_specsyspathinsertstrparentloaderexec_moduleSPEC)gen_pathspecmods      #/opt/ringagent/ringcli/workorder.py
_load_specr      sb    >>11)XFD
..
)
)$
/CHHOOAs8??+,KKC 88O    c                J   t        |       }t        |      }t        |      }|d   }ddlm}  ||      }dd l}|j                  || dz        }|j                  t        |j                  | d            }	|	r|	d   j                  nd}
|	r|j                  |	d         j                  ndt        |j                  d	i       j                  d
d            }t        |j                  dd      |j                  d	            |j                  d      }t        |j                  d            xs |d u}|d   }|| dz  }d}|j                         r7t        j                   |j#                               j%                         }d| d}dj'                  fdt)        j*                         D              }|rc|d    d|d    d|j                  dd       dt-        j.                  t1        |j                  di       j                  dd                   d}d}n|d    d!d|d"   d!d#}d$}|dk7  rd%|d&d'}nd(}|d)   }|d*k(  rd+|j                  d,|d-          d.}n)d/|j                  d0d1       d2|j                  d3d4       d5}|d6v r|d7z  }t2        j4                  j7                         j9                         }dj'                  g d8t-        j.                  |       d9t-        j.                  |       d:| d;| d<|j                  d=       d>d?|d@   z  d!dA|dB   d!d|dC   d!dD|dE   |dF   z   dGdH|rdIndJ dK|j                  dL       dM| dN|j                  dO       dP| dQdGdRdGdS| dTt-        j.                  |
       dU| dV| dW|j                  d=       dXt-        j.                  t;        j<                  |d?Y             dZ      }|| d[z  }|j?                  |       t1        |      S )\Nnamer   )	head_dimsz	-cast.stlz-print*.stlz(print STL missing)g        castingshrink_scaleg      ?metalwhitestone_mm
productionstylez.png z <img src="data:image/png;base64,z" style="max-width:420px">c           
   3  `   K   | ]%  \  }}d |k(  rdnd d| d|z  dd|z  dd	 ' yw)	z<trz	 class=hlr&   z><td>z	</td><td>.2fz g</td><td>z g</td></tr>N ).0adalloy	print_volvols      r   	<genexpr>z"write_workorder.<locals>.<genexpr>7   sW      % Aq Q%ZkR0aS 9Qwsm;y1}S&9	G%s   +.widthu    × lengthdepth?z mm (from cert stonecertzn/a)stone_wr(   stone_lz mmzT<p class="warn">ESTIMATED from carat: measure the physical stone before setting.</p>u+   <p class="warn">Print file is PRE-SCALED ×z.4fz8 for casting shrinkage: slicer scale MUST stay 100%.</p>z<p class="warn">Print file is at NOMINAL size: apply your calibrated shrink % in the slicer (run <code>ringcli calibrate</code> to dial it in).</p>archbezelzBezel: lip bezel_lip_mm	bezel_lipzA mm above girdle, clearance built in: burnish over after seating.zProngs: tips extend ~prong_overlength_mmg333333?z mm above the crown. Cut the bearing at girdle height (~1/2 prong depth), seat the stone, bend and shape tips. Bearing clearance seat_clearance_mmg{Gz?z9 mm per side is built into the seat: do not open further.)halopaveuo    Halo/pavé melee are DECORATIVE in CAD: bench-set with calibrated melee; the azure holes are the drill guides.z9<!doctype html><meta charset="utf-8">
<title>Work order: u"  </title>
<style>
body{font:14px/1.5 -apple-system,sans-serif;max-width:820px;margin:2em auto;padding:0 1em}
h1{font-size:1.4em} h2{font-size:1.05em;margin-top:1.6em;border-bottom:1px solid #ccc}
table{border-collapse:collapse} td,th{border:1px solid #ccc;padding:4px 10px}
.hl{background:#fdf3d0;font-weight:600}
.warn{background:#fde8e8;border:1px solid #e0a0a0;padding:8px 12px;border-radius:6px}
ul.qc{list-style:none;padding:0} ul.qc li::before{content:"☐ "}
code{background:#eee;padding:1px 5px;border-radius:4px}
</style>
<h1>Work order: z	 <small>(z)</small></h1>
z
<h2>Ring</h2>
<p>US size sizeu   : inner Ø    inner_ru    mm ·
band 
band_widthband_thicknessu    mm ·
head top girdle_zcrown_hz.1fu    mm from center ·
zPRODUCTION buildz"CONCEPT build (not for production)z</p>
<h2>Stone</h2>
<p>cutz: z, caratz ct nominal</p>
z
<h2>Metal</h2>
<p>Cast body u    mm³; with sprue/stems uQ    mm³.</p>
<table><tr><th>alloy</th><th>ring weight</th><th>with sprues</th></tr>zy</table>
<p><small>Densities are nominal: confirm with your caster.</small></p>
<h2>Print &amp; cast</h2>
<p>Print <code>z</code> in castable resin, upright as
exported (sprue and stems land on the plate). Add fine slicer supports for any
overhangs the stems don't cover. Standard burnout for your resin; our sprue is
the casting feed.</p>
z
<h2>Setting</h2>
<p>u   </p>
<h2>QC checklist</h2>
<ul class="qc">
<li>Seat coupon printed; REAL stone drops to girdle line, sits level</li>
<li>Print ID / band dims spot-checked with calipers</li>
<li>Cast ring ID within ±0.05 mm of size z</li>
<li>No porosity at prong bases / bezel lip</li>
<li>Prongs full length after cleanup</li>
<li>Stone tight and level after setting</li>
<li>Final weight recorded vs estimate</li>
</ul>
<h2>Spec</h2>
<pre>)indentz</pre>
z-workorder.html) r   r   ringcli.templatesr   trimeshloadvolumesortedglobr   floatgetr   boolexistsbase64	b64encode
read_bytesdecodejoinr   itemshtmlescaper   datetimedatetoday	isoformatjsondumps
write_text)r   outdirgenr   r   r   hdrM   castprints
print_fileshrinkr#   r$   stpngimgb64rows
stone_desc
stone_warn
shrink_boxr:   settingnowdocoutr-   r.   r/   s                              @@@r   write_workorderrx      s   
x.C&\Fc?D<D+	4B<<D6!334D
++CFKK4& 456F$*0EJ39VBZ(//sI488Ir*..~sCDFTXXgw7)9LMExx
#Hdhh|,-E1EJ	GB
dV4=
 C
C
zz|s~~/077905OP77 % MMO% %D
 !'*+40B/C4!gs34OS'2)>)B)B65)Q%RSTTUW
 
Is+49c/B#F
;
 }CF3< PP Q
P
 f:Dw ;!H I JM M +2662G+M*N O  !#':D AB C??
  N 	O --



)
)
+C- -  -KK%&-
'- T"#- $-- .1E-2- -- HHV- )- *+R	]):3(?-@- 	s-  - !##3 4S9-:
-  Z.2i=
(	-!- .!-" "'K L#-"M#-& 	HHUO'-& '-& "l'-& #%'-& &*XXg%6$7'-&8'-( )-()-, #Y--, /--, 09o--,>G--. HLf/-.M/-4 J'(5-4)5-< =-<=-@ 9A-@+A-J ,088F+;*<K-J=K-X kk$**T!,-.Y-X/Y-C\ dV?+
+CNN3s8Or   __main__   rC   )r   r   returndict)r   r   re   r   r{   r   )__doc__
__future__r   rV   r^   r\   importlib.utilr	   rb   r   pathlibr   ringcli.alloysr   r   r   rx   __name__printargvr)   r   r   <module>r      sa    #      
  4pf z	/#((1+sxx{
34 r   