Technical Notes

Screen_shot_2011-09-26_at_12
I recently started documenting technical issues that I encounter or things that I learn during my Maya scripting projects, and decided to share the notes with the public. I hope others will find it useful when troubleshooting. Click here to see the docs.

Posted by Daniel Vasquez
 

Curve Vectors Tool

This script finds a vector from a curve. I needed it for orienting a follice to the same direction as the curve's base, which corresponds to the first two cvs. After writing it, I realized that using edit points (ep) or curve points (u) would give a more accurate direction. Good enough for now, but will rewrite it.

UPDATE: Turns out that I could just use the pymel function tangent to accomplish the same thing (i.e. finding the tangent at a given point on a curve). For example, to find the tangent at parameter 0, which is the start of the curve, execute curv.tangent(0)

Posted by Daniel Vasquez
 

Hair From Particle Paths

(download)

I got hooked on my last script (see previous post) and decided to extend it by creating a hair system out of the particle paths. I'll post the script when it's working more smoothly, but here are a couple screencaps.

Posted by Daniel Vasquez
 

Curves From Particle Paths

(download)

Wrote a little script today. It generates cv curves from the path of a particle object or individual particles. Click here to see the code and a demo.

Posted by Daniel Vasquez
 

Gitting With It

Just learned about Github embedding with Gist. To celebrate the excitement, here are small pymel snippets you may find useful!

Posted by Daniel Vasquez
 

Selecting Vertices Sharing Two Edges

Screen_shot_2011-04-08_at_1
Here's a Python snippet that selects vertices sharing only two edges (using maya.cmds as mc):

With the mesh object selected,

obj = mc.ls(sl=True)[0]
vertCount = mc.polyEvaluate(obj, v=True)
vertList = ['{0}.vtx[{1}]'.format(obj,vert) for vert in range(vertCount) if len(mc.polyInfo('{0}.vtx[{1}]'.format(obj,vert), ve=1)[0].split(':')[1].split()) == 2]
mc.select(vertList)

The if statement containing the polyInfo command does the filtering by counting the number of edges around the queried vertex. Unfortunately this returns a line of values in a string, so I had to split it a couple times to retrieve the edges count. For example, vertex 302 of 'polySurface' is shared by the edges 506, 489, 484, and 485:

mc.polyInfo('polySurface.vtx[302]', ve=1)[0]
# Result: u'VERTEX 302: 506 489 484 485 \n' #


UPDATE: A vertex sharing two edges is called 'winged'. Here's another way to select winged vertices using PyMEL (as pm)...

obj = pm.ls(sl=True)[0]
vertList = [obj.verts[v] for v in range(len(obj.verts)) if len(obj.verts[v].connectedEdges()) == 2]
pm.select(vertList)

Posted by Daniel Vasquez