I'm working on a level building tool for unreal engine where you create a wall from a spline and can then boolean in doors and windows (or whatever). I'm using python from within a script on my HDA and using a callback script on a button to run the code.
Here's my code:
import hou boolList = [] scene = hou.node('/obj/wall_generator/') def main(kwargs): scene.allowEditingOfContents() node = kwargs['node'] def createNodes(): wallBase = hou.node('/obj/wall_generator/wallBase') frameMerge = hou.node('/obj/wall_generator/frame_merge') blast = hou.node('/obj/wall_generator/wallSideDel') bool = scene.createNode('frame_bool_setup') boolList.append(bool) print boolList if len(boolList) == 1: boolPrev = boolList[0] bool.setInput(0, wallBase) else: boolPrev = boolList[-2] bool.setInput(0, boolPrev) print boolPrev blast.setInput(0, bool, 0) frameMerge.setNextInput(bool, 1) def createUI(): i = int(hou.getenv('i')) ui = scene.parmTemplateGroup() folder = ui.findFolder('Boolean Controls') testParm = hou.StringParmTemplate('frame{}'.format(i), 'Frame{}'.format(i), 1, naming_scheme=hou.parmNamingScheme.Base1, string_type=hou.stringParmType.NodeReference) ui.appendToFolder(folder, testParm) scene.type().definition().setParmTemplateGroup(ui) i += 1 hou.putenv('i', str(i)) createNodes() createUI() scene.type().definition().updateFromNode(scene) scene.matchCurrentDefinition() def deleteNodes(kwargs): node = kwargs['node'] num = len(boolList) boolLast = hou.node('/obj/wall_generator/frame_bool_setup{}'.format(num)) boolLast.destroy()
So far all my code works within Houdini (apart from that I need to re-work my code so that instead of boolList I use an environment variable because defining the node definition resets the list variable - I know this doesn't work at the moment). A lot of this is temp right now as I'm just diving into the Houdini Python API and learning on my feet (and am still learning more advanced Python).
I tried throwing my HDA into Unreal and I couldn't get anything to update. It wouldn't create the new nodes or update the parameter interface. Is there something that I need to do to get this to work in Unreal or is it not possible at this point in time…?
Thanks so much!
Ryan