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


Forums

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

  1. 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
  2. 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
  3. 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
  4. Write(Modify) Extra File in HDAs

    Hi, there. I have some HDAs that use an external python module. I'd like to package the module into the HDAs so that external files are not necessary to use them. Currently I am embedding the python module using the “Custom Script” event handler, and I want to read file from “Extra Files” Tab. I want to write & read files from HDA's Extra Files Tab. Because I don't want to write & read files from External Directory. If I changed computer, I should move not only HDA asset but related External Files. I want to embed all files related to HDA. The Extra File is just txt file or json file. I already ask same question to sidefx forum. But, I receive some useful tips. I try HDADefinition Module but I cannot find to write in HDA. I spend about two weeks.. otl OTL Is there any way to write in the HDA's Extra Files? Link I asked same question
  5. Similar to the H14 workflow of hitting X on the currently selected node in any vop context to create a visualizer node, I want to do the same but connect the currently selected node to the compute lighting Ce output (or a bind export node set ot Ce but that can throw errors) to quickly visualize the color data of the map I am working on without having to do expensive shader calculations. The visualize node is great when working with Cd in SOPS but does not return the same functionality in shaders This is a default hotkey in arnold for C4D, its like alt+w+v or something. I'm sure there is a way to do this with a python script attached to a hotkey. Any ideas?
  6. 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.
  7. Hi, I'm writing a few shelf tools with hotkey links to allow quick creation of some common nodes (Null (N), Wrangle (W) etc) Here is the simple script if(len(hou.selectedNodes()) > 0): node = hou.selectedNodes()[0] if(node.type().category() == hou.sopNodeTypeCategory()): parent = node.parent() null = parent.createNode("null") null.setNextInput(node) null.moveToGoodPosition(True, False, True, True) null.setSelected(True, True, False) null.setCurrent(True) null.setDisplayFlag(True) Although the new Null is selected and display-flagged correctly, the parameter pane remains on the previously selected node. The outline colour of the null is also yellow rather than orange. Is the a way to fix this?
  8. Hi! Is there way to call "Render to Disk in Background" form Python? Houdini use one thread for generating ifd, so I want spawn rendering in background without H freeze like "Render to Disk in Background", but don't see any information in help or inside node how this works. I implement this in naive way using multiple hrender subprocesses works perfectly fine but subprocesses don't terminates automatically. Any one knows proper way to this?
  9. hello,I would like to use python to move a parameter to a folder. What functions do I need to use? please help me,thanks.
  10. I'm trying to build a list of all the parameters of a certain type from a node in python. For instance for a geo node, I want to build a list of all the toggle parameters on it. Comparing hou.node('/obj/geo1').asCode() and hou.node('/obj/geo1').parms() was going down a very messy road. I was hoping there was a way to use just the .parms() and check if each parameter is a toggle type? *Edit I feel like this may have something to do with it, https://www.sidefx.com/docs/houdini15.5/hom/hou/ToggleParmTemplate However only when I add a spare parameter and run .asCode() does it seem to reference this, and I can compare against .parms(), but it doesn't work on regular parameters.
  11. Blend Node Mask Parameter

    Since I keep forgetting how to do this.... Blend nodes have a weird parameter on them called Mask - it lets you specify what combination of Tx Ty Tz Rx Ry Rz Sx Ry Rz to take from each input. this is called a "Bit Mask" and here is how to figure then out: with a default blend object in your scene (blend1) and something wired into it...anything, a null open a python shell and type: >>> bmask = (then click on the Mask 1 parameter of blend1 and drag it here) you should have this: >>> bmask = hou.parm('/obj/blend1') hit enter now type >>> bmask.eval() hit enter >>> 511 what the hell? here's how to decrypt this number if you turn OFF all the TRS of blend1/Mask1 and type the above again you'l get: >>> 0 turn ON TX >>> 1 turn OFF TX and turn ON TY >>> 2 turn OFF TY and turn ON TZ >>> 4 and so on....each one is double the one before. so how did we get 511? we ADD each one to get a total > 1 (tx) + 2 (ty) + 4 (tz) + 8 (rx) + 16 (ry) + 32 (rz) + 64 (sx) + 128 (sy) + 256 (sz) = 511 so to manipulate this parameter with HOM we can set this parameter to the TOTAL that we want. if we want TX RY and SZ we'd use: ( 1 + 16 + 256 = 273 ) bmask.set(273)
  12. 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
  13. OpenPort and communicate via Python (Socket)

    Hey guys, I saw there is a hscript command ‘openport’, but I didn't find example on how to communicate with houdini via python. Here's what I need to do: 1-Open a port, from localHost, within houdini session. 2-From an external python interpreter, execute houdini python commands, using local port. IE: hou.node('/obj').createNode('geo') Here's how I can do this in maya: 1-cmds.commandPort(name='localhost:7555') 2- client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client.connect(('127.0.0.1', 7555)) c = ‘python(“cmds.polySphere()”);’ client.send(c) Does anyone know if it's possible to this in houdini? Anyone has some examples? Thanks Jonathan
  14. Hello dear community, I am having trouble scripting a second button on my hda. Both functions for the two buttons have been defined in the OnCreate callback in the scripts tab. While the first one is working fine, clicking the second one throws an error, saying the function or attribute defined in the parameter settings is not available. The callback-parameter for the first button has the value: kwargs["node"].hdaModule().OnCreateCurveButtonPressed() The second one has the parameter: kwargs["node"].hdaModule().OnCreateSectorsButtonPressed() And this is the error message that the console throws: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.607/houdini/python2.7libs\hou.py", line 23413, in __getattr__ def _SIDEEF_getattr__(*args): return _hou.HDAModule___getattr__(*args) AttributeError: 'module' object has no attribute 'OnCreateSectorsButtonPressed' Does anybody know whats causing this?
  15. I'm looking for a way to call the hotkey actions that ship with Houdini, for example "Home Selected" in the Network Editor context. I'm not sure what an "action" really is, is it a method invoked via the HOM? In this particular case I've tried using toolutils.homeToSelectionNetworkEditorsFor() but the behavior is not what I expect and would rather invoke the same "Home Selected" method that the hotkeys use via python.
  16. when I link some parameters some of the main node get crazy wire messing up the node. example Node A has some parameters link between them. example nodeA.parm("bla") and nodeA.parm("ble") is set as reference link to nodeA.parm("bla") nothing crazy one parameter looking at another one in the same node. now I want to create a new node and link all the parameters to this new node I want nodeB parameters to look at nodeA, after running the code witch is a regular stuff just setting parameters, some of the paramters in nodeA that were just a integer now have an expression poiting to another parameter =( should I create something like if its an expression use "setExpression" if is not an expression use the regular set? def linkParmsTo(source_node, target_node): """ Link the parms of the source node to those of the target node if a parameter with the same name exists. # Produced by: # Graham Thompson # captainhammy@gmail.com # www.captainhammy.com """ for parm_to_link in source_node.parms(): # Skip folder parms. if isinstance(parm_to_link.parmTemplate(), hou.FolderSetParmTemplate): continue parm_to_link_to = target_node.parm(parm_to_link.name()) # If the target parm exists if parm_to_link_to is not None: parm_to_link.set(parm_to_link_to)
  17. Getting point neighbor in Python

    Hello dear community, I am currently trying to setup a city generator as part of my bachelors thesis. For a basic street layout, I am using a voronoi sop on a plane and fuse these points. It would be a big ease to be able to find the neighbors of a point (not vertices) and get their position. I did some workaround by creating a dictionary with position vectors and counting the positions that match, so I can at least count the neighbors. Does anybody know a trick or a function to do this in pythin? I know there is a VEX function that does that, however I don't know VEX pretty much and I am having trouble understanding their usage, although I read the docs. Any kind of help would be much appreciated. Best regards, Nicolas
  18. Forcing file load via Python

    Hi I create a small python script in the filename entry to load my files. The python code returns the correct file name and path in the filename box. It is all good. But the problem is that I cant get it to load files automatically as the frame advances. I ahve to manually press "reload sequence" on every frame. Please bear in mind that the file names are generated at each frame by reading file names in certain folders so there is no pregenerated file scheme. I tried hou.iu.triggerUpdate but that did not do anything. I also tried the to eval the Reload sequence parm which is reload. That did not work either. I am hoping that someone here might have a better suggestion to get the reload going. Because as of now I cant render. Render out or Rop out does not work because it is not loading the files ;(
  19. Hello everyone, im fairly new to houdini so, i might be doing something completely wrong. At the moment stuck at trying to connect 2 nodes through python. Im trying to replace a material with a new one that i create through python. (Original network Image A), the way i do it manually is I just create a MantraShader and drag the output into the suboutput input(Image B), and that works. So, im trying to do the same thing through python. Here is what ive got so far: import hou shaderPath = hou.node("/obj/materials/CarPaint/") OldShader= hou.node("/obj/materials/CarPaint/CarPaint_surface") shaderConnection= hou.node("/obj/materials/CarPaint/suboutput") NewShader = shaderPath.createNode('mantrasurface') NewShader.setName("NewShader") shaderConnection.setInput(1,NewShader) The problem is that im not sure if the setInput is the right way to go, and, i dont fully understand shaders, but when i disconnect the Oldshader from the suboutput, the input turns from pinkish to white, and when I try to connect my new MantraShader, it doesnt work. (Image C) Sooo, im definitely doing something wrong xD. If any of you have an idea of what im doing wrong, or a completely new approach let me know! Cheers!
  20. Hello, how can I force a channel in a sop to evaluate my python expression as an expression (not as the final value) ? With hscript it is simple I write : `mycode` But with Python I don't get it, sometimes I write something like : frame() or hou.frame() or hou.pwd() And it is recognized immediately as an expression and is evaluated (blue/cyan background), sometimes the very same text is considered as the final value (background black). I sometimes need to enter the code many times in order to have it recognized as code. I do not understand why ? Any help is very welcome (I am on houdini 15.5.565 on Windows 10) Thanks, Nicolas
  21. Hi, how can i merge a PrimGroup (or a tuple of prims with hou.PrimGroup.prims() ) from another hou.Geomtry() into a new hou.Geometry() ? Thanks
  22. Hello, I'd like to include a 'hide/disable when' conditional on a parameter which is being created by a script. How do I do this? null = hou.node("/obj").createNode("null") null.setName('newNull') tabs = null.parmTemplateGroup() for folder in tabs.entries(): tabs.hideFolder(str(folder.label()), True) null.setParmTemplateGroup(tabs) parmGroup = null.parmTemplateGroup() parmGroup.addParmTemplate(hou.ToggleParmTemplate("overrideToggle", "Override Cache Version", 1)) parmGroup.addParmTemplate(hou.IntParmTemplate("overridingVersion", "Overriding Version", 1)) null.setParmTemplateGroup(parmGroup) null.parm('overrideToggle').set(0) null.parm('overridingVersion').disable(1)
  23. STUDENT DEMO REEL 2016

    Hello. I just recently graduated from VanArts which is based here in Vancouver. I have completed my demo reel in FX which is to say primarily using Houdini 15.5. I hope you all enjoy watching it as much as I enjoyed creating it. I am attaching the link below. Please let me know of any suggestions, criticisms all is welcome. Thank you. FX DEMO REEL 2016
  24. Hi All, When using external python modules from a python operator I usually use: import sys pyModPath = node.parm('pyModPath').eval() sys.path.append(pyModPath) This works perfectly for pure python modules but I am having issues with modules that require compiled external dependencies, in particular i am needing to use the pyproj module: https://pypi.python.org/pypi/pyproj? I have tried using a precompiled python wheel when installing through PIP but it still throws an error that the DLL could not be found in HOU (have double checked that I am using and installing for 64bit). I am typically installing the pip modules in the root Python27 folder and linking to the 'Lib\site-packages' folder in that directory (for pyre python I can link to modules anywhere). Unfortunately I am stuck using Windows at the moment. As a note: when using the pyproj module outside of Houdini (through the command line) it works fine. Does anyone have any tips / suggestions how to get these compiled modules functioning within HOU?
  25. Forcing 456.py

    Heya peoples, I'm going round in circles on this one and it might just be down to my poor understanding of python and/or houdini. I've managed to get 90% of what I want for this tool complete but the final piece evades me. I've got a python tempfile.TemporaryFile being created when 456.py is triggered - it works perfectly - i.e. created upon opening a hip and deleted once the hip is closed I think what I want to do is trigger the 456.py from within a shelf tool (which is a custom saver script) I mean this is essentially the age-old quest for an "onSave" callback but sadly I have no understanding of C++ or the HDK so this solution is totally lost on me. Any pointers appreciated Cheers
×