47
$\begingroup$

For example, in inkscape you can double click to add a new control vertex:

enter image description here

Is there a way to do that in Blender?

The closest thing I have found so far is CtrlLMB, but it just adds an unconnected vertex under the cursor.

Is there a way to add a connected vertex at a specific point along the curve, preferably without deforming the curve?

$\endgroup$
5
  • 2
    $\begingroup$ You can choose two points, press w and then subdivide. That will create a new connected point in between two segments. $\endgroup$
    – user1853
    Commented Apr 22, 2014 at 22:23
  • 1
    $\begingroup$ @cegaton Yes, but it's not very fast (it requires selecting two vertices first). Is there a faster way? $\endgroup$
    – gandalf3
    Commented Apr 22, 2014 at 22:47
  • 1
    $\begingroup$ I have written a bezier splitting functions and could hack it into a modal operator. Do you still need it? $\endgroup$
    – Leander
    Commented Jul 6, 2019 at 19:06
  • $\begingroup$ @Leander I would still be very interested in a working implementation, yes. I don't need it right now though, so don't worry about hacking it together if you don't want to ;) $\endgroup$
    – gandalf3
    Commented Jul 7, 2019 at 4:33
  • 1
    $\begingroup$ I'm ok doing this, it just something I can do to contribute to the open source project. $\endgroup$
    – Leander
    Commented Jul 7, 2019 at 15:58

3 Answers 3

57
+500
$\begingroup$

You can script this functionality with python and install it as an addon. I have created such a script.

Curve Edit Tools

Github download link

To use the addon, press I in the Edit Mode of a curve. You'll be prompted into a modal operation where you can slide a new control point along the curve.

addon in action

The original answer is below, it doesn't cover all the features of the current addon, even the point sampling will be replaced soon. The revision history shows the old addon for 2.7x.


The first step is to import some modules.

  • bpy Interaction with Blenders data and operations
  • bgl Blenders OpenGL wrapper
  • blf Module for font drawing
  • numpy as np Matrix handling, used for mathematical vector operations
  • mathutils Use to create the mathutils.Vector

Create a Bezier class

A Cubic Bézier is a very simple mathematical construct.

It needs four points.

  1. first control point.
  2. first handle (right_handle)
  3. second handle (left_handle of second point)
  4. second control point

$$ b(t) = \sum_{i=0}^{3} \binom{3}{i} t^i (1-t)^{3-i} b_i \\ = (1-t)^3 b_0 + 3t(1-t)^2 b_1 + 3t^2(1-t) b_2 + t^3 b_3 \\ = (-b_0 + 3b_1 - 3b_2 + b_3)t^3 + (3b_0 - 6b_1 + 3b_2)t^2 + (-3b_0 + 3b_1)t + b_0, \quad t \in [0,1] $$

The De Casteljau's algorithm illustrates how points on the curve are found. The formula takes a $t$ in $[0,1]$.

casteljaus algorithm

To split the curve at a specific $t$, we can use the method from this answer. Since we use numpy, we can use the points as points.

class CubicBezier(object):
    def __init__(self, points):
        self.points = np.array(points).astype(np.float32)

    def at(self, t):
        pt =  1 *        (1 - t)**3 * self.points[0]
        pt += 3 * t**1 * (1 - t)**2 * self.points[1]
        pt += 3 * t**2 * (1 - t)**1 * self.points[2]
        pt += 1 * t**3              * self.points[3]
        return pt

    def split(self, t):
        p1, p2, p3, p4 = self.points
        
        p12 = (p2-p1)*t+p1
        p23 = (p3-p2)*t+p2
        p34 = (p4-p3)*t+p3
        p123 = (p23-p12)*t+p12
        p234 = (p34-p23)*t+p23
        p1234 = (p234-p123)*t+p123

        return [p1,p12,p123,p1234,p234,p34,p4]

Next, we need to sample the point closest to the mouse position. Using this algorithm, pick discrete samples and convert them into the 2d region
closest distance

Thats basically everything from the maths side, now just wrap it in a modal operator.

Here is an example of a modal operator drawing in the 3D View.

$\endgroup$
7
  • 3
    $\begingroup$ Wow, works like a charm, and a fantastic example of how to write a modal operator! Thanks! Have a "second upvote" :) $\endgroup$
    – gandalf3
    Commented Jul 10, 2019 at 19:43
  • 3
    $\begingroup$ Should be much more UV! Thanks @Leander. $\endgroup$
    – lemon
    Commented Jul 10, 2019 at 19:48
  • 1
    $\begingroup$ Bookmarked. Exemplary. So much to learn from just one answer. $\endgroup$
    – Robin Betts
    Commented Jul 11, 2019 at 22:33
  • 1
    $\begingroup$ @gandalf3 The influx of imaginary internet points has motivated me to improve the addon. I have now incorporated your main point: not having to select anything, before the insert. The selection of the splines is now more complex and has its settings in the user prefs. Comment, if there are segments of code, which I should explain. I admit, the code is not at all well documented or easy to read. $\endgroup$
    – Leander
    Commented Jul 14, 2019 at 16:41
  • $\begingroup$ @Leander Fantastic, that speeds up the workflow a lot, thanks :D $\endgroup$
    – gandalf3
    Commented Jul 15, 2019 at 1:44
25
$\begingroup$

According to the Blender documentation for Bezier curves and NURBS curves there is no way to add a new point between two existing points without using the subdivide mechanism (selecting two or more points on the curve, W, Subdivide.

I too wish that there were. Perhaps sometime in the future.

$\endgroup$
1
  • 1
    $\begingroup$ That seems to be still true in 3.1. It's difficult to understand why you can add a vertex/control at any position for a curve in the Graph Editor but not in the 3D view. Surprising choice. $\endgroup$
    – mins
    Commented May 7, 2022 at 16:56
3
$\begingroup$

With the last vector in the curve selected, press E for Extrude.

Blender will produce a new vector and attach itself to the cursor. You can move the new vector and left-click to place it.

$\endgroup$
2
  • 7
    $\begingroup$ Pressing E on a control vertex that is already connected to two other cotrol vertices, will result in a disconnected vertex. Not quite what the OP is asking. $\endgroup$
    – user1853
    Commented Jul 6, 2019 at 18:35
  • $\begingroup$ You're talking about a vertex, not a vector. $\endgroup$
    – mins
    Commented May 7, 2022 at 16:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .