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:
- Curve Mapping ⚙ D15824 Python API: support creating Curve Mapping properties
- Curve Profile ⚙ D15825 Python API: support creating Curve Profile properties
- Color Ramp ⚙ D15826 Python API: support creating Color Ramp properties
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.