Archived post by flakypastries

“`py
def wrap_in_network_box( nodes: list[hou.Node], name: str | None = None, comment: str | None = None, color: hou.Color | None = None, ) -> hou.NetworkBox | None: “””Wraps nodes in a network box sized to fit them. Args: nodes: Nodes to enclose. Must share the same parent. name: Optional box name. Auto-generated if omitted. comment: Optional comment shown in the box header. color: Optional box color. Returns: The created network box, or None if nodes is empty. Raises: ValueError: If nodes do not share a common parent. “”” if not nodes: return None parent = nodes[0].parent() if any(n.parent() != parent for n in nodes): raise ValueError(“All nodes must share the same parent.”) box = parent.createNetworkBox(name) for node in nodes: box.addNode(node) if comment: box.setComment(comment) if color: box.setColor(color) box.fitAroundContents() return box
# Wrap the current selection: wrap_in_network_box(hou.selectedNodes(), comment=”My group”)“`