def exportControl(curves, name):
'''Export a control curve
'''
if not isinstance(curves, (list, tuple)):
curves = [curves]
grp = mc.group(em=True, name=name)
for each in curves:
ml_parentShape.parentShape(each, grp)
mc.delete(grp, constructionHistory=True)
tempFile = mc.internalVar(userTmpDir=True)
tempFile+='tempControlExport.ma'
mc.select(grp)
mc.file(tempFile, force=True, typ='mayaAscii', exportSelected=True)
with open(tempFile, 'r') as f:
contents = f.read()
ctrlLines = ['//ML Control Curve: '+name]
record = False
for line in contents.splitlines():
if line.startswith('select'):
break
if line.strip().startswith('rename'): #skip the uuid commands
continue
if line.startswith('createNode transform'):
record = True
ctrlLines.append('string $ml_tempCtrlName = `createNode transform -n "'+name+'_#"`;')
elif line.startswith('createNode nurbsCurve'):
ctrlLines.append('createNode nurbsCurve -p $ml_tempCtrlName;')
elif record:
ctrlLines.append(line)
with open(controlFilePath(name), 'w') as f:
f.write('\n'.join(ctrlLines))
return grp
评论列表
文章目录