In this example, we'll be looking at how to create curves with code. This can be used for a number of different purposes, such as forming the basis for further modeling operation or creating custom controls for complex rigs.
We'll actually be making two curves in this example—a simple one that we create directly and a more complex one that we create one point at a time.
Here's what we'll end up with as our output and moving both curves away from the origin.
Create a new file and name it makeCurves.py
or similar. Add the following code:
import maya.cmds as cmds import math def makeCurve(): theCurve = cmds.curve(degree=1, p=[(-0.5,-0.5,0),(0.5,- 0.5,0),(0.5,0.5,0), (-0.5,0.5,0), (-0.5, -0.5, 0)]) def curveFunction(i): x = math.sin(i) y = math.cos(i) x = math.pow(x, 3) y = math.pow(y, 3) return (x,y) def complexCurve(): theCurve = cmds.curve(degree=3, p=[(0,0,0)]) for i in range(0, 32): val = (math.pi * 2)/32 * i ...