Jump to content


  • Content count

  • Donations

    0.00 CAD 
  • Joined

  • Last visited

  • Days Won


Everything posted by Stalkerx777

  1. How to get a callback event on cook?

    You might want to use Object/Python Script or Sop/Python SOP nodes for this. Or create a new "Python based" operator via File -> New Asset > Python type and you'll be able to put your cooking code into the Code section of the operator
  2. how to update a menu items (not using menu script)

    This is what I did when I needed something like this. I added a callback to my menu A and used an intermediate data storage, so when I trigger menu A, it would update the storage and trigger the callback for menu B. Example of A -> B dependency Menu A parameter callback: def changed(): # Since Menu B depends on value of Menu A, we calculate the values for Menu B in this callback and push them to the "storage" values_for_menu_b = [1, 'a', 2, 'b', 3, 'c'] # setUserData wants a string (setCachedUserData can take any Python object, but only lives within the session) kwargs['node'].setUserData('storage', str(values_for_menu_b)) # Trigger menu_b, this will cause the menu script to evaluate kwargs['node'].parm('menu_b').pressButton() Menu B menu script: def menu_items(): # eval'ing the string into a list of tuples for the menu return eval(kwargs['node'].userData('storage')) Hope this helps
  3. Setting Default Scene File

    https://www.sidefx.com/docs/houdini/hom/locations.html Add this to $HOME/houdini18.5/scripts/123.py: hou.hipFile.load("your_scene.hip")
  4. Parameter Expression by Python

    0. Switch expression language to Python (you've done that already) 1. Set a keyframe on the string parameter. This is required! 2. Set your expression like this: hou.expandString("$HIPNAME").split('_')[0]
  5. Store Houdini environment variables between sessions

    hou.hscript("set -g VAR=val") Will save the variable in the hip file
  6. Python 3, using old Python 2 scripts

    This is simply not true. There's a huge difference between python 2 and 3. There's a reason why there's still massive amounts of Python 2 code around even after 12 years since Python 3 came out. Changes to import mechanics, strings and unicode, iterators, metaclasses just to name a few. Switching to Python 3 is not trivial. For simple scripts, converting manually is a reasonable option, for bigger projects I use this tool: futurize Check out this guide: https://docs.python.org/3/howto/pyporting.html
  7. how to run a bash command and show result to user?

    # myscript.py import os import time for f in os.listdir("."): time.sleep(0.1) print(f) From Houdini: import subprocess # Note the -u flag for unbuffered output cmd = "xterm -hold -e 'hython -u myscript.py'" proc = subprocess.Popen(cmd, shell=True)
  8. Export details to .json files

    Save your geometry with File SOP and set file extension to .geo (not .bgeo). Open it with a text editor and you'll see that it's just a JSON file.
  9. Depending on what you mean by "variables". They can be 1. Environment variables (os.environ), 2. Hip variables (stored in hip): hou.hscript("set -g VAR={}".format(value)) 3. Session variables: hou.session.VAR = "FOO" 4. You can store data on the node: hou.Node.setUserData("VAR", "FOO") and read it back with hou.Node.userData("VAR")
  10. Reading .env file from a centralized directory

    Maybe this will help https://www.toadstorm.com/blog/?p=722 P.S. It might be much easier to write a wrapper script for launching Houdini, instead of struggling with .env and packages
  11. Handle HDA parameter name changes during sync

    What you're looking for is a SyncNodeVersion event handler.
  12. "control" ui elements via python

    It depends, but in most cases you're out of luck. Check the shelf source. If the dialog was created with hou.ui.createDialog(..) then it means there's a source code somewhere and you can lookup the parameter name and set it with hou.Dialog.value(). But I doubt Ocatane devs chose this way it most likely implemented in HDK. Your best bet would be to check if Octane provides some sort of Python API or maybe ask them directly.
  13. Python SOP, in what order does Houdini evalute it?

    Python SOP should not modify any node parameters, this SOP is for manipulating geometry. For modifying parameters - use expressions To answer your question: Houdini networks are DAGs and the order is on Houdini's discretion, based on what has been already cooked and/or changed. In most cases, you should not be building network logic based on nodes order, it's very error prone.
  14. Reading .env file from a centralized directory

    In houdini.env: HOUDINI_PATH=$HFS/houdini:/path/to/my_tools where my_tools is a directory that has a structure which houdini recognises (i.e otls, scripts folders etc )
  15. externaldragdrop.py - only works on some machines? not all

    Haven't used external d&d but I would suggest submitting a bug report, especially if it works on some machines
  16. Stop executing code with warning: python inside Houdini

    There is no way for Houdini to continue executing your code after an exception raised, you must be doing something wrong. Paste your code here so we could check. There are nuances in a way how Houdini handles Python exceptions depending on where the code is being executed. For example if you run some code from a shelf button, than expect it to behave as you would with normal Python except that exceptions won't terminate Houdini process. However if you put a Python expression in a parameter and it raises an exception, it will only stop execution of that parameter code, while the other parameters expressions on different nodes will continue to execute. Similar when you run code in batch mode (Hython) exceptions risen in parameter callbacks won't terminate, you have to take extra care to check for errors and manually call exit() This function just pops up a message to the users and won't prevent your code from continue, check out the docs for it.
  17. Houdini UI Python Library

    Hi, guys! Just wanted to share with you some of my experiments. huilib - is a simple Python wrapper around Houdini's native .ui language. It has been written "just for fun", so no warranty if it works for you, but I think it's pretty usable for a simple UI, in situations, when using PyQt is not an option Maybe someday we'll see something similar from SESI Feel free to use it. https://github.com/alexxbb/huilib
  18. Houdini UI Python Library

    @krishna avril Here you go: https://github.com/alexxbb/huilib Haven't used it in recent Houdini versions, not sure if it still works
  19. Sorry can't help you here. In Linux, I could use ldd to inspect the dynamic section of the binary and see what it wants to load, but I have little experience with that on windows.
  20. This geoisosurface tool uses Houdini dynamic libraries and therefore must have access to them at runtime. Windows searches libraries in the PATH variable, so you need to set this variable before running the program: set PATH="C:\path\to\houdini\bin;%PATH%" Hope it helps.
  21. How to get a system time in HScript?

    Better late than never
  22. Python - Callbacks help

    Have you tried removing the callback in OnDeleted event handler instead of registering it in the nodeColor function? On a side note, are you expecting your caches to pop up and go like every N milliseconds? What you're trying to do looks redundant to me, and if you have a scene with a few dozens instances of you HDA , you'll likely experience a slowdown, because global event loop runs in the main Houdini thread. You could install your event on the node itself ( node.addEventCallback ) and see what nodeEventType works for you. Or install it on the parent container (say your hda is a SOP, install the event on your_node.parent()) so each time you dive into a geo container, it'll trigger the event. Anyway, there's a lot of options
  23. Get pressButton() error raise in try block

    Unfortunately, it's not working that way. I submitted an RFE a long time ago, but they still quiet on this. But you can still get what you want: parm = your_alembic_node.parm("buildHierarchy") cb = parm.parmTemplate().scriptCallback() kwargs = dict(node=your_alembic_node) try: eval(cb, locals()) except: #handle
  24. Python: Copy wrangle to multiple geometry nodes

    wrangle = hou.node("/obj/foo/cullWrangle/") exportNodes = hou.selectedNodes() for n in exportNodes: disp = n.displayNode() # assuming n is of "geo" type w_copy = wrangle.copyTo(disp) w_copy.setInput(0, disp) w_copy.moveToGoodPosition()
  25. Python Embed HDA

    Just use "Embedded" as a file path. hou.HDADefinition.save(file_name="Embedded")