Layer-Smart-Join entfernt — nie verwendet, auto Phase 2 macht's
- Alt+Click bypass im Cluster-Volume-Select-Handler raus.
- _layer_join_attempt + dJoin-Detection in smart_join.py raus.
Phase 2 automatic handling deckt die Use-Cases ab. Falls Manual-Layer-
Merge spaeter doch noetig: commit 118bc51 hat den Code als Referenz.
This commit is contained in:
@@ -296,80 +296,12 @@ def _l_join_attempt(doc, sel):
|
|||||||
doc.EndUndoRecord(ur)
|
doc.EndUndoRecord(ur)
|
||||||
|
|
||||||
|
|
||||||
def _layer_join_attempt(doc, wand_volumes):
|
|
||||||
"""Layer-Level Join: Versuch BoolUnion zwischen 2 wand_volume Breps.
|
|
||||||
Wenn beide gleiches Material haben + sich beruehren oder ueberlappen
|
|
||||||
→ mergen zu einem Brep. Behaelt UserStrings (= wand_id, material,
|
|
||||||
layer_idx) vom ersten Brep."""
|
|
||||||
if len(wand_volumes) != 2: return False
|
|
||||||
br0 = wand_volumes[0].Geometry
|
|
||||||
br1 = wand_volumes[1].Geometry
|
|
||||||
if not isinstance(br0, rg.Brep) or not isinstance(br1, rg.Brep):
|
|
||||||
return False
|
|
||||||
# Material-Check via UserStrings (= dossier_element_material)
|
|
||||||
mat0 = wand_volumes[0].Attributes.GetUserString(
|
|
||||||
"dossier_layer_material") or ""
|
|
||||||
mat1 = wand_volumes[1].Attributes.GetUserString(
|
|
||||||
"dossier_layer_material") or ""
|
|
||||||
if mat0 and mat1 and mat0 != mat1:
|
|
||||||
print("[SMART-JOIN] Layer-Join: Materialien unterschiedlich "
|
|
||||||
"({} vs {}), skip.".format(mat0, mat1))
|
|
||||||
return False
|
|
||||||
try:
|
|
||||||
union = rg.Brep.CreateBooleanUnion([br0, br1], 0.01)
|
|
||||||
except Exception as ex:
|
|
||||||
print("[SMART-JOIN] Layer-Join BoolUnion exc:", ex)
|
|
||||||
return False
|
|
||||||
if not union or len(union) == 0:
|
|
||||||
print("[SMART-JOIN] Layer-Join: Breps overlappen nicht "
|
|
||||||
"(BoolUnion returned None/empty)")
|
|
||||||
return False
|
|
||||||
if len(union) > 1:
|
|
||||||
print("[SMART-JOIN] Layer-Join: Breps overlappen nicht (BoolUnion"
|
|
||||||
" returned {} pieces, brauche 1)".format(len(union)))
|
|
||||||
return False
|
|
||||||
# 1 merged Brep
|
|
||||||
merged = union[0]
|
|
||||||
if not merged.IsValid:
|
|
||||||
print("[SMART-JOIN] Layer-Join: merged Brep invalid")
|
|
||||||
return False
|
|
||||||
try: merged.MergeCoplanarFaces(0.01)
|
|
||||||
except Exception: pass
|
|
||||||
ur = doc.BeginUndoRecord("DOSSIER Layer-Join")
|
|
||||||
try:
|
|
||||||
ok = doc.Objects.Replace(wand_volumes[0].Id, merged)
|
|
||||||
if ok:
|
|
||||||
doc.Objects.Delete(wand_volumes[1].Id, True)
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
finally:
|
|
||||||
doc.EndUndoRecord(ur)
|
|
||||||
|
|
||||||
|
|
||||||
def _run():
|
def _run():
|
||||||
doc = Rhino.RhinoDoc.ActiveDoc
|
doc = Rhino.RhinoDoc.ActiveDoc
|
||||||
if doc is None: return
|
if doc is None: return
|
||||||
sel = list(doc.Objects.GetSelectedObjects(False, False))
|
sel = list(doc.Objects.GetSelectedObjects(False, False))
|
||||||
if not sel:
|
if not sel:
|
||||||
Rhino.RhinoApp.RunScript("_Join", False); return
|
Rhino.RhinoApp.RunScript("_Join", False); return
|
||||||
# Layer-Level Join: wenn GENAU 2 wand_volume Breps selektiert + keine
|
|
||||||
# wand_axis → versuche Layer-Join (= BoolUnion der zwei Layer-Breps).
|
|
||||||
_wand_vols = [o for o in sel
|
|
||||||
if (o.Attributes.GetUserString("dossier_element_type")
|
|
||||||
or "") == "wand_volume"]
|
|
||||||
_wand_axes = [o for o in sel
|
|
||||||
if (o.Attributes.GetUserString("dossier_element_type")
|
|
||||||
or "") == "wand_axis"]
|
|
||||||
if (len(_wand_vols) == 2 and len(_wand_axes) == 0
|
|
||||||
and len(sel) == 2):
|
|
||||||
print("[SMART-JOIN] Layer-Join attempt: 2 wand_volume Breps")
|
|
||||||
try:
|
|
||||||
if _layer_join_attempt(doc, _wand_vols):
|
|
||||||
doc.Views.Redraw()
|
|
||||||
print("[SMART-JOIN] Layer-Join: Breps zu einem gemerged")
|
|
||||||
return
|
|
||||||
except Exception as ex:
|
|
||||||
print("[SMART-JOIN] Layer-Join exc:", ex)
|
|
||||||
# Info-Hint (T-Join unterstuetzt 1-Wand-Modus, L-Join braucht 2)
|
# Info-Hint (T-Join unterstuetzt 1-Wand-Modus, L-Join braucht 2)
|
||||||
n_wand_axes = sum(1 for o in sel
|
n_wand_axes = sum(1 for o in sel
|
||||||
if (o.Attributes.GetUserString("dossier_element_type")
|
if (o.Attributes.GetUserString("dossier_element_type")
|
||||||
|
|||||||
@@ -2778,11 +2778,6 @@ class _ClusterVolumeSelectHandler(Rhino.UI.MouseCallback):
|
|||||||
try:
|
try:
|
||||||
if "Left" not in str(e.MouseButton): return
|
if "Left" not in str(e.MouseButton): return
|
||||||
except Exception: pass
|
except Exception: pass
|
||||||
# Alt-Click bypassed Cluster-Swap → user kann Layer-Breps
|
|
||||||
# direkt anwaehlen (= fuer Layer-Smart-Join)
|
|
||||||
try:
|
|
||||||
if bool(e.AltKeyDown): return
|
|
||||||
except Exception: pass
|
|
||||||
view = e.View
|
view = e.View
|
||||||
if view is None: return
|
if view is None: return
|
||||||
vp = view.ActiveViewport
|
vp = view.ActiveViewport
|
||||||
|
|||||||
Reference in New Issue
Block a user