I have a text file that has four sets of points. In each set, the first and last points are the start and end points of a curve, and the middle two are the coordinates for two handle points. I have to generate Coon's patch. I only know that these four sets of control points define Coon's patch's boundary. Can anyone guide me further? I have to write a Python script for this, and I am not sure where or how to start. Can anyone explain or point to a resource where I can check out what Coon's patch is? I am new to blender

EDIT: I have drawn the bezier curves. I know the formula for coon's patch but i cannot find how to draw that with script in blender

import bpy
import numpy as np
from bpy import context, data, ops

def new_bezier_point (p0, p0hr, p1hl, p1, t):
    t1 = p0 + (p0hr - p0) * t
    t2 = p0hr + (p1hl - p0hr) * t
    t3 = p1hr + (p1 - p1hl) * t
    p2hl = t1 + (t2 - t1) * t
    p2hr = t2 + (t3 - t2) * t
    p2 = p2hl + (p2hr - p2hl) * t
    return [t1, p2hl, p2, p2hr, t3]

file1 = open('C:\\Users\\yuno gasai\\Downloads\\A3-2 (1)\\A3-2\\coons_patch_points.txt', 'r')
Lines = file1.readlines()

for i in Lines:
        coords = [np.array([float(c[0]),float(c[1]),float(c[2])]), np.array([float(l[0]),float(l[1]),float(l[2])]), np.array([float(r[0]),float(r[1]),float(r[2])]), np.array([float(e[0]),float(e[1]),float(e[2])])]
        curveData = bpy.data.curves.new('myCurve', type='CURVE')
        curveData.dimensions = '3D'
        curveData.resolution_u = 20
        polyline = curveData.splines.new('BEZIER')

        polyline.bezier_points[0].co = coords[0]
        polyline.bezier_points[1].co = coords[2]
        curveOB = bpy.data.objects.new('myCurve', curveData)

        scn = bpy.context.scene
        bpy.context.view_layer.objects.active = curveOB


        obj_data = curveOB.data

        obj_data.fill_mode = 'FULL'

        obj_data.extrude = 0.125

        obj_data.bevel_depth = 0.125

        obj_data.resolution_u = 20
        obj_data.render_resolution_u = 20

Resultant curves

And this is what i am trying to implement enter image description here enter image description here enter image description here enter image description here

  • $\begingroup$ Wikipedia knows what it is... You need a 3D interpolation between the points. There must be a set of rules or sample code online. $\endgroup$ Nov 11, 2022 at 9:43
  • $\begingroup$ i cant find the right functions in blender scripting i know the structure of coon's patch but i am havibg trouble finding to draw a bezier curve with giving start point end point and two handle points. $\endgroup$
    – Rklohana
    Nov 15, 2022 at 9:51
  • $\begingroup$ only one curve? Or the entire surface? 2 handle points each, or 1 for end, 1 for start? $\endgroup$ Nov 15, 2022 at 18:32
  • $\begingroup$ yes i need to draw 4 bezier curves through python script each curve has 2 handle points, 1 start point and 1 end point $\endgroup$
    – Rklohana
    Nov 15, 2022 at 22:16
  • $\begingroup$ I cant seem to find how to draw a curve from start point to end point in python every method i saw for drawing bezier curve only used 1 point as location $\endgroup$
    – Rklohana
    Nov 15, 2022 at 22:17

1 Answer 1


EDIT: I posted this back when you were asking only about the curve editing script. I'll check your edit and see if I can update the answer.

import bpy
from mathutils import Vector

C = bpy.context
D = bpy.data

path = D.curves.new("path1", 'CURVE') # create empty curve data
spline = path.splines.new('BEZIER') # create a new spline
spline.bezier_points.add(1) # already has 1 point by default
spline.bezier_points[0].co = spline.bezier_points[0].handle_left = Vector((-1,0,0))
spline.bezier_points[1].co = spline.bezier_points[1].handle_right = Vector((1,0,0))

spline.bezier_points[0].handle_right = Vector((-0.5,0.5,0))
spline.bezier_points[1].handle_left = Vector((0.5,0,0))

curve = D.objects.new("Curve1", path) #make a new object from the data
C.collection.objects.link(curve) # link the object to the scene

This re-creates the default bezier curve. Note that the handles that are outside the bounds (1. left handle and 2. right handle) share the coordinates of their control points. It's not terribly important where they are, but it looks much nicer in edit mode. Of course you can also use this to edit existing curves.

  • $\begingroup$ i got the idea but i am having trouble with things like patches i know with coon's algorithm will give me 4 contour points after then i am stuck on what to do with those points $\endgroup$
    – Rklohana
    Nov 18, 2022 at 14:32

You must log in to answer this question.

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