Python API support for CurveProfile, CurveMapping, and ColorRamp

Hello everyone,

I worked on supporting the creation of CurveProfile, CurveMapping, and ColorRamp properties through the Python API. I only needed curve mapping for my personal project, but went on and added the other two as a bonus. So they are not really “stress tested”.

You can define your own properties of such types, for example:

# Define a curve mapping for a vector value, with 'X', 'Y', and 'Z' buttons in the UI.
# Other types are 'VALUE', 'HSV', and 'CRGB', which are the common curve mapping types for the UI.
my_curve_mapping: bpy.props.CurveMappingProperty(name = "My Curve Mapping", min = 0.0, max = 10.0, subtype = 'XYZ')

# Define a curve profile with the line preset, which will be used when resetting the profile in the UI.
my_curve_profile: bpy.props.CurveProfileProperty(name = "My Curve Profile", preset='LINE')

# Define a color ramp. This will be a default a default ramp with one black, and one white slider.
my_color_ramp: bpy.props.ColorRampProperty(name = "My Color Ramp")

For UI layout, you can use the usual interface templates for them (e.g. template_curve_mapping). It is not possible to use layout.prop as it would require extra parameters to display specific buttons.

There are 3 patches for them:

See there for more details. For application order, each patch depends on the previous one. A single patch for all three can be found here: ✎ P3164 Unified patch

It would be nice if addon developpers around here could try and test them, in case anything is missing, or to improve on the default settings, etc.

17 Likes

This is absolutely awesome!

1 Like

Oh that’s super awesome :slight_smile:

1 Like

This is so great, no more terrible workarounds creating unused colour ramp nodes etc. :grin:

2 Likes

so great!!
but it’s an error?


maybe
#define IDP_CurveMapping(prop) ((struct CurveMapping *)(prop)->data.pointer)

This has been missing for a while! I don’t have a ton of time to test it, but is there an ETA for this to land?

Thanks, I fixed it.

There is no ETA for this. Hopefully it can make it into the next release.

Thanks for doing this @KevinDietrich

Forgive my ignorance, does that mean these widgets can be created for node group interfaces as well ?