Files
DOSSIER/rhino/begin_cmd_hook.py
T
karim 18d6d98e07 DOSSIER Multi-Phase: C#-Plugin + Yak + Wandstile + UX-Polish
- C#-Plugin "DOSSIER" mit 23 nativen Commands (dWall, dDoor, ..., dSection)
  - Native Command-Namen + Autocomplete + saubere History
  - Idle-Defer + RhinoCode-API → kein _-RunPythonScript-Echo
  - Yak-Paket via build.sh, Install in ~/Library/.../packages/8.0/
- Launcher (Tauri):
  - dossier_init Tauri-Command + Setup-Tab in Settings
  - Yak-Install + StartupCommands-XML + Window-Layout in einem Schritt
  - clean-rhino.sh fuer reproduzierbare Resets
  - check_dossier_initialized triggert Auto-Open-Setup beim ersten Start
- Wand-Architektur:
  - Chain-Logik DEAKTIVIERT → jede Wand baut eigenes Volume (individuell
    anwaehlbar, einzeln loeschbar)
  - Polyline-Wand: jedes Segment = eigene Wand
  - Smart-Split fuer wand_axis/decke/dach/raum/aussparung/traeger
  - Auto-Group axis+volume → kein ChooseOne-Dialog, Delete loescht beides
  - Stale-Mitre-Fix: Joint-Cache wird vor jedem Wand-Regen invalidiert
  - T-Junction-Tolerance auf 1mm (war 1cm, lieferte falsche T-Mitres)
- Wand-Stile:
  - Schema in dossier_project_settings.wand_styles (Material + Prio +
    Default-Dicke + Referenz, oder Layered mit Schichten)
  - dWall-Command Stil-Picker
  - ProjectSettingsDialog: Sidebar-Layout (Pill-Selection) +
    Wandstile-Tab mit Liste/Editor
  - _wand_chain_compat benutzt style_id
  - Prio-Dominanz: hoehere Prio gewinnt Eckverbindung, niedrigere wird
    T-mitered (siehe _resolve_corner_miter)
- Cmd+G fuer Group (Geschoss-Up auf Alias 'gu')
- Welcome + Cheatsheet borderless mit X/Back-Buttons
- BeginCommand-Hook fuer Gestaltung-Panel-Auto-Open
- panel_base: Python.NET-Enum-Fix fuer Material-Render
2026-05-30 12:46:53 +02:00

80 lines
2.5 KiB
Python

#! python3
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright (C) 2026 Karim Gabriele Varano
"""
begin_cmd_hook.py
Hook auf Rhino.Commands.Command.BeginCommand. Wenn der User ein Drawing-
Command startet (Line, Polyline, Rectangle, Circle etc.), oeffnen wir
automatisch das DOSSIER-Gestaltung-Panel und bringen es in den Vordergrund.
Idempotent — Re-Install nach _reset_panels deregistriert alten Handler.
"""
import Rhino
import scriptcontext as sc
import System
# Commands bei denen wir Gestaltung-Panel fokussieren.
# CommandEnglishName ohne Underscore-Prefix.
_DRAWING_COMMANDS = {
"Line", "Polyline", "Curve", "InterpCrv",
"Arc", "Circle", "Ellipse",
"Rectangle", "Polygon",
"Hatch", "Text",
"Point", "Points",
"InfiniteLine",
}
_GESTALTUNG_PANEL_GUID = "4b8d3f2e-5c9d-4e0f-b2c3-d4e5f6071829"
_HANDLER_KEY = "_dossier_begin_cmd_handler"
_VERBOSE_KEY = "_dossier_begin_cmd_verbose"
def _on_begin_command(sender, e):
try:
cmd = getattr(e, "CommandEnglishName", "") or ""
if sc.sticky.get(_VERBOSE_KEY):
print("[BEGIN-CMD] cmd='{}'".format(cmd))
if cmd not in _DRAWING_COMMANDS: return
try:
guid = System.Guid(_GESTALTUNG_PANEL_GUID)
Rhino.UI.Panels.OpenPanel(guid)
try:
Rhino.UI.Panels.FocusPanel(guid)
except Exception: pass
if sc.sticky.get(_VERBOSE_KEY):
print("[BEGIN-CMD] Gestaltung-Panel geoeffnet/fokussiert")
except Exception as ex:
print("[BEGIN-CMD] OpenPanel:", ex)
try:
Rhino.RhinoApp.RunScript(
'-_ShowPanel "DOSSIER Gestaltung"', False)
except Exception: pass
except Exception as ex:
print("[BEGIN-CMD] handler:", ex)
def install(verbose=False):
"""Einmalige Registrierung. Bei Re-Install (z.B. nach _reset_panels)
wird der alte Handler-Ref aus sc.sticky deregistriert."""
old = sc.sticky.get(_HANDLER_KEY)
if old is not None:
try: Rhino.Commands.Command.BeginCommand -= old
except Exception: pass
try:
Rhino.Commands.Command.BeginCommand += _on_begin_command
sc.sticky[_HANDLER_KEY] = _on_begin_command
sc.sticky[_VERBOSE_KEY] = bool(verbose)
print("[BEGIN-CMD] Hook installed (verbose={})".format(bool(verbose)))
except Exception as ex:
print("[BEGIN-CMD] install:", ex)
def set_verbose(flag):
sc.sticky[_VERBOSE_KEY] = bool(flag)
if __name__ == "__main__":
install(verbose=True)