TomRaynor Posted February 7, 2014 Share Posted February 7, 2014 Hi, Just trying to work out how to set (colour, or I suppose spline) ramp parameter values using python. I have sussed out the code to get the ramp positions and colour values, just not how to set them. Aside: The reason I want to do this is because I am making a quick and dirty python utility script to copy a ramp parameter's values and apply them to another ramp parameter, because as far as I know, you can't do this at the moment... I would love to be proven wrong! Cheers, Tom Quote Link to comment Share on other sites More sharing options...
graham Posted February 7, 2014 Share Posted February 7, 2014 Ramps are really just fancy multiparm parameters. Given a ramp parameter, you can access all the individual parms by calling hou.Parm.multiparmInstances(). This should give you all the position, color and interpolation parms you can then do stuff with. If you are just trying to copy a ramp to another one, you can make use of a hou.Ramp object you get by evaluating a ramp parameter and just setting the other parameter with it: >>> p1 = hou.parm('/obj/geo1/null1/parm') >>> p1.eval() <hou.Ramp is_color=True num_keys=2 data=((t=0, rgb=(0, 0, 0.9)), (t=1, rgb=(0.9, 0, 0)))> >>> p2 = hou.parm('/obj/geo1/null2/parm') >>> p2.eval() <hou.Ramp is_color=True num_keys=2 data=((t=0, rgb=(0, 0, 0)), (t=1, rgb=(1, 1, 1)))> >>> p2.set(p1.eval()) >>> p2.eval() <hou.Ramp is_color=True num_keys=2 data=((t=0, rgb=(0, 0, 0.9)), (t=1, rgb=(0.9, 0, 0)))> 1 Quote Link to comment Share on other sites More sharing options...
TomRaynor Posted February 9, 2014 Author Share Posted February 9, 2014 Ah amazing. I didn't realise that you could set the second ramp parameter that simply. I was trying to get a list of values and keys for the "ramp to copy" and then somehow create and set the keys and values in the second ramp. I got stuck as I couldn't find a way to set the second ramps keys and values using python. Can you set any general multiparm's values in this way then? Thanks! 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.