Skip to content

Commit

Permalink
Merge branch 'release/1.1.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Reeves committed Apr 13, 2021
2 parents 1247be0 + 47fc9c2 commit f7789f1
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 0 deletions.
57 changes: 57 additions & 0 deletions PARMmenu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
This file defines the menu items when right-clicking over parameters in
Houdini.
Files named the same (ie. PARMmenu.xml) can exist in $HOME/houdiniX.Y/
directory and will supplement the original definitions found in
$HFS/houdini/ (aka $HH).
The format in this file is similar to the format in $HH/MainMenuMaster
except that it uses the <menuDocument> and <menu> tags instead of
<mainMenu> and <menuBar>. See the comments in that file for more advanced
customization abilities.
Another difference here is that most menu items in this file have no labels
because they are dynamically created by Houdini. If labels are supplied to
the items which currently have no labels in this file, they will be
ignored.
Note that the id's correspond to their hotkeys with the h.pane.parms.
prefix (where available). For example, the item with id,
"revert_to_prev_val", refers to the action in the hotkeys manager as
"h.pane.parms.revert_to_prev_val".
For scriptItem elements, a 'kwargs' python dictionary is provided with the
following values:
'parms' : A list of hou.Parm objects which the script was invoked
upon.
'toolname' : The menu item's hotkey id (ie. the element's id
prefixed with h.pane.parms.)
'altclick' : True if the Alt key was also pressed, False otherwise
'ctrlclick' : True if the Ctrl key was also pressed, False otherwise
'shiftclick' : True if the Shift key was also pressed, False otherwise
'cmdclick' : True if the Option key was also pressed, False
otherwise. Note that this can only be true on OSX.
-->

<menuDocument>
<!-- menuDocument can only contain 1 menu element, whose id is
implicitly "root_menu"
-->
<menu>

<scriptItem id="bee_rs_tex_convert">
<label>Redshift Texture Convert (Bee)</label>
<modifyItem><insertAfter>revert_to_prev_val</insertAfter></modifyItem>
<scriptCode><![CDATA[
import bee.rs_tex_convert
bee.rs_tex_convert.main(kwargs)
]]></scriptCode>
</scriptItem>



</menu>
</menuDocument>
Binary file modified hdas/bee_coloriser.hda
Binary file not shown.
79 changes: 79 additions & 0 deletions scripts/python/bee/rs_tex_convert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import subprocess
import os
import hou


def main(kwargs):
"""
Called from a parm right click menu, gets the file's dir and runs redshiftTextureProcessor
"""

parms = kwargs.get('parms', False)

# get first parm
parm = parms[0]

# print('parm.eval(): {}'.format(parm.eval()))

# get dir
texfiles_dir = os.path.dirname(parm.eval())
print('texfiles_dir: {}'.format(texfiles_dir))

# check if path exists
if not os.path.exists(texfiles_dir):
print('Directory \"{}\" does not exist')
return False


# get redshift path from environ variables
rs_tex_processor_path = hou.getenv('REDSHIFT_COREDATAPATH') + '/bin/redshiftTextureProcessor.exe'

# print('rs_tex_processor_path: {}'.format(rs_tex_processor_path))

if not os.path.exists(rs_tex_processor_path):
print('could not find rstex exe')
return False

# start subprocess (locks houdini)
args = [rs_tex_processor_path, texfiles_dir + '/*']

# popen starts new process! call does not
subprocess.Popen(args)


def make_topnet():
"""
This is neat but not needed, also it creates topnets that cant delete themselves
"""

# get redshift path from environ variables
rs_tex_processor_path = hou.getenv('REDSHIFT_COREDATAPATH') + '/bin/redshiftTextureProcessor.exe'

# create topnet and cook in background
topnet = hou.node('/tasks').createNode('topnet', 'bee_rs_tex_convert')

# tidy layout
hou.node('/tasks').layoutChildren()

# ignore errors to skip non convertable files which is fine
topnet.children()[0].parm('local_echandleby').set(3)

fp_node = topnet.createNode('filepattern')
fp_node.parm('pattern').set(texfiles_dir + '/*')

gg_node = fp_node.createOutputNode('genericgenerator')
gg_node.parm('pdg_command').set('{} `pdgattribvals("directory")`/`pdgattribvals("filename")`'.format(rs_tex_processor_path))

# tidy layout
topnet.layoutChildren()

# execute in background
gg_node.executeGraph()

# trying to delete the node after not suprising crashed

# waitforall_node = gg_node.createOutputNode('waitforall')
# pythonscript_node = waitforall_node.createOutputNode('pythonscript')
# pythonscript_node.parm('script').set("print(self.topNode().destroy())")
# pythonscript_node.executeGraph()
# topnet.destroy()

0 comments on commit f7789f1

Please sign in to comment.