本文整理汇总了Python中hou.selectedNodes方法的典型用法代码示例。如果您正苦于以下问题:Python hou.selectedNodes方法的具体用法?Python hou.selectedNodes怎么用?Python hou.selectedNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hou
的用法示例。
在下文中一共展示了hou.selectedNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: maintained_selection
# 需要导入模块: import hou [as 别名]
# 或者: from hou import selectedNodes [as 别名]
def maintained_selection():
"""Maintain selection during context
Example:
>>> with maintained_selection():
... # Modify selection
... node.setSelected(on=False, clear_all_selected=True)
>>> # Selection restored
"""
previous_selection = hou.selectedNodes()
try:
yield
finally:
# Clear the selection
# todo: does hou.clearAllSelected() do the same?
for node in hou.selectedNodes():
node.setSelected(on=False)
if previous_selection:
for node in previous_selection:
node.setSelected(on=True)
示例2: openFolderFromSelectedNodes
# 需要导入模块: import hou [as 别名]
# 或者: from hou import selectedNodes [as 别名]
def openFolderFromSelectedNodes(ns=hou.selectedNodes()):
chooselist = []
choosedict = {}
for n in ns:
getlist,getdict = getFolderParms(n)
chooselist += getlist
choosedict.update(getdict)
#print choosedict,chooselist
if len(chooselist)>0:
choose = hou.ui.selectFromList(chooselist, message='Select Parms to bake key')
for i in choose:
#print str(chooselist[i])
foloderpath = choosedict[chooselist[i]]
if os.path.exists(foloderpath):
openFolder(foloderpath)
else:
print '{} is does not exists.'.format(foloderpath)
示例3: rename_selected_nodes
# 需要导入模块: import hou [as 别名]
# 或者: from hou import selectedNodes [as 别名]
def rename_selected_nodes(cls, search_str, replace_str, replace_in_child_nodes=False):
"""Batch renames selected nodes
:param str search_str: Search for this
:param str replace_str: And replace with this
:return:
"""
import hou
selection = hou.selectedNodes()
for node in selection:
name = node.name()
node.setName(name.replace(search_str, replace_str))
if replace_in_child_nodes:
for child_node in node.children():
name = child_node.name()
child_node.setName(name.replace(search_str, replace_str))
示例4: get_selected_rops_for_patching
# 需要导入模块: import hou [as 别名]
# 或者: from hou import selectedNodes [as 别名]
def get_selected_rops_for_patching():
"""
Gets a list of ROPs from the current selection that are able to be patched.
Returns:
List: A list of ROPs to patch
"""
# TODO: Need to do more checks on what is selected. Maybe allow the ROP SOP Output Driver?
rop_list = []
sel_nodes = list(hou.selectedNodes())
for rop_node in sel_nodes:
network_type = rop_node.parent().childTypeCategory().name()
if network_type == "Driver" or rop_node.type().name().startswith("rop_"):
parm_tg = rop_node.parmTemplateGroup()
entry = parm_tg.parmTemplates()[0]
if entry.name() != "hf_orig_parms":
rop_list.append(rop_node)
return rop_list
示例5: get_selected_rops_for_unpatching
# 需要导入模块: import hou [as 别名]
# 或者: from hou import selectedNodes [as 别名]
def get_selected_rops_for_unpatching():
"""
Gets a list of ROPs from the current selection that are able to be unpatched.
Returns:
List: A list of ROPs to unpatch
"""
rop_list = []
sel_nodes = list(hou.selectedNodes())
for rop_node in sel_nodes:
network_type = rop_node.parent().childTypeCategory().name()
if network_type == "Driver" or rop_node.type().name().startswith("rop_"):
parm_tg = rop_node.parmTemplateGroup()
entry = parm_tg.parmTemplates()[0]
if entry.name() == "hf_orig_parms":
rop_list.append(rop_node)
return rop_list
示例6: _addItem
# 需要导入模块: import hou [as 别名]
# 或者: from hou import selectedNodes [as 别名]
def _addItem(self,collection):
#Please, dont throw from here!
try:
nodes = hou.selectedItems()
except:
nodes = hou.selectedNodes()
if(len(nodes)==0):
QMessageBox.warning(self,'not created','selection is empty, nothing to add')
return
while True:
#btn,(name,desc) = (0,('1','2'))#hou.ui.readMultiInput('enter some information about new item',('name','description'),buttons=('Ok','Cancel'))
name, desc, public, good = QDoubleInputDialog.getDoubleTextCheckbox(self,'adding a new item to %s'%collection.name(),'enter new item details','name','description','public', '','a snippet',False)
if(not good):return
if(len(name)>0):break; #validity check
try:
#print(name)
#print(desc)
#print(hpaste.nodesToString(nodes))
self.model().addItemToCollection(collection,name,desc,hpaste.nodesToString(nodes),public, metadata={'nettype':self.__netType})
except CollectionSyncError as e:
QMessageBox.critical(self,'something went wrong!','Server error occured: %s'%e.message)
示例7: copy_node_path
# 需要导入模块: import hou [as 别名]
# 或者: from hou import selectedNodes [as 别名]
def copy_node_path(cls):
"""copies path to clipboard
"""
import hou
node = hou.selectedNodes()[0]
hou.ui.copyTextToClipboard(node.path())
示例8: process
# 需要导入模块: import hou [as 别名]
# 或者: from hou import selectedNodes [as 别名]
def process(self):
"""This is the base functionality to create instances in Houdini
The selected nodes are stored in self to be used in an override method.
This is currently necessary in order to support the multiple output
types in Houdini which can only be rendered through their own node.
Default node type if none is given is `geometry`
It also makes it easier to apply custom settings per instance type
Example of override method for Alembic:
def process(self):
instance = super(CreateEpicNode, self, process()
# Set paramaters for Alembic node
instance.setParms(
{"sop_path": "$HIP/%s.abc" % self.nodes[0]}
)
Returns:
hou.Node
"""
if (self.options or {}).get("useSelection"):
self.nodes = hou.selectedNodes()
# Get the node type and remove it from the data, not needed
node_type = self.data.pop("node_type", None)
if node_type is None:
node_type = "geometry"
# Get out node
out = hou.node("/out")
instance = out.createNode(node_type, node_name=self.name)
instance.moveToGoodPosition()
lib.imprint(instance, self.data)
return instance
示例9: launch
# 需要导入模块: import hou [as 别名]
# 或者: from hou import selectedNodes [as 别名]
def launch(switch):
n = hou.selectedNodes()[0]
if switch == False:
if n.type().name() == 'ifd':
run_mplay(n,'vm_picture')
elif n.type().name() == 'opengl':
run_mplay(n,'picture')
elif n.type().name() == 'arnold':
run_mplay(n,'ar_picture')
elif n.type().name() == 'comp':
run_mplay(n,'copoutput')
elif n.type().name() == 'ris::22':
run_mplay(n,'ri_display_0')
elif switch == True:
if n.type().name() == 'ifd':
run_rv(n,'vm_picture')
elif n.type().name() == 'opengl':
run_rv(n,'picture')
elif n.type().name() == 'arnold':
run_rv(n,'ar_picture')
elif n.type().name() == 'comp':
run_rv(n,'copoutput')
elif n.type().name() == 'ris::22':
run_rv(n,'ri_display_0')
# else:
# hou.ui.displayMessage('Plz select Mantra ROP')
示例10: run
# 需要导入模块: import hou [as 别名]
# 或者: from hou import selectedNodes [as 别名]
def run():
slnode = hou.selectedNodes()[0]
if slnode.type().name()=='dopnet':
uiText = 'Change OpenCL value on all children nodes in this %s' % slnode.path()
value = hou.ui.displayMessage(title='OpenCL', text=uiText, buttons=("Deactive", "Active"))
switchOpenCl(slnode,value)
示例11: blackbox_definitions
# 需要导入模块: import hou [as 别名]
# 或者: from hou import selectedNodes [as 别名]
def blackbox_definitions(out_folder):
# given the selected nodes, create a blackboxed definition for each asset and save to out_folder.
nodes = hou.selectedNodes()
for node in nodes:
definition = node.type().definition()
if definition:
def_filename = definition.libraryFilePath()
out_file = os.path.join(out_folder, os.path.basename(def_filename))
print("saving blackboxed file: {}".format(out_file))
definition.save(file_name=out_file, template_node=node, compile_contents=True, black_box=True)
示例12: setupMutationFromMarkedWedgesUI
# 需要导入模块: import hou [as 别名]
# 或者: from hou import selectedNodes [as 别名]
def setupMutationFromMarkedWedgesUI():
try:
anchor_node = hou.selectedNodes()[-1]
if anchor_node.type() != hou.nodeType("Top/wedge"):
raise Exception("No Wedge Node selected.")
except:
print "No Wedge Node selected."
wedge_sel_str = hou.ui.readInput("Enter Wedge Index List, i.e. '0_1,3_0,4_1'")[1]
wedge_sel_list = wedge_sel_str.split(",")
mode = hou.ui.selectFromList(["Convert to Takes (del. existing Takes)", "Convert to Takes (keep existing Takes)", "Convert to TOP Wedge (del. existing Takes)"], default_choices=([0]), exclusive=True, message="Please choose how to convert Marked Wedges", title="Conversion Mode", column_header="Choices", num_visible_rows=3, clear_on_cancel=True, width=400, height=180)
if mode == ():
raise Exception("Cancelled.")
mode = mode[0]
setupMutationFromMarkedWedges(wedge_sel_list, anchor_node, mode)
#function to create new root wedge node from current mutagen viewer selection
示例13: _replaceContent
# 需要导入模块: import hou [as 别名]
# 或者: from hou import selectedNodes [as 别名]
def _replaceContent(self, index):
try:
nodes = hou.selectedItems()
except:
nodes = hou.selectedNodes()
if (len(nodes)==0):
QMessageBox.warning(self,'cannot replace','selection is empty')
return
item=index.internalPointer()
good = QMessageBox.warning(self,'sure?','confirm that you want to replace the content of selected item "%s". This operation can not be undone.'%item.name() ,QMessageBox.Ok|QMessageBox.Cancel) == QMessageBox.Ok
if(not good):return
try:
item.setContent(hpaste.nodesToString(nodes))
except CollectionSyncError as e:
QMessageBox.critical(self,'something went wrong!','Server error occured: %s'%e.message)
示例14: orderSelected
# 需要导入模块: import hou [as 别名]
# 或者: from hou import selectedNodes [as 别名]
def orderSelected():
return orderNodes(hou.selectedNodes())
示例15: export_rsproxy_data_as_json
# 需要导入模块: import hou [as 别名]
# 或者: from hou import selectedNodes [as 别名]
def export_rsproxy_data_as_json(cls, geo=None, path=''):
"""exports RSProxy Data on points as json
"""
import hou
if geo is None:
node = hou.selectedNodes()[0]
geo = node.geometry()
# Add code to modify contents of geo.
# Use drop down menu to select examples.
pos = geo.pointFloatAttribValues("P")
rot = geo.pointFloatAttribValues("rot")
sca = geo.pointFloatAttribValues("pscale")
instance_file = geo.pointStringAttribValues("instancefile")
node_name = geo.pointStringAttribValues("node_name")
parent_name = geo.pointStringAttribValues("parent_name")
import os
import tempfile
if path == '':
path = os.path.normpath(
os.path.join(
tempfile.gettempdir(),
'rsproxy_info.json'
)
)
pos_data = []
rot_data = []
for i in range(len(pos) / 3):
pos_data.append((pos[i * 3], pos[i * 3 + 1], pos[i * 3 + 2]))
rot_data.append((rot[i * 3], rot[i * 3 + 1], rot[i * 3 + 2]))
json_data = {
"pos": pos_data,
"rot": rot_data,
"sca": sca,
"instance_file": instance_file,
"node_name": node_name,
"parent_name": parent_name
}
import json
with open(path, "w") as f:
f.write(json.dumps(json_data))