i needed a quick script tonight to export a slew of curves outta maya and google failed me so now that i’ve hacked a quick script for it i figure i’ll post it for future lazy coders :) here you go - a simple python script to export curves from maya ;)

from maya.cmds import *
import maya.OpenMaya as OpenMaya
def findNode (name):
    selectionList = OpenMaya.MSelectionList()
    selectionList.add(name)
    node = OpenMaya.MObject()
    selectionList.getDependNode(0, node)
    return node
f = open("c:/curves.xml", "w")
f.write("<curves>\n")
curveNames = ls(type='nurbsCurve')
for i in xrange(len(curveNames)):
    f.write("    <curve>\n")
    curveFn = OpenMaya.MFnNurbsCurve(findNode(curveNames[i]))
    points = OpenMaya.MPointArray()
    curveFn.getCVs(points)
    for j in xrange(points.length()):
        pos = points[j]
        f.write("   
<point value=\"(%g,%g,%g)\" />\n" % (pos.x, pos.y, pos.z))
    f.write("    </curve>\n")
f.write("</curves>\n")
f.close()