Welcome to od|forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

Search the Community: Showing results for tags 'python'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Lounge/General chat
    • Education
    • Jobs
  • Houdini
    • General Houdini Questions
    • Effects
    • Modeling
    • Animation & Rigging
    • Lighting & Rendering
    • Compositing
    • Games
  • 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 143 results

  1. Hi everyone, I'm trying to have my Python Module in my HDA place another node right below my asset on creation. So my OnCreation script runs my python module from disk, which has the following code: pos = first_node.position() second_pos = (pos[0], pos[1] - 2) second_node.setPosition(second_pos) This does nothing. The second node is always created near (0, 0) in the network editor. But if i run those lines in the Python shell in Houdini, it works just fine. So that tells me that the OnCreated scripts don't wait for the HDA to actually be placed into the scene before running, despite what the docs say (a problem I've run into before). My solution to this was to use hdefereval to wait to run the code until the event loop was idle. This shows promises of working, but I'm running into issues now. The code I'm trying is: pos = first_node.position() second_pos = (pos[0], pos[1] - 2) hdefereval.executeDeferred("second_node.setPosition(second_pos)") but the problem here is that when it goes to execute the code, the variables no longer exist, and the code fails because "Name 'second_node' is not defined". But I use a custom 123.py script every day that has the exact line hdefereval.executeDeferred("hou.hscript(code)") where "code" is a pre-defined variable, and hdefereval has no problem using that variable when it goes to execute. So I'm not really sure what the problem is here. What is the best way to move a node using Python? (and if you know how to get my hdefereval call to work, that'd be even better!) Thanks, ~Chris
  2. So i need to modify file path in all file and filecache nodes. I made python script and it works, but the problem is it works only for selected nodes. I cant find how to loop through all nodes in houdini script to find specific ones and make changes more automatically. Thanks!
  3. Hey guys, I'm very interested in anything with crypto currencies like Bitcoin. I've coded something together that grabs the current Bitcoin price from the web and throws it into Houdini as a 3d text. I've also managed to get the Bitcoin price history and graph it inside Houdini. Don't know tho whom it may be useful but look around or maybe even improve it. Maybe it might create new ideas. Python code and example available in the attachment or at github. The Batchman Bitcoin.hipnc
  4. Came across the above solution when trying to enable OpenCL globally. This is my exact implementation import hou; def set_opencl(parent_node, parm_value): for node in parent_node.allSubChildren(): for p in node.parms(): if p.name()=='opencl': try: p.set(parm_value) except hou.PermissionError: #this handles the case that the parm is inside of a locked .otl pass hou.session.set_opencl(hou.node('/obj/dopnet1'), 1); But get the following error message. have googled but no solution so far. Can any Python experts help?
  5. Hey, I am trying to do some stuff in python with viewport selections. I want to query whether or not the user has anything selected, not necessarily get what is already selected. As far as I can tell the only way to do anything with the viewport is through toolutils. If I use "toolutils.sceneViewer().selectGeometry()" and nothing is selected, it waits until the user hits enter over the viewport before continuing. Is there any way to simply return whether or not any geometry has been selected without having to wait for the user to hit enter? import toolutils sv = toolutils.sceneViewer() geo = sv.selectGeometry() if geo: print "There is a selection" else: print "No geo selected" Thanks! James C
  6. I've been trying to write an expression which will hold a value and change every specified number of frames. I have a point jitter, and an animated seed so the point will change position every timestep, my goal is to have an expression where the the point will stay in the same position for 8 frames and then change position, and remain in that position for another 8 frames and so on. I've attached a very basic scene file if its any easier for you to use that, any help is greatly appreciated, Thanks! PointJitter.hip
  7. Hey everyone, I recently set up a website and a stream for Houdini people or everyone else who is interested in Houdini. I am going to start streaming Houdini every day, starting today. After each stream I will upload results and depending on time a timelapse, a tutorial, a .hip(nc) file or documentation of sorts for everybody to view and examine. Where can you find all this? Website: http://shadesoforange.de/ Stream: https://www.twitch.tv/shadesoforange Who am I? I am studying Animation & Game in Darmstadt, Germany and am 23 years old. I recently finished my internship at RISE FX and am crazy about all Houdini, procedural and CG stuff. More about me here. My first stream is going to start at 15:00 CET. So if you want to hang out and have a chat, come by and say hello! See you!
  8. I'm developing a setup using a Python SOP and came across some behavior that I cannot account for. In my example scene, you'll see that I just have a cube appended with a Python SOP. Enable the Python SOP to see what happens. Inside the Python SOP I'm just getting the parent node (the cube), then trying two different things: 1) append a transform node to the Python SOP, and 2) append a transform node to the cube. The first succeeds, the second fails due to "invalid node type name", and it spawns multiple transform nodes. Here's the code: node = hou.pwd() parent = node.parent() # This works just fine: node.createOutputNode("xform") # This fails due to "Invalid Node Type": parent.createOutputNode("xform") So the first issue is why does createOutputNode from a parent node fail? The error raised is "Invalid node type name", but that doesn't make sense because the same node type name is valid when using createOutputNode from the current node. The second issue is why do multiple transform nodes get spawned from a single createOutputNode? EDIT: Only a single transform node spawns when the parent.createOutputNode line is removed, so I believe the second issue is due to the Python SOP re-evaluating the failing code multiple times, each time spawning another successful transform node from the Python SOP. createOutputNode_example.hip
  9. Would it be too much of a hustle to implement ability to "tear out" sub menus like one is able to do in Maya? It would be beneficial in learning when studying the nodes. Especially in the node area when using the TAB.
  10. How does the pivot work when using the make transform Vop node? I am trying break down and figure out the function of the Make Transform node using python (Outside of any 3d software). The Translate is pretty basic as I can just place them into a matrix as they are x = m[3][0], y = m[3][1] and z = m[3][2]. For rotation I am using the following: def EulerToMatrix(Rotation): x, y, z = Rotation XM = M3([[ 1, 0, 0], [0, math.cos(x), -math.sin(x)], [0, math.sin(x), math.cos(x)]]) YM = M3([[math.cos(y), 0, math.sin(y)], [0, 1, 0], [-math.sin(y), 0, math.cos(y)]]) ZM = M3([[math.cos(z), -math.sin(z), 0], [math.sin(z), math.cos(z), 0], [0, 0, 1]]) return (ZM * YM * XM) I can then just pipe this information into the Matrix4. The problem I have now is that I cannot find any information that I can understand on how to apply the pivot to the matrix4. It's not as simple as just adding. I have attached a file that has the make transform that I am using to test against. The pivot seems to be linked to the rotation and so I am guessing it is related to the scale as well. Is there any way to break down how this pivot transforming works? MakeTransPiv.hip
  11. Hi everyone, Are you a big fan of the Houdini Tricks website? We are - that's why we invited the man behind Houdini Tricks, motion designer and developer Erwin Santacruz, to be our featured Houdini Artist. He's not only a tireless contributor to the Houdini community, he is also a great teacher. Here, he walks us through building Python shelf tools in Houdini. We hope you enjoy his tutorial as much as we did, Patricia and the GridMarkets team
  12. Hi, I´m trying to create a custom panel editor. Still in the early stages, but I would like to have my QToolBox has the same size of his parent widget the QScrollArea. I was thinking about implement resizeEvent() to resize the QToolBox (horizontally) when the QScrollArea changes size. But I´m always getting the wrong sizes from QScrollArea, even changing the size of the panel I´m receiving the (1,1,638,478) size from the viewport().geometry() or sizeHint(). I´m puzzled!! Thanks for helping!
  13. Currently I wanted to change some rops´s image path parameters with python. I have the problem that python converts my strings with e.g. "$F4" or "$JOB" expressions in it to absolute paths. Can I avoid that? e.g. : c.parm("vm_picture").set("//testDirectory/teststring_$F4.v001.exr") turns to: //testDirectory/teststring_0079.v001.exr How can I set this up with keeping the $JOB or $F expressions in it? is this possible?
  14. Hi all, I have a small question about the best behavior when one wants to keep the track of the source scenes for a specific task/asset. Let's say you want to cache a sim. Usually you will make several versions of it. I think it is important to have the source file for each sim/cache version that is saved at the caching time (maybe in the sim/cache folder). Houdini has a 'post-render script' capabilities but my knowledge of hscript or python is very limited. Any ideas how to do that? Thank you! Cheers, Cristian
  15. Hi Everyone, I was wondering if there is anyway in Python to run a function only when the left mouse bottom being held down? Thanks,
  16. Hi guys, I am working on a python script that bakes the hand movement of geometry with mouse in the viewport over the time and creates keys on each frame. In other word, I want to move my object with mouse in the view port and get the Transform/Rotation/Scale keyed on each frame. Currently I am using hou.selectedNode() and the hou.parm() to access the specific parameters that I want to bake. Then I use a for loop to generate keyframe on each frame. Immediately after pushing the bake button it bakes the parameters value on the first frame for entire time line. I have tried using while loop with time.sleep() to wait for a bit after setting key on each frame, but it freeze the view port and I cant move my geometry. Is there anyway to make my code somehow that constantly check the new values of object parameters on each frame and allow me to work on the view port while it does its job in the background? Is this related to multi threading? Here is my for loop for f in timeline: setKey = hou.Keyframe() setKey.setFrame(f) setKey.setValue( keyValue[f] ) ParmList.setKeyframe(setKey) hou.setFrame(f) Thanks,
  17. There are various event handlers you can use with HDA's (like onCreated, onInputChanged etc.) but I can't seem to find one that can be used as a callback for when the output connection of the HDA changes.. Basically i'm trying to create a custom version of the gas disturbance, part of which has the option to visualise the block size of the disturbance (just with coloured points on a grid). So I was thinking I would use an event handler on the HDA to know when it was connected and then in python traverse down the children to find the solver then traverse back up to find the smoke object so I can get the size and center to position the grid correctly. Is this possible? Is this a stupid idea?
  18. Hello I'm trying to make a little script that would check which frame was the last one rendered and then would continue the rendering process if necessary. It's a Windows machine The easiest way I could think of doing it was simply using the subprocess module to call the hrender script with the proper arguments, but I having some trouble The relevant code is def main(): last_known_frame = get_last_frame(RENDER_DIR) if last_known_frame is not None: hrender_command = "hrender -e -f {} {} -d {} {}.hip".format(last_known_frame, END_FRAME, OUTPUT_DRIVER, PROJECT_NAME) os.chdir("V:\Programs\Side Effects Software\Houdini 15.5.607\\bin") subprocess.call([hrender_command], shell=True) However, I get a "hrender -e -f... is not a recognized as an internet command..." I tried using subprocess.call(["hrender", hrender_command], shell=True), with the proper path to the HIP file, but then it calls it like they were two different arguments, which isn't the case So three questions Is what I'm doing possible? What am I doing wrong? Is there a better way? Regarding the second question, I superficially searched how to use HOM on a generic script but apparently you need to assign PATH variables and such on Windows, it looks like a mess I would prefer to avoid if possible Thank you
  19. Hello, I am struggling with adding all deep render properties inside a mantra node with python. To do so manually via interface is quite simple, I go to node - edit render properties - filter *deep* - add them all. However I am modifying mantra nodes with python and it would be great if I could do the same thing automatically. So far it seems rather tedious - I need to create all ParmTemplates, match their signatures and append to a FolderParmTemplate and set this to the node. Another thing worrying me is menu parameters - I do not need to create interface with menus, can I only set the desired value? Is it equivalent to creating a string parameter and setting it's value to menu item's name (not label)? Thanks, Juraj
  20. Hi, I'd like to access the 'Hide When' parameter field in 'Edit Parameter Interface' via python. The idea is to access this field and store a string such as "{ showmoreinfo == 1 }". Is there a way to easily do this? I searched and found workarounds which involve calling the hide method i.e. hou.parm('/out/mantra1/vm_lightexport_scope21').hide(1) but this result in an inefficient system requiring hoops to achieve what I want. Any ideas? Thanks Luca
  21. Has anyone else encountered an issue with an hda python module where the OnInputChanged evaluates twice? I'm not sure what's causing it... Even simple code in the module triggers it -- eg: node = kwargs['node'] print node ^ I get two printouts of the node each time i change the input connection. I originally noticed this when I was trying to query the connected input. When I did node = kwargs['node'] input = node.inputs()[0] print input I would get an error saying the index was out of the tuple range, followed by a correct printout of the first input connection. The first eval seems to trigger before the connection is actually made, hence why it errors the first time through. Then the second eval triggers once it's connected. This is bizarre, and I haven't yet figured out what's causing it. Surely this isn't standard behavior. Anyone else seen this or have ideas as to what's causing it? Thanks, Chris
  22. Hey Guys! I have a pretty newbie question about some Python and HDA interaction. So in a nutshell I'm trying to create an HDA with implemented Python script which does the following: 1. I have an Original Geo, which is object merged in my HDA. 2. I select some primitives on my original geo (or on the HDA). 3. After I selected my primitives, with a press of a button on my HDA, the selected primitives will be added to a group's pattern parameter inside my HDA. 4. And of course it would be great if this could work with a relative reference, so if I copy my HDA multiple times it'll update the groups within the correct HDA. I have this code so far: import toolutils viewer = toolutils.sceneViewer() geo = viewer.selectGeometry() s = geo.mergedSelectionString() # How can I make THIS PATH relative reference? n = hou.parm('/obj/Colorzied_Geo_Asset_1/Colorized_GEO/group1/pattern') n.set(s) I put together a pretty simple example file and the hda, which will hopefully help you guys understand what I'm trying to achieve. In case my explanation is a little confusing. selectedPrims_python_problem_v001.hip colorzied_geo_asset.hda Any help or nudge in the right direction would be greatly appreciated! Thanks in advance! Best, Laszlo
  23. Hi all, I'm attempting to write a particle cache exporter and I'm having trouble getting the Python module to use functions that are stored in a different section. My instinct was to create a new output driver type as the category made sense, but there were a few challenges which I'll mention here for others facing the same issues: The 'Render to Disk' button's Callback Script section is greyed out. To run code when this button is pushed you need to Create a file parameter called 'soho_program' and change it's default channel value to 'opdef:.?PythonModule' Create a file parameter called 'soho_outputmode' and change it's default to 2 This just runs the code in PythonModule. I have another module in which I store the functions that need to be run in PythonModule, but I cannot import these fucntions. The docs about asset modules state that you need to write the following to import another section as a module: import toolutils foo = toolutils.createModuleFromSection('bar', kwargs['type'], 'PFX_Exporter_Functions') However, because this is an output driver, there appears to be no kwargs argument, so I cannot get the kwargs['type'] value. I've tried other methods such as hou.nodeTypeCategories()['Driver']. Strangely the 'Driver' type is not available directly like all the others are as listed here. Does anyone know how to import modules from the other sections when using the Driver type?
  24. Hi, when creating channel defaults inside digital asset I can set it as a value or hscript expression. Is it possible to set it to python expression? A way would be to create OnCreated script which will assign expression to a channel, or use some hscript for executing python command. But I am curious if there is another - better way Juraj
  25. After a bit of light testing it seems that if I import a Python module when loading Houdini, using pythonrc.py, I cannot later use it directly in a parameter expression. Instead I have to import it into the expression again, which could make the expression string more complicated and error-prone (multiple lines or semicolons). Is this really the case? I feel like I must not be doing something correctly.