#! python3 # -*- coding: utf-8 -*- # Wrapper fuer dSection: interaktiver Schnitt-Pick (2 Punkte + Blickrichtung). # Defaults kommen aus Project-Settings.defaults; nach erfolgreicher # Erstellung wird der neue Schnitt als aktive Zeichnungs-Ebene set. import sys, os sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) import Rhino import scriptcontext as sc doc = Rhino.RhinoDoc.ActiveDoc if doc is None: print("[SECTION] kein aktives Dokument") else: try: import schnitte # Defaults aus Project-Settings; Fallback auf hartkodierte Werte. defaults = { "depthBack": 8.0, "heightMin": -1.0, "heightMax": 12.0, "cutAtLine": True, "namePrefix": "S", } try: import layers_panel as rhinopanel ps = rhinopanel.load_project_settings(doc) d = (ps or {}).get("defaults", {}) defaults["depthBack"] = float(d.get("schnittDepthBack", 8.0)) defaults["heightMin"] = float(d.get("schnittHeightMin", -1.0)) defaults["heightMax"] = float(d.get("schnittHeightMax", 12.0)) except Exception as ex: print("[SECTION] defaults from project-settings:", ex) sid = schnitte.pick_schnitt_interactive(doc, defaults=defaults) if not sid: print("[SECTION] abgebrochen") else: # Broadcast neue Zeichnungs-Ebene an Panels + auto-aktivieren try: eb = sc.sticky.get("ebenen_bridge") if eb is not None: eb._send_state() except Exception as ex: print("[SECTION] broadcast:", ex) try: import json zraw = doc.Strings.GetValue("dossier_zeichnungsebenen") or "[]" z_list = json.loads(zraw) new_z = next((x for x in z_list if isinstance(x, dict) and x.get("id") == sid), None) if new_z is not None: eb = sc.sticky.get("ebenen_bridge") if eb is not None: eb._set_active_zeichnungsebene(new_z) print("[SECTION] erstellt: {}".format(sid)) except Exception as ex: print("[SECTION] auto-activate:", ex) except Exception as ex: print("[SECTION] error:", ex)