Make it possible to create ColorRamp from Python
This is a feature request to make the ColorRamp available from Python.
Currently it is only possible to embed an existing ColorRamp into a custom UI . However it is not possible to create a new ColorRamp from Python, this can only be done in C code.
One workaround is to use an existing ColorRamp, e.g. in a Cycles node, however this workaround has drawbacks and is hacky. Another workaround is to add textures which have an embedded ColorRamp, but this obviously clutters the texture list with helper textures.
5 Comments
bump this would be a very useful feature. Here's an example (bare bones, mind you) of how a custom ColorRamp node would be added (the most relevant portion to this feature request is the 'color_ramp' class variable and the 'draw_buttons' class method).
You're going to have to be more specific here. Color ramps are already accessible all over Blender's interface, including in Python. What, specifically, are you looking to have added?
@Jason van Gumster: They are accessible, but we can't create new ones, e.g. to attach to custom nodes. I updated the description to make it more clear.
@simonwendsche: This is definitely more clear. Though I'd like to see example code that shows how you envision the API to look.
Also, how will the ramps be stored in the .blend file? Currently, they aren't datablocks. Would you be looking to set them up like that, or would they be stored some other way?
@Jason van Gumster: To be honest, I currently have no idea how exactly this would be implemented. This would require a look from an experienced Blender developer. I just wanted to log this issue as a feature request. Maybe in a few years we will have it available... I am developing addons for external renderer integration, so I'm used to this and have a lot of patience.
Another option for me would be to allow OpenGL drawing with bgl/blf in the user interface, like Campbell Barton did in this patch that was sadly never merged: youtube.com/watch But I should probably submit that as a separate request.