How can I ask the user to draw a curve

What i’m trying to do is to make a button, that when clicked allows the user to draw a bezier curve in the viewport just like in edit mode, and once it’s done, to be able to use that curve inside my script.

By “once it’s done” i mean when the user presses another button or hits enter.

Hope I am clear -,_,-

This is a pretty straightforward script, but if you don’t have much experience with the Blender API you might find it a bit challenging.

The summary version would be:

  • it needs to be a modal operator
  • on invoke you need to create a new object and curve data
  • when user input is received, add control points to the curve data or complete the operator.
1 Like

@alvenster @testure The technique is very easy but surely is a lot of boilerplate code.

There is some explanation about the details here (Unity), and it can be ported accordingly to Blender using the gpu module and the mathutils library:

https://catlikecoding.com/unity/tutorials/curves-and-splines/

As I said if there is a way to avoid writing custom code, is feasible to create a curve object and edit it as normal. Another option is to use the Flexibezier addon that has very handy and advance bezier editing.