blender 2.80 experiment 5 - scripted curve

Nikolaus Gradwohl2018-12-12T05:30:07+00:00

For this blender 2.80 experiment I created four bezier curves using the blender python api. There have been some changes in the api, but porting existing python scripts to 2.80 is pretty easy - the main changes required for older code to run is how the objects get added to the scenes, because of the new collections in blender 2.80

you can download the blend file here

scripted curves

to run a python script open a texteditor and run a script with ALT-p

the script I used to create the curves is

import bpy
from math import pi,cos,sin
import random

for curves in range(4):
    cd ='Curve%d' %(curves), type='CURVE')

    b ='BEZIER')

    for i in range(60):
        a =  i/10.0 * 2.0*pi + pi/2.0*curves
        r = 0.5
        xh1 = cos(a + pi/2.0) * r
        yh1 = sin(a + pi/2.0) * r
        xh2 = cos(a - pi/2.0) * r
        yh2 = sin(a - pi/2.0) * r

        r2 = random.uniform(0.1,3)

        x = cos(a)*r2
        y = sin(a)*r2
        if i > 0:
        b.bezier_points[-1].handle_right = (x+xh1,y+yh1,i/10)
        b.bezier_points[-1].handle_left = (x+xh2,y+yh2,i/10)
        b.bezier_points[-1].co = (x,y,i/10)

    od ='CurveObject%d'%(curves), cd)
    od.location=(0,0,0) = 'FULL'
Tweet This! submit to reddit Digg! Tags: | no comments | no trackbacks

See also:

blender 2.80 experiment 7 - keyframes
Animation Node experiment - closed curve
Animation Node experiment - script node spiral
blender 2.80 experiment 9 - freestyle
blender 2.80 experiment 6 - fresnell



Leave a response

Leave a comment