How do you add custom profile prop to operator (like in bevel operator)

Hi
I know I can draw new curve profile with (added in blender 2.82):
layout.template_curveprofile(self, "custom_profile")
There is ‘custom_profile’ property in bevel operator:
https://docs.blender.org/api/blender2.8/bmesh.ops.html?highlight=bevel#bmesh.ops.bevel
But how do I define this property in my operator? There is not such thing as:
profile: bpy.props.CurveProfile()
Any ideas?

You’re right, unfortunately this isn’t possible. There’s a similar situation for the CurveMapping struct: https://blender.stackexchange.com/questions/61618/add-a-custom-curve-mapping-property-for-an-add-on

I didn’t think of this during the GSoC project, but it actually seems like a bigger issue.

I don’t have too much experience in this area, but maybe you could try making a subclass of bpy.types.CurveProfile and then use a PointerProperty?

And it doesn’t feel like a good solution, but you could hijack the CurveProfile struct in ToolSettings.

There is no property for it, you have to create two float properties (one for each axis) and then control them with layout.template_curve_mapping()

I tried to create pointerProp type=bpy.types.CurveProfile (not sure why I shoudl create subclass for it?), but blender would not register this kind of operator property.

Now I tried to use bevel_curve_profile directly in operator draw function:
layout.template_curveprofile(context.tool_settings, “custom_bevel_profile_preset”)
but any changes to curve are gone on operator redo:


It was the same with curve-mapping node in past. I guess operator is undoing any changes to objects, scene, properties, that are not defined in operator itself, before executing itself on prop change.

Testure - yep but it seems curve property is being reset on each operator re-run (when changing operator property)

I figured out that curve is being restored on each operator redo, because I’m runing operator on curve. If I run operator on mesh in edit mode, curve can be adjusted no problem. Too bad that I wanted to use it on curve. Here is simple simple code:

import bpy


def main(context):
    for ob in context.scene.objects:
        print(ob)


class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    bl_options = {"REGISTER", "UNDO"}

    def draw(self, context):
        self.layout.template_curveprofile(context.tool_settings, "custom_bevel_profile_preset")
        
        
    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        main(context)
        return {'FINISHED'}


def register():
    bpy.utils.register_class(SimpleOperator)


def unregister():
    bpy.utils.unregister_class(SimpleOperator)


if __name__ == "__main__":
    register()

    # test call
    bpy.ops.object.simple_operator()

@JoseConseco If you don’t mind the fact that it’s a dirty hack, add Bevel modifier to an object you’ll run your operator on(turn modifier off so you won’t see bevel applied), check custom profile, from here you can edit profile and it won’t get reset in operator’s window if you change other operator’s properties. To update profile in operator’s window you have to hover cursor over it. It works on Curve object as well.
This way you can have Profile widget even as a node property.