Skip to content

Commit

Permalink
Merge branch 'release/1.5.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
simonreeves committed Jan 16, 2023
2 parents e207aa7 + 636ea49 commit 4eb5fd7
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 27 deletions.
42 changes: 42 additions & 0 deletions python3.9libs/nodegraphtitle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from __future__ import print_function
import hou
import nodegraphprefs as prefs

def networkEditorTitleLeft(editor):
try:
title = ''
pwd = editor.pwd()
playerparm = pwd.parm('isplayer')
if playerparm is not None and playerparm.evalAsInt() != 0:
title += 'Network in Playback Mode\n'
if prefs.showPerfStats(editor):
profile = hou.perfMon.activeProfile()
if profile is not None:
profiletitle = profile.title()
if not profiletitle:
profiletitle = 'Profile ' + str(profile.id())
title += profiletitle + ': ' + prefs.perfStatName(editor)

except:
title = ''

# Bee edit, append $JOB
# Add a newline if title is in use
if title:
title += '\n'

title += hou.getenv('JOB').split('/')[-1]

return title

def networkEditorTitleRight(editor):
try:
title = ''
pwd = editor.pwd()
title += pwd.childTypeCategory().label()

except:
title = ''

return title

44 changes: 38 additions & 6 deletions scripts/python/bee/focus_null.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,51 @@
import hou
import stateutils
import toolutils

def main():
nodes = hou.selectedNodes()
def main(kwargs):
"""
Creates a null to use as a focus gizmo for the selected camera(s)
"""

for node in nodes:
# store reference to selected node
selected_nodes = hou.selectedNodes()

# Init to record if a camera was selected at all
any_camera_selected = False

# get network editor pane
pane = stateutils.activePane(kwargs)

if not isinstance(pane, hou.NetworkEditor):
hou.ui.setStatusMessage('Only works in network editor', severity=hou.severityType.Error)
return False

for node in selected_nodes:
if node.type().name() != 'cam':
continue

# A camera was found!
any_camera_selected = True

# create null
focus_null = node.parent().createNode('null', node.name() + '_focus')
# create null
# toolutils not soptoolutils, because it's not a SOP
focus_null = toolutils.genericTool(kwargs, 'null')
focus_null.setName(node.name() + '_focus', True)

# add focus distance expression
expression = "vlength(vtorigin('.', '{}'))".format(node.relativePathTo(focus_null))
node.parm('focus').setExpression(expression)

# Lock rotation
focus_null.parmTuple('r').lock(True)

# set focus null visual properties
focus_null.parm('shadedmode').set(1)
focus_null.parm('controltype').set(2)
focus_null.parm('geoscale').set(0.1)
focus_null.parmTuple('dcolor').set((0,0.1,1))
focus_null.parmTuple('dcolor').set((0, 0.1 ,1))

if not any_camera_selected:
message = "There were no cameras found in selection! Please select camera(s)"
hou.ui.setStatusMessage(message=message, severity=hou.severityType.ImportantMessage)
return
28 changes: 13 additions & 15 deletions scripts/python/bee/labelled_netbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@

def main():
# find parent node of current node.
selected_nodes = hou.selectedNodes() # type: tuple[hou.Node]
current_nodes = [x for x in selected_nodes if x.isCurrent] # type: List[hou.Node]
selected_nodes = hou.selectedNodes()
current_nodes = [x for x in selected_nodes if x.isCurrent]

if len(current_nodes) == 0:
print("there are no selected node. please select some nodes")
message = "There are no selected nodes, please select some nodes first"
hou.ui.setStatusMessage(message=message, severity=hou.severityType.ImportantMessage)
return
parent = current_nodes[0].parent() # type: hou.Node

# Ask user for label, first looks tidier in network viewer
label = hou.ui.readInput('Label')

parent = current_nodes[0].parent()

# create network boxes
# parent_network_box = parent.createNetworkBox() # type: hou.NetworkBox
child_network_box = parent.createNetworkBox() # type: hou.NetworkBox
child_network_box = parent.createNetworkBox()

# find good position of boxes, which is center of selected nodes.
list_x_of_selected_nodes = [node.position().x() for node in selected_nodes]
Expand All @@ -27,7 +32,7 @@ def main():
child_network_box.fitAroundContents()

# set color of network boxes
network_box_color = hou.Color(0.5,0.1,0.1)
network_box_color = hou.Color(0.5, 0.1, 0.1)
child_network_box.setColor(network_box_color)

# create sticky_note
Expand All @@ -38,25 +43,18 @@ def main():
sticky_note_position = hou.Vector2(sticky_note_position_x, sticky_note_position_y)
sticky_note.setPosition(sticky_note_position)

if hou.isUIAvailable:
label = hou.ui.readInput('Label')
else:
label = 'default'

sticky_note.setText(label[1])
sticky_note_height = 2
sticky_note.setTextSize(sticky_note_height * .5)

# min width to fit sticky note text
sticky_note_width = max(child_network_box.size().x(), 4)

sticky_note.setSize(hou.Vector2(sticky_note_width, sticky_note_height))

# add after setting position
child_network_box.addItem(sticky_note)

sticky_note_text_color = hou.Color(214.0 / 255.0, 214.0 / 255.0, 214.0 / 255.0)
sticky_note.setDrawBackground(False)
sticky_note.setTextColor(sticky_note_text_color)

return

Expand Down
14 changes: 8 additions & 6 deletions toolbar/bee.shelf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<memberTool name="bee_focus_null"/>
</toolshelf>

<tool name="bee_placehighlight" label="Place Highlight" icon="$BEE_HOU/icons/placehighlight.svg">
<tool name="bee_placehighlight" label="Place Highlight (Bee)" icon="$BEE_HOU/icons/placehighlight.svg">
<toolSubmenu>Bee</toolSubmenu>
<script scriptType="python"><![CDATA[import hou
import stateutils
Expand Down Expand Up @@ -59,7 +59,7 @@ bee.object_merge_selected.sibling_sop(kwargs)]]></script>
</keywordList>
</tool>

<tool name="bee_labelled_netbox" label="Labelled Network Box Bee" icon="PLASMA_App">
<tool name="bee_labelled_netbox" label="Labelled Network Box (Bee)" icon="PLASMA_App">
<toolMenuContext name="network">
<contextNetType>OBJ</contextNetType>
<contextNetType>SOP</contextNetType>
Expand All @@ -77,7 +77,7 @@ bee.object_merge_selected.sibling_sop(kwargs)]]></script>
<script scriptType="python"><![CDATA[import bee.labelled_netbox
bee.labelled_netbox.main()]]></script>
<keywordList>
<keyword>bee network box label note sticky</keyword>
<keyword>bee network box label note sticky group frame backdrop</keyword>
</keywordList>
</tool>

Expand All @@ -93,23 +93,25 @@ bee.object_merge_selected.sibling_obj(kwargs)]]></script>
</keywordList>
</tool>

<tool name="List Materials" label="List Materials" icon="Textport">
<tool name="List Materials" label="List Materials (Bee)" icon="Textport">
<toolMenuContext name="network">
<contextNetType>SOP</contextNetType>
</toolMenuContext>
<toolSubmenu>Bee</toolSubmenu>
<script scriptType="python"><![CDATA[import bee.list_materials
bee.list_materials.main()]]></script>
<keywordList>
<keyword>python list materials</keyword>
</keywordList>
</tool>

<tool name="bee_focus_null" label="Focus Null" icon="Textport">
<tool name="bee_focus_null" label="Camera Focus Null (Bee)" icon="$BEE_HOU/icons/align.svg">
<toolMenuContext name="network">
<contextNetType>OBJ</contextNetType>
</toolMenuContext>
<toolSubmenu>Bee</toolSubmenu>
<script scriptType="python"><![CDATA[import bee.focus_null
bee.focus_null.main()]]></script>
bee.focus_null.main(kwargs)]]></script>
<keywordList>
<keyword>camera add focus null bee</keyword>
</keywordList>
Expand Down

0 comments on commit 4eb5fd7

Please sign in to comment.