SideFX Houdini customization package
git clone https://git.lucas.co/hou-control.git
python3.13libs/hc/hcpathtab.py (1.9K)
1 import hou
2 from .hcgeo import HCGeo
3 from .hcgeometryutils import merged_visible_geo
4 from .hccommands import command
5 from .hctab import HCTab
6 from .hcvisibility import childCategory, collect_visible_nodes
7
8
9 class HCPathTab(HCTab):
10 """A tab that is looking at a node -- Parm, DetailsView, and everything
11 below it in the hierarchy.
12
13 pwd() returns a plain hou.Node. It used to return an HCNode wrapper, which
14 the rest of the package bypassed 22 calls to 1 and which lacked path(), so
15 HCPathTab.path() -- and the Show Path Message command through it -- raised
16 AttributeError.
17 """
18
19 def __init__(self, hou_tab):
20 self.hou_tab = hou_tab
21
22 def pwd(self):
23 return self.hou_tab.pwd()
24
25 """ Pin """
26
27 # HOM puts isPin()/setPin() on every hou.PaneTab, but the pin holds a
28 # tab's *path* against the pane's link group, which only a path-based
29 # tab has -- so the command lives here, not on HCTab, and every subclass
30 # (Parm, DetailsView, NetworkEditor, SceneViewer) inherits it.
31
32 def isPin(self):
33 return self.hou_tab.isPin()
34
35 def setPin(self, value):
36 self.hou_tab.setPin(value)
37
38 @command("Pin", state="isPin")
39 def togglePin(self):
40 self.setPin(not self.isPin())
41
42 def path(self):
43 return self.pwd().path()
44
45 def childCat(self):
46 """Category name of the nodes inside pwd(): 'Object', 'Sop', 'Lop'..."""
47 return childCategory(self.pwd())
48
49 def visibleNodes(self):
50 return collect_visible_nodes(self.pwd().children())
51
52 def hcGeo(self):
53 return HCGeo(self.geo())
54
55 def geo(self):
56 if self.childCat() == 'Sop':
57 display_node = self.pwd().displayNode()
58 if display_node is not None:
59 return display_node.geometry()
60 return hou.Geometry()
61
62 return merged_visible_geo(self.visibleNodes(), apply_world_transform=True)
63
64 def selectedNodes(self):
65 return list(self.pwd().selectedChildren())