{"id":84,"date":"2013-05-20T12:43:02","date_gmt":"2013-05-20T02:43:02","guid":{"rendered":"http:\/\/alrichardson.com\/?p=84"},"modified":"2013-08-05T19:41:21","modified_gmt":"2013-08-05T09:41:21","slug":"generative-coding","status":"publish","type":"post","link":"https:\/\/alrichardson.com\/?p=84","title":{"rendered":"Generative coding"},"content":{"rendered":"<p>I keep coming back to procedural generation. Something about the unpredictable nature of parametric design really piques my interest.<br \/>\nI&#8217;ve begun scripting a system that will be the basis of a generative project, here it is:<\/p>\n<pre class=\"lang:python decode:true\">import maya.cmds as cmds\r\nimport random\r\n\r\ncurveNumber = 1\r\ncurveName = 'string' + str(random.randrange(1,100))\r\ncount = 0\r\n\r\nfor i in range(0,curveNumber):\r\n    pointNumber = random.randrange(4,100)\r\n    pointArray = [(0,0,0)] * pointNumber\r\n    cmds.curve( name = curveName + str(count).zfill(3), degree = 3, point = pointArray )\r\n    pointCount = 0\r\n    directionX = (random.random() -0.5 )\r\n    directionY = (random.random() -0.0 )\r\n    directionZ = (random.random() -0.5 )\r\n    curveAmount = 0.00001 * random.randrange(1,100)\r\n    for i in range(0,int(pointNumber)):\r\n        oldCurveAmount = curveAmount\r\n        cmds.setAttr( curveName + str(count).zfill(3) + '.controlPoints' + str([pointCount]), pointCount * directionX * curveAmount, pointCount * directionY, pointCount * directionZ * curveAmount )\r\n        curveAmount = curveAmount * 1.1\r\n        print curveAmount\r\n        print oldCurveAmount\r\n        pointCount += 1\r\n    count +=1<\/pre>\n<p>This script creates curves of\u00a0different\u00a0lengths and CV counts, then arcs them in different directions. I&#8217;m hoping to have them arc back as the\u00a0angle\u00a0becomes steeper to create an organic curving line.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I keep coming back to procedural generation. Something about the unpredictable nature of parametric design really piques my interest. I&#8217;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 = &#8216;string&#8217; + str(random.randrange(1,100)) count = 0 for i [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,18,3,5],"tags":[],"class_list":["post-84","post","type-post","status-publish","format-standard","hentry","category-coding","category-generative","category-maya","category-python"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/posts\/84","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/alrichardson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=84"}],"version-history":[{"count":4,"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/posts\/84\/revisions"}],"predecessor-version":[{"id":176,"href":"https:\/\/alrichardson.com\/index.php?rest_route=\/wp\/v2\/posts\/84\/revisions\/176"}],"wp:attachment":[{"href":"https:\/\/alrichardson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=84"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alrichardson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=84"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alrichardson.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=84"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}