stu

stu

About Me

Expertise
Not Specified
Location
Not Specified
Website

Connect

Recent Forum Posts

Custom Shelf Tools not wired/appended to selected geo/network node Jan. 7, 2019, 5:41 p.m.

RMB-click on the output and TAB works, just too bad that I can't do it as easily from the shelf or the radial dial, in the viewport.

Custom Shelf Tools not wired/appended to selected geo/network node Jan. 7, 2019, 5:18 p.m.

Custom from scratch I'd expect to have to handle it myself. But a simple drag-in from the network (which is what I'm doing), I'd expect to work:

1. Select thing upon which I want to perform a function.
2. Do this (dragged-from-network shelf tool functionality) to it.

Otherwise, the “drag to shelf” functionality as a high-level workflow is limited in it's usefulness if I have to backwards-engineer basic functionality after the fact.

Custom Shelf Tools not wired/appended to selected geo/network node Jan. 7, 2019, 4:17 p.m.

That strikes me as odd given that the auto-generated script appears to contain verbage for the connection.Simple colorSOP custom shelf tool script:



import sys
import toolutils

outputitem = None
inputindex = -1
inputitem = None
outputindex = -1

num_args = 1
h_extra_args = ‘'
pane = toolutils.activePane(kwargs)
if not isinstance(pane, hou.NetworkEditor):
pane = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor)
if pane is None:
hou.ui.displayMessage(
’Cannot create node: cannot find any network pane')
sys.exit(0)
else: # We're creating this tool from the TAB menu inside a network editor
pane_node = pane.pwd()
if kwargs.has_key(“outputnodename”) and kwargs.has_key(“inputindex”):
outputitem = pane_node.item(kwargs)
inputindex = kwargs
h_extra_args += ‘set arg4 = "’ + kwargs + ‘“\n’
h_extra_args += ‘set arg5 = ”’ + str(inputindex) + ‘“\n’
num_args = 6
if kwargs.has_key(”inputnodename“) and kwargs.has_key(”outputindex"):
inputitem = pane_node.item(kwargs)
outputindex = kwargs
h_extra_args += ‘set arg6 = "’ + kwargs + ‘“\n’
h_extra_args += ‘set arg9 = ”’ + str(outputindex) + ‘“\n’
num_args = 9
if kwargs.has_key(”autoplace"):
autoplace = kwargs
else:
autoplace = False
# If shift-clicked we want to auto append to the current
# node
if kwargs.has_key(“shiftclick”) and kwargs:
if inputitem is None:
inputitem = pane.currentNode()
outputindex = 0
if kwargs.has_key(“nodepositionx”) and kwargs.has_key(“nodepositiony”):
try:
pos = [ float( kwargs ),
float( kwargs )]
except:
pos = None
else:
pos = None

if not autoplace and not pane.listMode():
if pos is not None:
pass
elif outputitem is None:
pos = pane.selectPosition(inputitem, outputindex, None, -1)
else:
pos = pane.selectPosition(inputitem, outputindex,
outputitem, inputindex)

if pos is not None:
if kwargs.has_key(“node_bbox”):
size = kwargs
pos -= size / 2
pos -= size / 2
else:
pos -= 0.573625
pos -= 0.220625
h_extra_args += ‘set arg2 = "’ + str(pos) + ‘“\n’
h_extra_args += ‘set arg3 = ”’ + str(pos) + ‘“\n’
h_extra_args += ‘set argc = ”’ + str(num_args) + ‘“\n’

pane_node = pane.pwd()
child_type = pane_node.childTypeCategory().nodeTypes()

if not child_type.has_key('color'):
hou.ui.displayMessage(
‘Cannot create node: incompatible pane network type’)
sys.exit(0)

# First clear the node selection
pane_node.setSelected(False, True)

h_path = pane_node.path()
h_preamble = ‘set arg1 = ”’ + h_path + ‘“\n’
h_cmd = r'''
if ($argc < 2 || ”$arg2“ == ”“) then
set arg2 = 0
endif
if ($argc < 3 || ”$arg3“ == ”“) then
set arg3 = 0
endif
# Automatically generated script
# $arg1 - the path to add this node
# $arg2 - x position of the tile
# $arg3 - y position of the tile
# $arg4 - input node to wire to
# $arg5 - which input to wire to
# $arg6 - output node to wire to
# $arg7 - the type of this node
# $arg8 - the node is an indirect input
# $arg9 - index of output from $arg6

\set noalias = 1
set saved_path = `execute(”oppwf“)`
opcf $arg1

# Node $_obj_geo1_color1 (Sop/color)
set _obj_geo1_color1 = `run(”opadd -e -n -v color color1“)`
oplocate -x `$arg2 + 0` -y `$arg3 + 0` $_obj_geo1_color1
opparm $_obj_geo1_color1 ramp ( 2 )
opparm $_obj_geo1_color1 color ( 1 0 0 ) ramp2pos ( 1 ) ramp2c ( 1 1 1 )
opset -d off -r off -h off -f off -y off -t off -l off -s off -u off -F on -c on -e on -b off $_obj_geo1_color1
opexprlanguage -s hscript $_obj_geo1_color1
opuserdata -n ‘___Version___’ -v ‘' $_obj_geo1_color1
opuserdata -n ’___toolcount___' -v ‘2’ $_obj_geo1_color1
opuserdata -n ‘___toolid___’ -v ‘sop_color’ $_obj_geo1_color1
opset -p on $_obj_geo1_color1

opcf $arg1

set oidx = 0
if ($argc >= 9 && ”$arg9“ != ”“) then
set oidx = $arg9
endif

if ($argc >= 5 && ”$arg4“ != ”“) then
set output = $_obj_geo1_color1
opwire -n $output -$arg5 $arg4
endif
if ($argc >= 6 && ”$arg6“ != ”") then
set input = $_obj_geo1_color1
if ($arg8) then
opwire -n -i $arg6 -0 $input
else
opwire -n -o $oidx $arg6 -0 $input
endif
endif
opcf $saved_path
'''
hou.hscript(h_preamble + h_extra_args + h_cmd)