In this example, we'll be looking at how to create new polygonal faces with code, both a simple quad and a more complex example that incorporates an internal hole.
Create a new file, name it polyCreate.py
(or similar), and add the following code:
import maya.cmds as cmds import math def makeFace(): newFace = cmds.polyCreateFacet(p=[(-1,-1,0),(1,- 1,0),(1,1,0),(-1,1,0)]) def makeFaceWithHole(): points = [] # create the inital square points.append((-5, -5, 0)) points.append(( 5, -5, 0)) points.append(( 5, 5, 0)) points.append((-5, 5, 0)) # add empty point to start a hole points.append(()) for i in range(32): theta = (math.pi * 2) / 32 * i x = math.cos(theta) * 2 y = math.sin(theta) * 2 points.append((x, y, 0)) newFace = cmds.polyCreateFacet(p=points) makeFace() makeFaceWithHole()
If you run the preceding script, you'll see two new objects created, both in the XY plane...