Generative

Generative coding

I keep coming back to procedural generation. Something about the unpredictable nature of parametric design really piques my interest.
I’ve begun scripting a system that will be the basis of a generative project, here it is:

import maya.cmds as cmds
import random

curveNumber = 1
curveName = 'string' + str(random.randrange(1,100))
count = 0

for i in range(0,curveNumber):
    pointNumber = random.randrange(4,100)
    pointArray = [(0,0,0)] * pointNumber
    cmds.curve( name = curveName + str(count).zfill(3), degree = 3, point = pointArray )
    pointCount = 0
    directionX = (random.random() -0.5 )
    directionY = (random.random() -0.0 )
    directionZ = (random.random() -0.5 )
    curveAmount = 0.00001 * random.randrange(1,100)
    for i in range(0,int(pointNumber)):
        oldCurveAmount = curveAmount
        cmds.setAttr( curveName + str(count).zfill(3) + '.controlPoints' + str([pointCount]), pointCount * directionX * curveAmount, pointCount * directionY, pointCount * directionZ * curveAmount )
        curveAmount = curveAmount * 1.1
        print curveAmount
        print oldCurveAmount
        pointCount += 1
    count +=1

This script creates curves of different lengths and CV counts, then arcs them in different directions. I’m hoping to have them arc back as the angle becomes steeper to create an organic curving line.