diff --git a/rhino/elemente.py b/rhino/elemente.py index fe25ff4..43f25f6 100644 --- a/rhino/elemente.py +++ b/rhino/elemente.py @@ -1879,6 +1879,34 @@ def _make_traeger_preview(first_pt, profil, B, H, D, t, angle): return handler +def _snap_endpoint_to_other_wand_axis(doc, my_wall_id, ep, tol=0.05): + """Snap einen Endpunkt auf die naechste OTHER wand_axis (within tol). + Ignoriert self. Default 5cm — tight genug um nur intentionale Move- + Naehe zu erfassen, lose genug um typische Snap-Drift zu fixen. + + Return: snapped Point3d oder None wenn nichts in Reichweite.""" + if ep is None: return None + best = None; best_d = tol + for obj in doc.Objects: + try: + t = obj.Attributes.GetUserString(_KEY_TYPE) or "" + wid = obj.Attributes.GetUserString(_KEY_ID) or "" + except Exception: continue + if t != "wand_axis" or wid == my_wall_id: continue + g = obj.Geometry + if not isinstance(g, rg.Curve): continue + try: + rc, par = g.ClosestPoint(ep) + if not rc: continue + cp = g.PointAt(par) + d = ((cp.X - ep.X) ** 2 + (cp.Y - ep.Y) ** 2) ** 0.5 + if d > 1e-6 and d < best_d: + best_d = d + best = rg.Point3d(cp.X, cp.Y, ep.Z) + except Exception: continue + return best + + def _t_snap_to_wand_axis(doc, pt, tol=0.15): """Snap pt auf die naechste wand_axis. Zwei Pfade: