Jump to content

dealing with ramp using python


mohamaedkamal

Recommended Posts

# Initialize new ramp.
node = hou.pwd()
ramp_parm = node.parm('ramp')

bases = [hou.rampBasis.Linear] * 5
keys = [0.0, 0.125, 0.25, 0.375, 0.5]
values = [0.0, 0.25, 0.5, 0.75, 1.0]
ramp = hou.Ramp(bases, keys, values)

ramp_parm.set(ramp)
# Add multiple points to existing ramp.
node = hou.pwd()
ramp_parm = node.parm('ramp')

ramp = ramp_parm.eval()
bases = list(ramp.basis()) + [hou.rampBasis.Constant] * 4
keys = list(ramp.keys()) + [.5, 0.625, 0.75, 0.875]
values = list(ramp.values()) + [0.25, 0.5, 0.75, 1.0]
ramp = hou.Ramp(bases, keys, values)

ramp_parm.set(ramp)
# Change first point value from 0.0 to 1.0.
node = hou.pwd()
point1_val = node.parm('ramp1value') # Point indexing starts from 1.
point1_val.set(1.0)

python_ramp.hipnc

Edited by f1480187
  • Like 5
  • Thanks 1
Link to comment
Share on other sites

  • 3 years later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...