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 477 results

  1. 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.
  2. 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?
  3. 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.
  4. 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,
  5. 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
  6. 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)
  7. 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.
  8. 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/
  9. 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
  10. 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.
  11. ( 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.
  12. 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
  13. Hi everyone, I'd like to provide a toggle (on a hda) for switching the Scene View from /obj context to a nested lopnet (/obj/geo/lopnet). Does anyone know a script / command for that? Many thanks!
  14. hello! I am trying to get a python Variable to be brought into Houdini under the "alias and Variables" windows. I was wondering if anyone else has solve this issue and would be able to assist [ cusompaths = test hou.hscript("setenv = $custompaths") hou.hscript("varchange $custompaths") ][/code] thanks josh
  15. In PDG network, how can I access Outputs (see image) of a preview node withing Python Processor context? In other words how can I access @pdg_output or workItem.output from Python Processor node? Update Feb 23, 2:13 pm I tried the following but it prints an empty array. for upstream_item in upstream_items: new_item = item_holder.addWorkItem(parent=upstream_item) print(new_item.inputResultData) Update Feb 23, 2:24 pm (Solved) After struggling with this for 4 hours I finally was able to figure it out by reading HDAProcessor code located at C:\Program Files\Side Effects Software\Houdini 18.5.408\houdini\pdg\types\houdini\hda.py It seams like most of default nodes store outputs with item.addExpectedResultData(...) call. So to get output values of a previous PDG node for upstream_item in upstream_items: new_item = item_holder.addWorkItem(parent=upstream_item) parent_outputs = new_item.expectedInputResultData I hope it helps someone.
  16. How to search through CPIO data?

    Hi there! I'm looking at getting the most out of the hou.Node.saveItemsToFile() & hou.Node.loadItemsFromFile() functions, we're already using them to export/load node snippets, but I was hoping to use the hou.loadCPIODataFromString Function to scan through the file before loading it in. The main idea being to check for node name clashes prio to loading, and then have a set of options to deal with that. However I'm struggling to work out the "proper" way of converting that data into a python friendly format. So far what I'm doing is this: with open(cpio_file, "r") as f: CPIO_string = f.read() CPIO_data = hou.loadCPIODataFromString(CPIO_string) And that gives me what appears to be a massive tuple, full of other massive tuples, filled with raw strings. I can search through them line by line but it feels wrong, very very wrong. Is there some clever way of converting that data block into a python friendly format? Any help is much appreciated! Matt
  17. python reqests lib

    i am trying to use requests inside a python node when i hit the save button an error message keeps popping up Traceback (most recent call last): File "Sop/python/save", line 1, in <module> File "<string>", line 47, in Save File "<string>", line 21, in get_img NameError: global name 'response' is not defined
  18. Does any one know how can I set my Houdinis Python (located on the Houdini install directory) as the default python version used in this machine? At the moment I only have python27 installed (the one that comes with H.18.5.408) and I'd like windows to recognize this. I tried to change the environment variables, and even set a path... As it stands, if I open cmd prompt and write 'python' or 'python --version' its as if I didn't have it installed.
  19. Hi, How can I move default parameters like Translate, Rotate and Scale to a new folder with python? Like in Edit Rendering Parameters we can easily drag and drop any parameter, how to achieve that with the help of python?
  20. Hi, Say there were an existing hip with hdaAsset::1.0 used multiple times throughout various node graphs inside. hdaAsset is now in version ::2:0 and there's been a parameter name change, say from 'inputFloat' to 'inputF'. Would there be a way, upon hip load, to catch that? Maybe an event handler script with a condition in there for that hdaAsset::1.0 node type and parm? The goal is to read the connectors of all hdaAsset::1.0 instanced before the assets gets synced to ::2.0 upon scene load and then wire them into the newly named 'inputF' after sync. Manual rewiring of broken node graphs avoided. Everybody happy. Or, looked at differently, prevent hda sync to the latest version for that particular node type definition, just so the connectors would stay in place. Has anybody dealt with something like that before? Thanks, Hristo
  21. I had an issue with a Python SOP setting the file parameter of an other node, where the Python sat above/before the effected node. Resulting in a broken and somewhat random behavior. This was done in a for loop. What seams to have fixed it was to move the Python SOP to execute under/after the effected node. Could someone explain the order of how nodes are executed? Is it that the nodes are evaluated from bottom up and then executed?
  22. I have a filename param which contains "$F4". When I read it using hou.param('...').eval(), the "$F4" is expanded to the current frame. Is there a way in Python to prevent this expansion, i.e. get the raw string with "$F4" included literally?
  23. I'm using an if condition in my script to validate the existance of a directory. In case it doesn't exist, I want Houdini to stop execuing the code and raise a warning. So far I have: if (condition == False): raise hou.NodeError("No Source Folder Found.") exit() But it seems like houdini is ignoring the raise warning function... EDIT: Looks like the correct function for this is hou.ui.displayMessage("No Source Folder Found."), but it still runs the rest of the code which is not what I want...
  24. Hi everyone, has anyone come across this problem before? been setting up a custom script for drag and drop via the externaldragdrop.py file. Now the weird thing is. it works on some machines and not others. works on my home machine, a colleagues home machine. one of the machines at work and two other and work is does do anything. Whats seems to be happening is houdini, is not even registering that a file is being attempted to be dropped form an external window. So the .py file cant be called? I can't seem to find any documentation on this either which does not help. all machines at work are running the same environment setup. any ideas?? cheers Daniel Happy new year to all
  25. Hi everyone, Short explanation: I want to be able to see parameters (of a Houdini Digital Asset) that I created in Houdini’s Python Module, in Unreal. Long explanation: I’m creating a Digital Asset in Houdini and want to use it in Unreal. When I create parameters in Houdini in the “Type Properties” window everything is fine and the asset works in Unreal and parameters are visible and can be adjusted. Now I added some a Python function in the Python Module of Houdini that creates some parameters. I also created a button that when pressed, triggers this function. This all works in Houdini but as soon as I export this to Unreal the button does nothing. If I use the Sync Session in Unreal (so I have my Houdini and Unreal open at the same time with the same asset) and press on the button (in Unreal), then the parameters do get created in Houdini, but still not in Unreal. The only solution I found so far is, place the tool in Unreal, go back to Houdini’s “Type Properties” window, save the tool again and press “Revert Layout” in the pop-up window. Only then the parameters created in Python get visible in Unreal. But as soon as I place another HDA in the level I have to do that all over again. I want the user to use this tool only in Unreal, without reverting the layout all the time in Houdini. Is there away to achieve this? Thanks in advance, you would really help me out here!