Memo Posted June 7, 2014 Share Posted June 7, 2014 Is it possible to programmatically modify a color ramp via python (add / remove / edit keys,values, basis etc)? All I've found is this http://www.sidefx.com/docs/houdini13.0/hom/hou/Ramp which only explains how to read these values, not write to them. The reason I'd like to do this is: I have VEX code which colors my particles based on a number of color ramps. That all works fine. However editing the color ramps can be cumbersome, and I already have color palettes created in photoshop which I'd like to use. I thought my options are: 1. Hand edit the color ramps to reflect the color palettes. Very boring and tedious. 2. Hand enter the RGB values into VEX. Even more boring and retarded. 3. Write a tool which loads the palettes in whatever format, and modifies a color ramp to reflect the palette. The VEX code just references this color ramp. This code would only execute once obviously, I load my palette and bang, the color ramp is up to date. I loved this idea, because I could scatter a bunch of these nodes around, each one a different palette, and the VEX code just references a different node for a different palette. However I can't find how to modify the color ramp so I'm stuck. My plan B is to output the RGB values to number box arrays, and have VEX reference that, which might be faster anyway, but I lose the in between values and the ability to visually tweak the palette in context. Any ideas? Quote Link to comment Share on other sites More sharing options...
animknight Posted June 7, 2014 Share Posted June 7, 2014 Is this what you want ?? myNode # your node with the ramp parameter attnParm = myNode.parm('attenramp') # Get the ramp parameter attnParm.set(5) # You can add more points to the ramp just by setting the number you want. You can also get the keys and iterate over them and set the value on all ramp parms rampKeys = attnParm.eval().keys() # Get the keys numPoints = len(rampKeys) # Get the number of points for keyNum in range(1, numPoints + 1): posParm = myNode.parm('attenramp + str(keyNum) + 'pos') posParm.set(your value) Similarly you can iterate through other ramp params like color and interpolation and set them accordingly. Hope this helps. Cheers -J Quote Link to comment Share on other sites More sharing options...
Memo Posted June 7, 2014 Author Share Posted June 7, 2014 why shiver me timbers that worked! thanks. Can I ask how and where you found this info? I searched all the docs but couldn't find anywhere that you could do this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.