git.lucas.co / hou-control
git clone https://git.lucas.co/hou-control.git

commit11432efe4dd70c6f848d1c1cf3f8b6cc3ff14614
parent7b64287d9e
authorLucas Galante <lsgalante12@gmail.com>
date2026-04-16 21:11
hc: add automatic node tagging and global color update tool

 MainMenuCommon.xml             | 11 ++++++++---
 python3.11libs/hc/hcsession.py | 18 ++++++++++++++++++
 scripts/OnCreated.py           |  1 +
 3 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/MainMenuCommon.xml b/MainMenuCommon.xml
index ace9d0b..ed6d01d 100755
--- a/MainMenuCommon.xml
+++ b/MainMenuCommon.xml
@@ -27,11 +27,16 @@
       </scriptItem>
 
       <scriptItem id="h.hc_session_reloadcolors">
-        <label>Reload Colors</label>
-        <scriptCode><![CDATA[from hc import HCSession; HCSession().reloadColorSchemes()]]></scriptCode>
+        <label>Reload Viewport Colors</label>
+        <scriptCode><![CDATA[from hc import HCSession; HCSession().reloadViewportColors()]]></scriptCode>
       </scriptItem>
 
-      <scriptItem id="h.hc_session_reloadhotkeys">
+      <scriptItem id="h.hc_session_updatenodecolors">
+        <label>Update Node Colors</label>
+        <scriptCode><![CDATA[from hc import HCSession; HCSession().updateNodeColors()]]></scriptCode>
+      </scriptItem>
+
+      <scriptItem id="h.hc_session_reloadkeycam">
         <label>Reload Hotkeys</label>
         <scriptCode><![CDATA[from hc import HCSession; HCSession().reloadHotkeys()]]></scriptCode>
       </scriptItem>
diff --git a/python3.11libs/hc/hcsession.py b/python3.11libs/hc/hcsession.py
index 656fc13..c61f890 100644
--- a/python3.11libs/hc/hcsession.py
+++ b/python3.11libs/hc/hcsession.py
@@ -203,6 +203,24 @@ class HCSession:
     def reloadHotkeys(self):
         HCBindings().load()
 
+    def updateNodeColors(self):
+        from .hcsettings import HCSettings
+        prefs = HCSettings().prefs()
+        hex_color = prefs.get('node_graph').get('node_color').lstrip('#')
+        r = int(hex_color[0:2], 16) / 255.0
+        g = int(hex_color[2:4], 16) / 255.0
+        b = int(hex_color[4:6], 16) / 255.0
+        new_color = hou.Color(r, g, b)
+
+        count = 0
+        for node in hou.node("/").allSubChildren():
+            # Check for the custom tag we just added to OnCreated.py
+            if node.userData("hc_custom_color") == "1":
+                node.setColor(new_color)
+                count += 1
+        
+        hou.ui.setStatusMessage(f"Updated {count} custom-colored nodes to {hex_color}")
+
     def keycam(self):
         tab = self.currentTab()
         if tab is not None and tab.type() == 'HCSceneViewer':
diff --git a/scripts/OnCreated.py b/scripts/OnCreated.py
index 2d622e4..38288a2 100644
--- a/scripts/OnCreated.py
+++ b/scripts/OnCreated.py
@@ -7,6 +7,7 @@ node = HCNode(kwargs['node'])
 prefs = HCSettings().prefs()
 
 node.setUserData("nodeshape", "rect")
+node.setUserData("hc_custom_color", "1")
 
 hex_color = prefs.get('node_graph').get('node_color')
 hex_color = hex_color.lstrip('#')