Jump to content

Search the Community

Showing results for tags 'python'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • General
    • Lounge/General chat
    • Education
    • Jobs
    • Marketplace
  • Houdini
    • General Houdini Questions
    • Effects
    • Modeling
    • Animation & Rigging
    • Lighting & Rendering
    • Compositing
    • Games
    • Tools (HDA's etc.)
  • Coders Corner
    • HDK : Houdini Development Kit
    • Scripting
    • Shaders
  • Art and Challenges
    • Finished Work
    • Work in Progress
    • VFX Challenge
    • Effects Challenge Archive
  • Systems and Other Applications
    • Other 3d Packages
    • Operating Systems
    • Hardware
    • Pipeline
  • od|force
    • Feedback, Suggestions, Bugs

Found 490 results

  1. i want to call a method when OTL's parameters are updated . that is easily done with the callback script . this works ... hou.node('.').hdaModule().blah() but i want the same method to be called when there is an event. in my case when the (input) connection is changed. the problem is the even doesnt recognize hou.node('.').. after a trying a few different things... kwargs seem to work. but now the method now needs to take in the kwarg arguments to work .. dummy.hdanc scene.hipnc here is a test scene & hda for reference ... can this be done cleaner / better ?
  2. Hey again, Got a problem that I'm not sure how to tackle. Here is the current setup: Points within Houdini are being transformed into position using an xml. There are 2 python nodes that accomplish the above to give the points unique info about what they represent with an x,y,z cord and rotation x,y,z. I've made some edits to a few of the points, too many for me to update the xml manually, and I'd like to update the xml with the new x,y,z cord and rotation x,y,z. I believe I can modify the xml with python, but I'm unsure on how I would be able to grab the moved point data from Houdini. Any ideas on how to bridge the gap between Houdini and the xml?
  3. I am curious if it is possible to clock how long it takes to cook a surface operator and interrupt if it goes above a certain limit, preferably within a python SOP? Backstory; there are cases when a polyexpand2D node takes excessively long time to cook. I've contacted SideFX for this unexpected behavior. Long story short, this is what they recommended: And it does, when you translate the input geometry of the ‘polyexpand2d’ SOP the results do vary. So now I am trying to figure out a way to clock a particular section of the network tree, and if it takes longer than X amount of time, I want to translate the input ever so slightly. Hopefully this will help it so it doesn't take +1 hour to cook (average is somewhere between 1-5 seconds). I have been looking into hou.perfMon but that didn't really lead me anywhere. Let me know if anyone has any suggestions. Pseudo Code: import time trans_node = hou.node("../translate1") cook_node = hou.node("../COOK_THIS") start = time.time() time_limit = 5.0 rot= 0.0 while current_time < time_limit: try: cook_node.cook() except Timeout: rot= random(0.0, 360.0) trans_node.parm("rx").set(rot) cook_node.cook() continue Thank you!
  4. Hi, Using python in houdini. I'm trying to get the full network path from the network editor that's under my mouse cursor. This is the code I have so far. I put this code in a shelf button. Assigned a hotkey to the shelf button. When I'm over my network editor I press the hotkey and this works, getting the name of the panetab of the network editor under my mouse cursor. paneTabObj = hou.ui.paneTabUnderCursor() print paneTabObj.name() #prints panetab6 in my case I'm trying to find a way to get the network path of this network editor panetab. For example "/ob/geo1/subnet2/"
  5. Align Tool for Houdini

    Now you can align multiple objects with Aligner like in 3ds max. Just select object or objects, press button and select the target. https://gumroad.com/l/Aligner Installation: 1. Create new shelf 2. Add new shelf tool 3. Copy and paste script from aligner.py 4. Edit ui_file path to the file aligner_gui.ui P.S. Asign the tool on Shift+A hotkey. Enjoy!
  6. Python Genetic Grid in Houdini

    Hello Guys, Is there someone who understand python in houdini? Because i don't I wanna trying remake this > Video I read one interview where Albert Omoss talking he rebuild this code from Processing to Python in Houdini, but i dont find any tips how to make it or how i can rebuilt GeneticGrid.mp4
  7. I have a multiple cache folder and i want to import all the cache sequence in several "file" node once using python. any idea how to do that?
  8. Using external IDE?

    how can I use external IDE to code python? vscode or sublime text
  9. OPmenu issue

    Hi Guys, First post since I joined odforce. I am trying to make a tool which could create filecache node on the right click of a null node. The moment I hover my cursor on the "mdu" option, before clicking it's creating filecache node. Its a submenu option, so I think I am missing some thing important. <?xml version="1.0" encoding="UTF-8"?> <menuDocument> <menu> <subMenu> <label>mdu</label> <actionItem id = "create.rop.node"> <labelExpression><![CDATA[ node = kwargs['node'] result = 'Create Rop Node' sel = hou.selectedNodes()[0] if sel.type().name() == 'null': selName = sel.name().split("_") joinName = "_".join(selName) nodeName = joinName.replace('OUT_',"") if selName[0] == 'OUT': nodePath = sel.path() node = hou.node(nodePath) node.createOutputNode("filecache",nodeName) else: raise hou.Error("Invalid Node name") else: print sel.name() + " is not valid for cache" result = u"\u2713 " + result return result ]]></labelExpression> <context> <expression>kwargs["node"].type().category().name() in ("Sop")</expression> </context> </actionItem> </subMenu> </menu> </menuDocument> Thanks
  10. Tree panel from HOU module

    Hi, can we create a similar panel like this whith the help of the hou module inside Houdini ( no qt ) ? Or inside paramaters panel ? the best would be that ! ? THX! G
  11. I have Subnet node name is "subnet1". In "subnet1" i have ROP node.The same name as subnet is "subnet1". When i change my subnet name change the my ROP name too. How to write in "On Name Change" python ? Thank you.
  12. Modeler 2021 Released!

    Modeler 2021 for Houdini Released! Release notes: https://www.dropbox.com/.../Modeler-2021-Release-Notes... Product Link: https://gum.co/mdNet Release video and new video tutorials will be available soon
  13. hello , it's my first time i use python in houdini fx i know python from before but i never used it in houdini fx and it seems it's easier than vex to achieve the same task, my problem is i have an fbx file with shop_materialpath and there are different name in shop_materialpath i want to create a string channel for each unique name , that string channel it will be a path for ue4 material for example if i have 2 different name in shop_material the first one is TS_02 and the second is Roof_01 i want to create 2 string channel to expose it later to ue4 using hda first string pathmat1 and the second one is pathmat2 and they will be applied in an attribute name unreal_material or path , i want to automate this process because i want it to work on random asset if i dont know the name of the shop_materialpath the python script should loop in each primitive and see how many name there are in shop_material path and create string channels for them . i already made a script to store the name of the shop_materialpath in a dictionary and then i lost from where should i continue idk how to access primnum in python and idk how to create string channel like in vex using chs() here is my python code # Run a generator Box SOP Verb def grp_n(grp): myDict={} for mat in grp: if mat in myDict: myDict[mat]=1 else: myDict[mat]=1 return myDict node = hou.pwd() geo = node.geometry() dict={} list=[] for pri in geo.prims(): list.append(pri.attribValue("shop_materialpath")) l=grp_n(list) print l and i made a simple code in vex but in this case i already know the shop_material names and im testing using if conditions and applying string to the unreal_material , i want to automate this process to check how many names there are in shop_material path and then creating string channels for each one, sorry i dont know how to explain this in an easy way but my english is not too good string id1=chs("uemat1"); string id2=chs("uemat2"); string id3=chs("uemat3"); // testing conditions comparing the groups name if(s@shop_materialpath=="TS_02"){ s@unreal_material=id1; } else{ s@unreal_material=id2; } if(s@shop_materialpath=="Emissive_01"){ s@unreal_material=id3; }
  14. Callback script error

    Hello everyone, I'm new to python and perhaps learning it in combination with Houdini may not be the perfect way to go for a newbie but here I am. So I get this error when trying to execute my code from a button: Traceback (most recent call last): File "Sop/STEGG_TEST/bt_execute", line 1, in <module> File "Sop/STEGG_TEST, PythonModule", line 135, in main File "Sop/STEGG_TEST, PythonModule", line 98, in encode File "Sop/STEGG_TEST, PythonModule", line 71, in encode_enc File "Sop/STEGG_TEST, PythonModule", line 31, in modPix AttributeError: 'iterator' object has no attribute '__next__' I'm not sure what this error means. I tried running the code outside Houdini, and the only difference was that as a standalone, it's not getting the input from the input fields I have in the UI so I had to type them myself. The rest all worked fine. I'm not exactly sure how to go about this, should I upload the code I'm trying to run, as well as a version of the HDA I'm trying to make? I'm mainly interested in what this error means and why it only pops up in Houdini but not when I run externally.
  15. How to get a callback event on cook?

    I been coding the callback event in a HDA with Python, the goal is to call every time the node is cooked(after the cook); But it seem not such event type in hou.nodeEventType and hou.hdaEventType. I was write the hou.Node.addEventCallback() in OnCreate event handler section to setup different event type callback. Is there any way to write a callback in HDA for something like "OnCook" event?
  16. Hi. I have an image rendered with Mantra in Houdini. Please let me know if there is a way to do it with a python script. Do you know how to copy only this mantra node to Nuke and that image can be loaded directly from Nuke? Thank you.
  17. Hello, I need a way to set the value of a voxel of a hou.VDB with python. Do you know if there is an equivalent to the setVoxel() function used to the hou.Volume for the vdb ? Thanks in advance,
  18. I look at here. I want do color parameter How to do this sir Thanks https://www.sidefx.com/forum/topic/50408/?page=1#post-227213 How to do it ???? Create Color this text vvvvvvvvvvvv vvvvvvvv vvvvvv vv v
  19. import hou #CreateNode root = "/obj" node = hou.node(root).createNode("geo" , "test") #ParmGRP parm_group = node.parmTemplateGroup() parm = hou.IntParmTemplate("testParm", "TestParameter" , 1) #ParmAppend parm_group.append(parm) node.setParmTemplateGroup(parm_group) #Move To Tranform Folder() parm_group.remove("testParm") parm_group.appendToFolder(parm_group.findIndicesForFolder("Transform"),node.parm("testParm").parmTemplate()) node.setParmTemplateGroup(parm_group) #################### MOVE TO ROOT ####################### #################### ERROR ####################### parm_group = parm_group parm_group.remove("testParm") #parm_group.appendToFolder(parm_group.findIndicesForFolder("Misc"),node.parm("testParm").parmTemplate()) parm_group.appendToFolder(parm_group.findIndicesForFolder("root"),node.parm("testParm").parmTemplate()) node.setParmTemplateGroup(parm_group)
  20. How to run python script node?

    Hi guys, a noob question here but I cannot continue without this and can't figure it out either. How to run a python node? A guy in tutorial said ctrl+enter but that doesn't work for me and nothing happens in python shell.
  21. Can i addSection("PythonModule") sop null How i create "PythonModule" in sop null or sop geo with python georoot = "/obj" geo = hou.node(georoot).createNode("null" , "test") pm_section =geo.type().definition().addSection("PythonModule") pm_section.setContents("your_python_module_contents") But : hda worked myref : https://www.sidefx.com/forum/topic/61047/
  22. Setting Default Scene File

    Hey there, So I have been looking around on various posts to try and find out how I take my template scene file and make so whenever I open a version of Houdini that template file is the one that opens. I know very little about scripting and I am not sure what I am meant to change in the 123.cmd file. Anyone ever done this and know how to set it up, please? Thanks
  23. Python export selected nodes, netbox

    Hello guys, is there some clean way, how to export selected nodes, netboxes to clean hip scene file? We cant find any simple solution. Now we exporting json with list of objects, merge scene to new clean scene and delete all except list. Crazy, but it works. Thanks a lot for ideas.
  24. ( I posted this on the sidefx forum as well, posting here as well to hopefully get more eyes on this . ) Hey there guys. So in my journey to learn some scripting/python... I am having some issues ( code below ) So I am trying to create a shelf script that goes through all geo objects in the scene, creates a new specific geo node, and within it make a pointcloud that would be made from the values collected. I am hoping to build the pointAttrib dict, and as it's looping through the objects, append to the list. at the end of the script, I want to print/use the list of values but only one set of values prints. I am expecting at least 10 object names and their respective values. Anyone have the time to point me in the right direction? I'd love to know what I am doing wrong. pointAttrib ={} def selectSubChildrenOfType(node, node_type): for child in node.allSubChildren(): if child.type() == node_type: #print child.name() #print child.worldTransform() trX = str(child.worldTransform().at(3,0)) trY = str(child.worldTransform().at(3,1)) trZ = str(child.worldTransform().at(3,2)) #create dictionary from info above. keys = {'name': child.name(), 'tx': trX, 'ty': trY, 'tz': trZ} pointAttrib.update(keys) # print "obj "+ (pointAttrib["name"]) + " transX " + (pointAttrib["tx"]) # print a readable version of the values we generated. # print "translate X: " + trX # print "translate Y: " + trY # print "translate Z: " + trZ # executes the defined function above. selectSubChildrenOfType(hou.node("/obj"), hou.objNodeTypeCategory().nodeTypes()['geo']) #create a point per transform matrix that was found in the selctSUbChildrenOfType function. for key in pointAttrib: print key print pointAttrib[key] Question number 2: How would the code look for creating a node only if it doesn't exist. ( if I point to the specific node directly ). It's a bit of a chicken or an egg problem and I'm not sure how I would solve it. So far I have tried.. but yeah it's not right, but at least thats where my head is at. Any ideas? hints? tips? def createNodeIF(node, name) for child in node.allSubChildren(): if child.name() != name: hou.node("/obj").createNode("geo", "pointcloud" ) Any help would be appreciated.
  25. I need to create a HDA with uisoparm handle which will be show/hide on hotkey, and dynamically tune different parameters in my hda. For example by pressing some hotkey it will tune param0, and after pressing same hotkey it will tune param1, etc... The problem is that I can't understand why uisoparm handle doesn't shows in viewport after its creation. Another handles like circle, xform, vector works fine. template.bindHandle("circle", "my_handle") But uisoparm handle doesn't appear in viewport , and I can't understand why here is example of my code. also I attached a hip file with hda. import hou import viewerstate.utils as su class State(object): def __init__(self, state_name, scene_viewer): self.state_name = state_name self.scene_viewer = scene_viewer self.node = None self.start_pt = None self.end_pt = None self.displayRotHandle = True self.start_handle = hou.Handle(self.scene_viewer, "rotate_start") self.end_handle = hou.Handle(self.scene_viewer, "rotate_end") self.displayCarveHandle = True self.carve0_handle = hou.Handle(self.scene_viewer, "carve_0") self.carve1_handle = hou.Handle(self.scene_viewer, "carve_1") def onEnter(self, kwargs): self.node = kwargs["node"] # rotation handles init self.start_handle.disableParms(["tx", "ty", "tz", "rx", "rz"]) self.end_handle.disableParms(["tx", "ty", "tz", "rx", "rz"]) self.start_handle.show(True) self.end_handle.show(True) self.start_handle.update() self.end_handle.update() self.displayRotHandle = True # carve handles init self.carve0_handle.show(True) self.carve1_handle.show(True) self.carve0_handle.enableParms(["input", "k","onoff"]) self.carve1_handle.enableParms(["input", "k","onoff"]) self.carve0_handle.update() self.carve1_handle.update() self.displayCarveHandle = True self.start_pt = self.node.node("start_pt").geometry() self.end_pt = self.node.node("end_pt").geometry() def onMouseEvent(self, kwargs): """ Find the position of the point to add by intersecting the construction plane. """ ui_event = kwargs["ui_event"] device = ui_event.device() origin, direction = ui_event.ray() return True def onKeyEvent(self, kwargs): ui_device = kwargs["ui_event"].device() self.key_pressed = ui_device.keyString() if self.key_pressed == "a": if self.displayRotHandle == True: self.scene_viewer.showHandle("rotate_start", 0) self.scene_viewer.showHandle("rotate_end", 0) self.scene_viewer.showHandle("carve_0", 0) self.scene_viewer.showHandle("carve_1", 0) self.displayRotHandle = False else : self.displayRotHandle = True self.scene_viewer.showHandle("rotate_start", 1) self.scene_viewer.showHandle("rotate_end", 1) self.scene_viewer.showHandle("carve_0", 1) self.scene_viewer.showHandle("carve_1", 1) return True def onHandleToState(self, kwargs): # Called when the user manipulates a handle handle_name = kwargs["handle"] parms = kwargs["parms"] prev_parms = kwargs["prev_parms"] node = kwargs["node"] if handle_name == self.start_handle.name(): # user manipulates rotation start handle node.parm("rot_start").set(parms["ry"]) if handle_name == self.end_handle.name(): # user manipulates rotation end handle node.parm("rot_end").set(parms["ry"]) if handle_name == self.carve0_handle.name(): # user manipulates carve 0 handle node.parm("carve_0").set(parms["k"]) node.parm("first_u").set(parms["onoff"]) if handle_name == self.carve1_handle.name(): # user manipulates carve 1 handle node.parm("carve_1").set(parms["k"]) node.parm("second_u").set(parms["onoff"]) def onStateToHandle(self, kwargs): # Called when the user changes parameter(s), so you can update dynamic handles if necessary handle = kwargs["handle"] handle_parms = kwargs["parms"] node = kwargs["node"] if self.start_pt != None: pos_start = self.start_pt.point(0).position() else: pos_start = [0.0, 0.0, 0.0] if self.end_pt != None: pos_end = self.end_pt.point(0).position() else: pos_end = [0.0, 0.0, 0.0] if handle == "rotate_start": handle_parms["tx"] = pos_start[0] handle_parms["ty"] = pos_start[1] handle_parms["tz"] = pos_start[2] if handle == "rotate_end": handle_parms["tx"] = pos_end[0] handle_parms["ty"] = pos_end[1] handle_parms["tz"] = pos_end[2] if handle == "carve_0" : handle_parms["k"] = 0 if handle == "carve_1" : handle_parms["k"] = 1 def createViewerStateTemplate(): """ Mandatory entry point to create and return the viewer state template to register. """ state_typename = kwargs["type"].definition().sections()["DefaultState"].contents() state_label = "Denis test dynamic handle" state_cat = hou.sopNodeTypeCategory() template = hou.ViewerStateTemplate(state_typename, state_label, state_cat) template.bindFactory(State) template.bindIcon(kwargs["type"].icon()) template.bindHandle("circle", "rotate_start") template.bindHandle("circle", "rotate_end") template.bindHandle("uisoparm", "carve_0", "ownerop('carve_0') owneropgroup('group')", cache_previous_parms=True, handle_parms=["input", "k","onoff"] ) template.bindHandle("uisoparm", "carve_1", "ownerop('carve_0') owneropgroup('group')", cache_previous_parms=True, handle_parms=["input", "k","onoff"] ) return template carve_python_states_v01.zip