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.
Tag Archives: Python
Curve Vectors Tool
https://gist.github.com/1223185
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)
Hair From Particle Paths
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.
Curves From Particle Paths
Gitting With It
Just learned about Github embedding with Gist. To celebrate the excitement, here are small pymel snippets you may find useful!
Selecting Vertices Sharing Two Edges
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)
# 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)
Cache Cloud Is Out
Finally posted my script! It’s a utility that creates Maya Particle Disk Cache (PDC) files from a sequence of point cloud data. You can find more information here. Hope you enjoy it as much as I do.
UPDATE: I modified the script so that it contains more classes and documentation (v0.9.0). Unfortunately, it’s almost twice as slow as the original release (v0.8.4). Feel free to download the code from my website: http://folio.heylight.com/#958712/Code
Cache Cloud finished
The past couple of weeks I’ve been working on a python script that I named Cache Cloud. With all the point cloud data being generated with Kinect hacks and 3D scanners, I thought this would be a useful Maya utility. It writes Maya Particle Disk Cache files using an animation of point cloud data. It’s finished, but I’ll post some sample videos before releasing the script within the next couple of days. Thanks to this video, I was inspired to write Cache Cloud. Next I’d like to write another one to make nParticle cache files.
UPDATE: I added another feature that removes zero-value points; and cleaned up some code which is now making it twice as fast to process.
Importing Point Cloud Data
I was inspired by the making of a music video and wanted to try the same thing using their data with Python in Maya. I also ended up trying it with the House Of Cards data. Eventually, I’ll make a GUI that allows for easy point cloud data import into Maya. I wonder how this data can be used for polygon modelling – something else to try.