-
Content count
439 -
Donations
0.00 CAD -
Joined
-
Last visited
-
Days Won
15
Everything posted by Stalkerx777
-
python How to get a callback event on cook?
Stalkerx777 replied to Gaussian_Guaicai's topic in Scripting
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 -
how to update a menu items (not using menu script)
Stalkerx777 replied to catchyid's topic in Scripting
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 -
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]
-
Store Houdini environment variables between sessions
Stalkerx777 replied to underscoreus's topic in Scripting
hou.hscript("set -g VAR=val") Will save the variable in the hip file -
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
-
how to run a bash command and show result to user?
Stalkerx777 replied to catchyid's topic in Scripting
# 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) -
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.
-
How to know the name the instance of the asset that OnCreated() is associated with?
Stalkerx777 replied to catchyid's topic in Scripting
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") -
Reading .env file from a centralized directory
Stalkerx777 replied to underscoreus's topic in Scripting
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 -
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.
- 1 reply
-
- 1
-
-
Python SOP, in what order does Houdini evalute it?
Stalkerx777 replied to valdomat's topic in Scripting
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. -
Reading .env file from a centralized directory
Stalkerx777 replied to underscoreus's topic in Scripting
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 ) -
externaldragdrop.py - only works on some machines? not all
Stalkerx777 replied to danielsweeney's topic in Scripting
Haven't used external d&d but I would suggest submitting a bug report, especially if it works on some machines -
Stop executing code with warning: python inside Houdini
Stalkerx777 replied to Mozzarino's topic in Scripting
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. -
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
-
@krishna avril Here you go: https://github.com/alexxbb/huilib Haven't used it in recent Houdini versions, not sure if it still works
-
HDK getting started. Compile geoisosurface.C
Stalkerx777 replied to kiryha's topic in HDK : Houdini Development Kit
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. -
HDK getting started. Compile geoisosurface.C
Stalkerx777 replied to kiryha's topic in HDK : Houdini Development Kit
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. -
Better late than never
-
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
-
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
- 1 reply
-
- 1
-
-
Python: Copy wrangle to multiple geometry nodes
Stalkerx777 replied to Chadwick87's topic in Scripting
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() -
Just use "Embedded" as a file path. hou.HDADefinition.save(file_name="Embedded")
- 1 reply
-
- 1
-