feat: shelf tool (replaces broken panel), PySide6 fix, descriptor uses HOUDINI_USER_PREF_DIR
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"hpath": "/home/niklas/Documents/projects_privat/hermes-houdini-bridge",
|
||||
"hpath": "$HOUDINI_USER_PREF_DIR/hermes_houdini_bridge",
|
||||
"env": [
|
||||
{"HHB_PACKAGE": "/home/niklas/Documents/projects_privat/hermes-houdini-bridge"}
|
||||
{"HHB_PACKAGE": "$HOUDINI_USER_PREF_DIR/hermes_houdini_bridge"}
|
||||
],
|
||||
"load_package_once": true,
|
||||
"enable": "houdini_version >= '21.0'"
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shelfDocument>
|
||||
<tool name="hermes_bridge_toggle" label="Hermes Bridge" icon="MISC_python">
|
||||
<help>Toggle the Hermes-Houdini Bridge on/off. \nRight-click: Set port.</help>
|
||||
<script scriptType="python"><![CDATA[
|
||||
import hou
|
||||
import socket
|
||||
import json
|
||||
import os
|
||||
|
||||
# ── Config ──────────────────────────────────────────
|
||||
CONFIG_FILE = os.path.join(hou.homeHoudiniDirectory(), "hermes_bridge.json")
|
||||
DEFAULT_PORT = 12345
|
||||
|
||||
def load_port():
|
||||
try:
|
||||
with open(CONFIG_FILE) as f:
|
||||
return json.load(f).get("port", DEFAULT_PORT)
|
||||
except Exception:
|
||||
return DEFAULT_PORT
|
||||
|
||||
def save_port(p):
|
||||
with open(CONFIG_FILE, "w") as f:
|
||||
json.dump({"port": p}, f, indent=2)
|
||||
|
||||
def is_open(port):
|
||||
result = hou.hscript("openport")[0]
|
||||
return f"Port {port} is open" in result
|
||||
|
||||
def toggle(port):
|
||||
if is_open(port):
|
||||
hou.hscript(f"closeport {port}")
|
||||
hou.ui.displayMessage(
|
||||
f"Bridge CLOSED on port {port}",
|
||||
severity=hou.severityType.ImportantMessage,
|
||||
title="Hermes Bridge"
|
||||
)
|
||||
else:
|
||||
hou.hscript(f"closeport {port}")
|
||||
hou.hscript(f"openport {port} 0.0.0.0")
|
||||
host = socket.gethostname()
|
||||
hou.ui.displayMessage(
|
||||
f"Bridge OPEN — {host}:{port}\n\n"
|
||||
f"Copy to Hermes:\n"
|
||||
f'"Hey Hermes, I have Houdini open on {host} (port {port})"',
|
||||
severity=hou.severityType.ImportantMessage,
|
||||
title="Hermes Bridge"
|
||||
)
|
||||
|
||||
# ── Right-click: set port ───────────────────────────
|
||||
kwargs = kwargs if "kwargs" in dir() else {}
|
||||
if kwargs.get("altclick") or kwargs.get("ctrlclick"):
|
||||
port = load_port()
|
||||
new = hou.ui.readInput(
|
||||
"Bridge port number",
|
||||
buttons=("OK", "Cancel"),
|
||||
default_choice=0,
|
||||
title="Hermes Bridge — Port",
|
||||
initial_contents=str(port)
|
||||
)
|
||||
if new and new[0]:
|
||||
try:
|
||||
new_port = int(new[1].strip())
|
||||
save_port(new_port)
|
||||
hou.ui.displayMessage(
|
||||
f"Port set to {new_port}",
|
||||
severity=hou.severityType.Message,
|
||||
title="Hermes Bridge"
|
||||
)
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
toggle(load_port())
|
||||
]]></script>
|
||||
</tool>
|
||||
</shelfDocument>
|
||||
Reference in New Issue
Block a user