Skip to content

Instantly share code, notes, and snippets.

@simonreeves
Last active April 13, 2021 17:29
Show Gist options
  • Save simonreeves/263496c63da38b2973b77cdf7c7f3ebe to your computer and use it in GitHub Desktop.
Save simonreeves/263496c63da38b2973b77cdf7c7f3ebe to your computer and use it in GitHub Desktop.
create #pdg #tops #topnet and nodes #houdini #python
import os
import subproocess
import hou
def make_rs_convert_topnet(path):
"""
Create topnet and some nodes
"""
texfiles_dir = os.path.dirname(path)
# 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', '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()
make_rs_convert_topnet('/c/path/to/wall.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment