Files
DOSSIER/rhino/tools.py
T
karim b9a2124026 Rename all log tags to match English module names
[EBENEN] → [LAYERS], [EBENEN-BE] → [LAYERS-BE]
[ZEICHNUNGSEBENEN] → [DRAWING-LEVELS]
[GESTALTUNG] → [STYLES]
[OBERLEISTE] → [TOOLBAR]
[WERKZEUGE] → [TOOLS]
[DIMENSIONEN] → [DIMENSIONS]
[AUSSCHNITTE] → [VIEWPORTS]
[MASSSTAB] → [SCALE]
[SCHNITT] → [SECTION], [SCHNITT_GRIPS] → [SECTION-GRIPS]
[WAND_GRIPS] → [WALL-GRIPS], [TREPPE_GRIPS] → [STAIR-GRIPS]
[CURVE_DOTS] → [CURVE-DOTS]
[panel_base] → [CORE]
[ALIAS-LOADER] → [ALIASES]
[BEGIN-CMD] → [CMD-HOOK]
2026-06-06 12:48:27 +02:00

61 lines
1.9 KiB
Python

#! python 3
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright (C) 2026 Karim Gabriele Varano
"""
werkzeuge.py
WERKZEUGE-Panel: Architektur-orientierte Toolbar als React-WebView.
Feuert Rhino-Befehle via RunScript bei Button-Klick.
"""
import os
import sys
import Rhino
import scriptcontext as sc
_HERE = os.path.dirname(os.path.abspath(__file__))
if _HERE not in sys.path:
sys.path.insert(0, _HERE)
import panel_base
PANEL_GUID_STR = "6d9f5040-7e1f-4f2b-c4d5-f6071829304a"
class WerkzeugeBridge(panel_base.BaseBridge):
def __init__(self):
panel_base.BaseBridge.__init__(self, "werkzeuge")
def _on_ready(self):
# Keine initialen Daten noetig — Toolbar ist statisch
pass
def handle(self, data):
if not isinstance(data, dict): return
t = data.get("type", "")
p = data.get("payload") or {}
if not isinstance(p, dict): p = {}
if t == "READY":
self._on_ready()
elif t == "RUN":
cmd = p.get("cmd")
if cmd and isinstance(cmd, str):
# Whitelist: alles muss mit "_" beginnen (Rhino-Befehl) und
# darf keine Zeilenumbrueche oder Semikolons enthalten.
cmd = cmd.strip()
if cmd.startswith("_") and "\n" not in cmd and ";" not in cmd:
try:
Rhino.RhinoApp.RunScript(cmd, False)
print("[TOOLS] {}".format(cmd))
except Exception as ex:
print("[TOOLS] RunScript-Fehler:", ex)
else:
print("[TOOLS] Befehl ignoriert (kein '_' Praefix oder unsicher):", cmd)
def _bridge_factory():
return WerkzeugeBridge()
panel_base.register_and_open("werkzeuge", "Werkzeuge", PANEL_GUID_STR, _bridge_factory,
icon_spec=("build", "#3a6fa8"))