def fillBundles(): selection = hou.selectedNodes() lightBundle = hou.nodeBundle("boltLightL010") boltBundle = hou.nodeBundle("boltL010") nodes = [] for item in selection: path = item.path() path = path + "/Bolt_display" nodes.append(hou.node(path)) lightNodes = [] for item in selection: path = item.path() path = path + "/boltLights1" lightNodes.append(hou.node(path)) for x in lightNodes: lightBundle.addNode(x) for x in nodes: boltBundle.addNode(x)
def getBundles(): getclip = pyperclip.paste() try: dict = ast.literal_eval(getclip) bdl_names = dict['bundles'].keys() # Add node (if exist) in new scene to bundle for x in range(0, len(bdl_names)): name = bdl_names[x] nodes = dict['bundles'][name] if hou.nodeBundle(name): bdl = hou.nodeBundle(name) else: bdl = hou.addNodeBundle(name) # Add Same Nodes if exist for nd in nodes: if hou.node(nd): bdl.addNode(hou.node(nd)) else: pass # Set pattterns pattern = dict['bundle_pattern'][x] bdl.setPattern(pattern) # TODO: Add filter support # Set filters # filter = dict['bundle_filter'][x] # bdl.setFilter(filter) except: print 'Buffer filled not a bundle list data type, try copy to clipbord again'
def _addNodeToBundle(self, node, **kwargs): bundleName = kwargs.get("bundleName", None) if not bundleName: return None bundle = hou.nodeBundle(bundleName) if not bundle: hou.hscript('opbadd "%s"' % bundleName) bundle = hou.nodeBundle(bundleName) if not bundle.containsNode(node): bundle.addNode(node)
def _returnBundleContent(self, value): """given the string value, returns the contents of the bundle with the corresponding name""" targetBundle = hou.nodeBundle(value) if targetBundle: nodes = targetBundle.nodes() return nodes else: return []
def _removeNodeFromBundle(self, node, **kwargs): bundleName = kwargs.get("bundleName", None) if not bundleName: return None bundle = hou.nodeBundle(bundleName) if not bundle or not bundle.containsNode(node): return None bundle.removeNode(node)
def outputBundle(bundle_name): if _Settings.SavedBundles.get(bundle_name, None) == None: try: bundle = hou.nodeBundle(bundle_name) node_paths = list(node.path() for node in bundle.nodes()) cmd_bundle(bundle_name, node_paths) except: cmd_bundle(bundle_name, []) _Settings.SavedBundles[bundle_name] = True
def test_select_box1_from_bundle_box_content(self): selData = [] targetBundle = hou.nodeBundle("box_bundle") nodes = targetBundle.nodes() for i in nodes: if i.name().find("box1") != -1: selData.append(i) sq = sQuery.sQuery() sel = sq.bundle("box_bundle").filter("*box1*") self.assertListEqual(sel._data, selData)
def get_nodes(self): str_value = self._sesi_parm.evalAsString() values = str_value.split() nodes = [] for value in values: if value.startswith('@'): node_bundle = hou.nodeBundle(value) if node_bundle != None: nodes.extend(node_bundle.nodes()) else: node = hou.node(value) if node: nodes.append(node) return nodes
def setShot(self): s = self.shots.selectedItems()[0] name = s.text(0) fr = map(int, re.findall(r'(\d+)', s.text(1))) combo_cam = s.text(2).rstrip() bundle = s.text(3).rstrip() take = s.text(4).rstrip() notes = s.text(5).rstrip() self.ln_name.setText(name) self.ln_begin.setText(str(fr[0])) self.ln_end.setText(str(fr[1])) self.combo_cam.setCurrentIndex(self.combo_cam.findText(combo_cam)) self.ln_notes.setText(notes) self.combo_bundle.setCurrentIndex(self.combo_bundle.findText(bundle)) self.combo_takes.setCurrentIndex(self.combo_takes.findText(take)) hou.playbar.setPlaybackRange(min(fr), max(fr)) hou.setFrame(min(fr)) if self.ch_flipbook.isChecked(): viewer = toolutils.sceneViewer() settings = viewer.flipbookSettings() settings.frameRange(fr) if combo_cam != 'Camera' and self.ch_cam.isChecked(): camera_node = hou.node(combo_cam) if camera_node: hou.ui.paneTabOfType(hou.paneTabType.SceneViewer, 0).curViewport().setCamera(camera_node) try: camera_node.parm('vcomment').eval() except: camera_node.addSpareParmTuple( hou.StringParmTemplate('vcomment', 'Viewport Comment', 1, '')) camera_node.parm('vcomment').set( 'Name: ' + name + '\n' + 'Camera: ' + combo_cam + ' ( ' + str(min(fr)) + '-' + str(max(fr)) + 'f ) ' + str(hou.fps()) + 'fps ' + str(camera_node.parm('resx').eval()) + 'x' + str(camera_node.parm('resy').eval()) + 'px\n' + 'Notes: ' + notes) camera_node.setCurrent(True, True) else: hou.ui.paneTabOfType(hou.paneTabType.SceneViewer, 0).curViewport().homeAll() if bundle != 'No Bundle': if self.ch_bundle.isChecked(): displNodes = hou.nodeBundle(bundle).nodes() hideNodes = hou.node('/obj').children() for n in hideNodes: try: n.setDisplayFlag(False) except: pass hou.clearAllSelected() for n in displNodes: try: n.setDisplayFlag(True) except: pass n.setSelected(1, clear_all_selected=0, show_asset_if_selected=0) if self.ch_hide.isChecked(): hou.clearAllSelected() nds = hou.nodeBundle(bundle).nodes() for n in nds: n.setSelected(1, clear_all_selected=0, show_asset_if_selected=0) self.hide(nds) if take != 'No Take': hou.takes.setCurrentTake(hou.takes.findTake(take)) else: hou.takes.setCurrentTake(hou.takes.rootTake())