Reading and writing ramps and ramp properties

   2272   4   3
User Avatar
Member
537 posts
Joined: Dec. 2005
Offline
A two part technical question:

1). I'm trying to read a ramp in it's entirety. Meaning, loop through all the parameters in the node, hit the ramp .. and gather the ramp (which is a parmTemplate in hou), but also all of the keys, positions, interpolation switches. Right now I can certainly loop through all parms or tuples, but hitting a technical wall when it comes to getting what I'd probably see when I go to edit parameter interface, I want at those. So how would I do that in Python?

2). Next, I'd like to save all relevant information about a ramp into an attribute. This is quite a bit more complicated than say a float parameter. In which I'm already taking the name of the parm, making that the attribute name, then assigning the float value. A ramp could be reproduced as a list, a string, or what I'm seeing in VOPs/VEX as a struct. But there doesn't seem to be a good way to pipe that into an attribute.

Has anyone ventured into i/o with ramps? I'd really like to read, compact, and reuse them as attributes.
Edited by andrewlowell - Oct. 18, 2020 22:00:05
User Avatar
Member
2528 posts
Joined: June 2008
Offline
Have you played around with what the .asCode() method kicks out? What if you just wrote that to disk? Then you could execute the python code to re-establish the ramp later..?

Here is the code that will generate one TAB on a ramp. (it's actually made up of three parameters.)
# Code for /obj/geo1/attribwrangle1/shape1pos parm 
if locals().get("hou_node") is None:
    hou_node = hou.node("/obj/geo1/attribwrangle1")
hou_parm = hou_node.parm("shape1pos")
hou_parm.lock(False)
hou_parm.deleteAllKeyframes()
hou_parm.set(0)
hou_parm.setAutoscope(False)


# Code for /obj/geo1/attribwrangle1/shape1value parm 
if locals().get("hou_node") is None:
    hou_node = hou.node("/obj/geo1/attribwrangle1")
hou_parm = hou_node.parm("shape1value")
hou_parm.lock(False)
hou_parm.deleteAllKeyframes()
hou_parm.set(0)
hou_parm.setAutoscope(False)


# Code for /obj/geo1/attribwrangle1/shape1interp parm 
if locals().get("hou_node") is None:
    hou_node = hou.node("/obj/geo1/attribwrangle1")
hou_parm = hou_node.parm("shape1interp")
hou_parm.lock(False)
hou_parm.deleteAllKeyframes()
hou_parm.set("linear")
hou_parm.setAutoscope(False)
Edited by Enivob - Oct. 19, 2020 09:20:19
Using Houdini Indie 20.0
Ubuntu 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
537 posts
Joined: Dec. 2005
Offline
Thanks Enivob, this is quite a bit more granular than I'm looking for however. The first step is actually finding all the parameters that a the macro-ramp parm contains. Right now they just all seem to be unique parms, which is true. But I just can't believe there isn't a .getchildparms() type thing for a ramp parm. Going by name just seems so sloppy.

I think I might need to write my own format for these things if it doesn't exist, this would need to be stored in an attribute and then read and reconstructed in vops/vex.

I haven't tried the ascode, but this would need to be a non-moving parts thing. No setting of parms or reading writing. Basically:

loop through all parms on a node
if ramp, get all parms in ramp
record all values in reconstruct-able way in point attribute
use point attribute to reconstruct ramp and process data in vops/vex
User Avatar
Member
537 posts
Joined: Dec. 2005
Offline
Here's a complete workflow which:
1. Reads node parameters, including ramps.
2. Turns them into point attributes
3. Uses them downstream

Attachments:
point_cloud_reader_dev.v01.hip (198.0 KB)

User Avatar
Member
385 posts
Joined: July 2018
Offline
Enivob
Have you played around with what the .asCode() method kicks out? What if you just wrote that to disk? Then you could execute the python code to re-establish the ramp later..?

i am trying to find out how this works and implement it in a python module. Can you share a working example of this for a ramp parameter because i am testing the one they have in houdini documentation and its not working for me so far. i dont see the python file in my hip directory where it should be according to the open function documentation
  • Quick Links