o
    .;j                  
   @   sj   d Z ddlZd	ddZze  ejd W dS  ey4 Z zejde d W Y dZ[dS dZ[ww )
a  Auto-imported patch (when this dir is on PYTHONPATH): make build123d 0.11's
Compound.center() robust. TOM's gen_urdf calls .center() on custom build123d
parts whose Compound nesting trips a `_wrapped is None` AssertionError in 0.11;
the true centroid is still recoverable by collapsing to a solids-only Compound,
else the bbox center. Logs each fallback so we learn which parts are affected.
Scoped: only active when tom_build.sh puts this dir on PYTHONPATH.
    Nreturnc                     s>   ddl m}  t| ddrd S | j  fdd}|| _d| _d S )Nr   Compound_tom_center_patchedFc                    s   z | g|R i |W S  t y } zgzt|  }W n t y'   g }Y nw |r`z,ddlm} ||dj|i |}tjdt	| dt
|j d |W W  Y d }~S  t y_   Y nw |  }tjdt
|j d | W  Y d }~S d }~ww )Nr   r   )childrenz0[tom_patch] center(): solids-collapse fallback (z solids) after 
z1[tom_patch] center(): bbox-center fallback after )	Exceptionlistsolids	build123dr   centersysstderrwritelentype__name__bounding_box)selfargskwargsexcr
   _Cvalbb_orig B/data/cameron/repos/smith300_para_stuff/tom_patch/sitecustomize.py_safe_center   s@   z_patch.<locals>._safe_centerT)build123d.topology.compositer   getattrr   r   )r   r   r   r   r   _patch   s   
r"   z>[tom_patch] build123d Compound.center robustness patch active
z[tom_patch] patch failed: r   )r   N)__doc__r   r"   r   r   r   _excr   r   r   r   <module>   s    
&"