I would like to write a PyMel script that generates a single triangle mesh. Ultimately, I want to understand how to create a mesh in Maya via PyMell using raw verts and normals.
I know that I can create a sphere mesh like so
mySphere = pm.polySphere();
But if I want to make it in a more explicit fashion, I could to the following
import pymel.core as pm;
pm.newFile( force = True );
myTransform = pm.createNode( "transform", name="MyTransform" );
myShape = pm.createNode( "mesh", name="MyShape", parent=myTransform );
myPolySphere = pm.createNode( "polySphere", name="MyPolySphere" );
pm.connectAttr("MyPolySphere.output", "MyShape.inMesh" );
myGroup = pm.group( empty=True, name="MyGroup" );
pm.parent( myTransform, myGroup );
pm.setAttr( "{0}.radius".format(myPolySphere), 10.0 );
What I have learned is that I need a Shape/Mesh node which holds all the raw verts/normals/face information.
However the polySphere node is the mesh generator. In other words, it calculates the position of the verts on the sphere based on parameters passed into the node such as the Sphere’s radius.
Basically I want to do the same thing except I want to inject my own raw vert/normals/faces into my shape node. I want to start by creating a simple triangle. How would I go about this? How do I pass my own vert/normals/faces into a Mesh’s inMesh property? Thanks!