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
  • 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 177 results

  1. Hi its probably a long shot but I'll try anyway. I am trying to build ui using the old ui scripting with the help of huilib. This is not an argument thread about .ui vs PyQt vs PySide. I am trying to build a selection list in the UI like those you found in hou.ui.selectFromList Upon searching I came across the CHOOSER command with NO helpful hints or docs whatsoever. A lot of examples of how to build it but none to show how to populate it. Can anyone help if they know please? All the examples seems to point that the content was build dynamically. This is taken from one of the examples: undoChooser = CHOOSER 1 VALUE(undoChoices) STRETCH; But thas no pointer of how undoChoices was constructed. Thank you all!!
  2. Hey all, Sorry to add another Python cooking question (I've seen a lot, searching), but here goes. I have two subnets, a 'source' (from an .fbx) and a 'target'. The Objects in each correlate by name, and those in the source subnet are keyframe-animated. I'm driving the target Objects via: sourceMg = sourceNode.worldTransform() # beep boop, additional calculations go here targetNode.setWorldTransform(sourceMg) It works great, but once Houdini caches the frame the script is no longer (apparently) cooked, which makes sense--I pasted my code into a Python Script Object for convenient testing, which I suppose is not its intended use. If the HOM documentation is telling me what to do instead, however, I don't see it. There's the 'Python object' page, but I don't know that this is quite the same. In short: my script works as intended, but after the scene plays through once, Python stops moving the target nodes (I'm guessing because Houdini quits cooking it, since it's not doing anything Houdini expects it to do, like make geometry). Where does a script like this belong? I'm sure there's something embarrassingly obvious I'm missing--it's just a little extra confusing to me because I have to manipulate everything on the Object level. Thanks in advance for the help! If anything's unclear, lemme know
  3. Hey Guys i want to push render to disk button in mantra node via python , but its not working , my code is something like this : myRenderNode = hou.node('/out/baketexture1') myRenderNode.parm('execute') is there any trick to do this ? thanks
  4. Hello all, I'm currently working on a digital asset that creates sections from a given model. Each of these sections will have different values for different sections (the attribute values of all points within a section remain the same). Since the number of sections can vary, I've decided to go with the multiparm list to handle input. Since I've never used the multiparm before, I'm not sure how I can use these values within the HDA. From what I've been able to find here and on odforce, python seems like a good way to go. I've never used python in houdini so I'm a bit lost. How would I use python to accept the user values and set it for the points of the corresponding sections? Any help or leads will be extremely helpful. Pictures attached. Thanks, Rushil
  5. Execute string in Python ?

    Hey guys is there any way to execute string in python ? its my string variable : "hou.parm('/obj/test3_FBX/materials/Google_Hybrid___7/Google_Hybrid___7_surface/map1')" i want to use it to set a parameter , but problem is its a string. im also tried to change it like this : myPath = '/obj/test3_FBX/materials/Google_Hybrid___7/Google_Hybrid___7_surface/map1' hou.parm(myPath) in 3dsmax maxscript you can using a execute syntax before string to do it. is there a similar way in python for that ?
  6. i dont know why i cant rename my nodes with str variable , can anyone tell me what is the problem ? setName not working with getChildrenName variable , but you can change it with typing string directly , for example newNodeGroup.setName('Hello') here is the code myNodes = hou.selectedNodes() getChildren = myNodes.children()[0] getChildrenName = getChildren.name() newNodeGroup = myNodes.createNode('group') newNodeGroup.setName(getChildrenName) thanks
  7. access menu item

    hi, is there a way to access the menu items with python to change dynamically the label name? or adding submenus etc.? in this case i want add a specific hipname beside the label. thx for help or hints. nic.
  8. Hey guys! I'm starting this thread to share few shelf scripts i use and came across, during my houdini journey. Please feel free to add in more! # ADD NODES/OBJECTS TO MANTRA (Customisable) Select node(s) and click on the script to add it to mantra's force object/matte object etc. You can customise where to add by changing the parameter name (line 22) import hou selection = hou.selectedNodes() names = [n.name() for n in selection] my_list = “” if len(selection) < 1 : my_list = "nothing selected, please select at least one object" else: a=1 for sel in selection: my_list = my_list + "\n" + "selected object " + str(a) + ":" + sel.name() a=a+1 hou.ui.displayMessage(my_list, buttons=('OK',)) length = len(selection) print "Number of nodes selected: " + str(length) paths = [n.path() for n in hou.node('/out').allSubChildren() if n.type() == hou.nodeType('Driver/ifd')] selected = hou.ui.selectFromTree(choices=paths) mantras = [hou.node(path) for path in selected] for m in mantras: m.parm('matte_objects').set(' '.join(n.name() for n in hou.selectedNodes())) #CHANGE PARAMETER NAME AS REQURIED print ("Selected mantra nodes : ") + m.name() new_name=' '.join(names) hou.ui.displayMessage("( "+ (new_name) + " ) – added to selected mantra(s) matte objects.", buttons=('*OK*',)) #SETUP DELAYED LOAD Select node(s) and execute. It'll create procedural shader and setup all the parameters. Works on all nodes with 'file' parameter. #function for node variable: return type, description and name def extract_getTypeName(node): nodetype = node.type() description = nodetype.description() type_name = nodetype.name() return type_name #show selection tuple names selection = hou.selectedNodes() print len(selection) my_list = “” if len(selection) < 1 : my_list = "nothing selected, please select at least one object" else: a=1 for sel in selection: my_list = "selected object : " + sel.name() a=a+1 hou.ui.displayMessage(my_list, buttons=('OK',)) #for each object in selection lenght = len(selection) print "DONE!" for i in range(lenght): #create python variable for selected node selected = hou.selectedNodes()[i] if selected: meshop=hou.node('/shop'); meshop=meshop.createNode('vm_geo_file'); meshop.setName('delayed_load_shop_1', 1) targetdshop=meshop.path(); meobj=hou.node('/obj') meobj=meobj.createNode("geo"); meobj.setParms({"shop_geometrypath":targetdshop}); meobj.setName('DELAYED_load_geo_1', 1) targetfile=selected.parm('file') or selected.parm('sopoutput') mefile=meobj.node('file1') meobj.parm("geo_velocityblur").set(1) meobj.parm("vm_forcegeometry").set(0) meshop.parm("file").set(targetfile)
  9. Hi all, I apologize if this is a noob question. Currently I am trying to find out how to change the options in a drop-down menu. Say if there are 3 options, and I am trying to set the option to the second option, I tried doing node.parm('resolution').set(1) I got the following errors: return _hou.Parm_set(*args) TypeError: Cannot set a string parm to a int But if I tried to replace `1` with the string value of the second option, while there are no errors to be seen, the option in the drop down did not get change to the second option at all, it is still stuck at the default option. Any ideas?
  10. Hi, learning python, I'm trying to do a simple test of creating a custom shelf tool that calls a function from a file to create a sphere I copy the create sphere shelf button script: import toolutils import soptoolutils rad = 0.5 kwargs['bbox'] = hou.BoundingBox(-rad, -rad, -rad, rad, rad, rad) sphere = soptoolutils.genericTool(kwargs, 'sphere') sphere.parm("type").set("polymesh") sphere.parm("radx").set(rad) sphere.parm("rady").set(rad) sphere.parm("radz").set(rad) I save a .py file with a new function and paste the script with a small change of - rad = 1 so I have a saved file called spherebig.py that looks like that import hou import toolutils import soptoolutils def createBigSphere(): rad = 1 kwargs['bbox'] = hou.BoundingBox(-rad, -rad, -rad, rad, rad, rad) sphere = soptoolutils.genericTool(kwargs, 'sphere') sphere.parm("type").set("polymesh") sphere.parm("radx").set(rad) sphere.parm("rady").set(rad) sphere.parm("radz").set(rad) in my new shelf tool I enter this on the script tab: import spherebig spherebig.createBigSphere() and when I press the button I get this error: NameError: global name 'kwargs' is not defined am I doing something wrong or is there a different way to create objects this way? Thanks gweiss
  11. hou.OperationFailed handle & format

    Hello, I was wondering how you format to handle a hou.OperationFailed exception. I was using the below function to convert the file sop to python, because yeah... http://www.sidefx.com/docs/houdini/hom/hou/Geometry#saveToFile but in order to catch the exception it raises hou.OperationFailed http://www.sidefx.com/docs/houdini/hom/hou/OperationFailed So this is not the case for try, except in python. My Houdini Feng Shui is just not showing me the way at the moment. Thanks, -Ben
  12. Hello, I'm trying to import an external python library “matplotlib” on Python SOP with a code below; frommatplotlib.colors import to_hex I downloaded matplotlib 2.0.2 and extracted under User/username/MyDocuments/houdini16.0/python2.7libs, while referring some previous threads and this video tutorial; https://www.youtube.com/watch?v=xoVORgBT190 The last folder (python2.7libs) is what I created. However, the python SOP seems not to find matplotlib. The error message is below; Error Python error: Traceback (most recent call last): File “”, line 4, in ImportError: No module named matplotlib.colors Is there anything else I can try to import it? My working environment is; Windows 7 professional Houdini Indie 16.0.632 matplotlib 2.0.2 Thanks a lot!
  13. Just letting everyone know that there is a yet another new Houdini course on Pluralsight. Please take the time to explore the new course by Framestore FX TD Timothy Stam, Procedural Cities with Houdini and Python. Course Link https://www.pluralsight.com/courses/houdini-python-procedural-cities About the Course In this course, you will learn how to tackle the problem of generating vast CG cities, making use of Python and various Houdini techniques, while maintaining artist control every step of the way. First, you will be introduced to Python itself, and where and how it can be used in Houdini. Next, you will learn how to populate a city plan with buildings of various types, block by block, and how to automate this using Python. Finally, Python is again used to do the heavy lifting on the skyline, building a tool that ensures artist control over the height of buildings. You will use Python to import files from disk, read from and write to files, keep track of what the set-up is doing, build node networks automatically and to develop the technology required to make this city generator work internally. By the end of this course, you will output a vast, automatically generated CG city, instanced upon a point cloud containing all the necessary attributes. With this knowledge, you can go big while keeping your memory footprint as small as possible. About the Author Timothy worked on the cities for the Yorktown sequence for Star Trek: Beyond, did a variety of FX on Pirates of The Caribbean: Dead Men Tell No Tales and has worked on a number of commercial projects, both doing FX and building procedural modeling tools. He studied Digital Effects at Bournemouth University and Game Art at the Utrecht School of Art & Technology and is currently an FX TD at Framestore, having worked as such before at MPC, Electric Theatre Collective and as a TD at Double Negative.
  14. Hey Houdini friends, Does anyone know of how to set zero inputs of subnet in Python? The http://www.sidefx.com/docs/houdini/hom/hou/Node#createNode createNode does not support arguments that sets this, or is it possible to set it after the creation? When I use createNode to create it, the subnet is defaulted to have 4 inputs and 1 ouput. Thank you so much in advance! Best, Viola Lyu
  15. Hi there,I'm trying to change the colour of a primitive once a particle collides with it….but i don't want to use an attribute transfer because that gives me a gradient of colour on the primitive and i want to change the colour back after it's been hit and have it be a solid colour. So hit == green (0,1,0)not hit == red(1,0,0)Another problem i'm having is when i don't use an attribute transfer and write it in a python sop(code below) i change all the primitives colours in one go rather than individually where the the particle collides with each primitive.Not sure how to go about this, but here is the file attached.Any help would be much appreciated.CODE FOR HIT COUNTER AND PRIMITIVE CHANGE COLOUR node = hou.pwd() geo = node.geometry() from hou.session import * inputs = node.inputs() # bring in city searcher data pointcolliders = inputs.geometry().points() ship = geo.prims() if hou.frame() == 1: hitCount = 0 for p in pointcolliders: store = p.attribValue(“hittotal”) # get hittotal attribute from the pop solver hitCount += store # hitcount += store (to add number of hits to hou.session) hits = store green = (0.0,1.0,0.0) red = (1.0,0.0,0.0) #change colour of second input so object for s in ship: if hits == 1: s.setAttribValue('Cd', green) else: s.setAttribValue('Cd', red) particles hit each prim.hipnc
  16. Hey guys I have a python library that does not work well in the Houdini python environment. However, it works fine in my system environment. Is there a way to run a .py file from disk from a python node? If yes, can it be made to use the system environment? Thanks!
  17. Python - Houdini Engine

    Anyone scripted anything for Houdini Engine in Maya? Just want to be able to import an HDA. Any pointers appreciated.
  18. Global variable using python

    Hi guys Can you set global variables using python within an HDA? I have an ordered menu that is being populated by a python menu script. Is it possible to set a global variable from in there? Thanks!
  19. hi there, I have a global attribute that i've made in a python node: citySearcherDistanceTrav = geo.addAttrib(hou.attribType.Global, 'citySearcherDistanceTrav', '') i've then set the attribute with some floats totalDistance = self.stepSize * hou.frame() #speed * time = distance travelled dt = str(totalDistance) geo.setGlobalAttribValue('citySearcherDistanceTrav',dt) #see image 1 But i can't seem to access the values in the next node directly below. I tried find global attrib not sure how to access the data in a python node again. A
  20. Hey guys I have an HDA with 2 python SOPs inside. I need a button on the HDA that would trigger a function in one of the python SOPs. I looked at how callback scripts work but it was too confusing. Appreciate it if someone could help me out. Thanks! Cheers defc0n1
  21. Export Multiple FBX Using Python

    Hey, so I have a situation where i have exported a load of rbd simulations to alembic and i now, after re-importing them back in as alembic archives, I want to export them out from Houdini as FBX. Now, i can do this fine on an individual level, but it takes a while to export each one and then I have to come back and export the next one when thats finished, usually an hour later or something. What i I would prefer to do is to create a python script to automatically export the next one so i can leave them all going over night or something but I dont have any idea how to do this. Can someone please help me out or point me in the right direction? Thanks
  22. Hey everyone I have an ordered menu in my HDA that gets populated by a python script based on an attribute. The name of the menu is data_source: if (geo.attribValue('nHDU') > 1): return ("0", "Primary", "1", "Extension") else: return ("0", "Primary") I'm trying to access this token value from an internal python node using this: value = hou.evalParm("../data_source") Now I know for sure that the nHDU value is >1 and the two menu items are being populated. Problem is, no matter what I select on the menu, I always get a value 0. It works if I add it directly to the ordered menu without using a script. But that defeats the purpose because it should depend on the attribute nHDU. Could someone tell me what's happening here? Thanks.
  23. Hi there, I'm trying to flip the vector once it reaches the boundary of the square and then it carries on moving randomly within the boundary, but i can't seem to get it to do this. I;ve made mirror functions to flip vectors and plus and minus functions but it doesn't seem to work, not sure what i'm doing wrong. A boundaryavoider.hipnc
  24. 2D walker

    Hi there, i'm trying to animate multiple points that move randomly within a boundary. So far i have the random movement done, but i want to be able to get the points to collide with the boundary and carry on moving. Any help would be great. A walker.hipnc
  25. In my attempt at solving a pull focus issue I sourced the following script here on odforce. I then paste into a Python Script digital asset node. But how to get it to run/compile? Should it run automatically? #!/usr/bin/env hython _version = 0.11 ''' Inital Author: "SYmek" from od[force] community. Edited by: Farsheed Ashouri Thanks to everyone who have helped. For more information: http://forums.odforce.net/index.php?/topic/9725-creating-a-new-python-script-for-automating-camera-dof-setup-solved/ ''' import hou def computeFocus(): if hou.selectedNodes(): for node in hou.selectedNodes(): # print node.path() if node.type().name() == "cam": camera = node # else: target = node target = hou.node("/obj").createNode("null","DOF_Controler") theExp='vlength(vtorigin("%s", "%s"))' try: camera.parm("focus").setExpression(theExp % (camera.path(),target.path())) # cT = camera.worldTransform().extractTranslates() # tT = target.worldTransform().extractTranslates() # try: camera.parm("focus").set(cT.distanceTo(tT)) print "Done." except: print "Did you actually select any camera?" else: print "Please select a camera and a target." #if __name__ == "__main__": computeFocus()