Hey,
I’ve been developing this script in 2010 and recently switch to 2012. And I can’t seem to get any part of the scrip to work from the script editor… I know that sounds confusing, but Every time i press the double blue play button nothing happens…
I tried running just parts of the script by selecting a chunk and hitting enter on the numb pad, but to no avail.
Let me know if I’m crazy. If you could help me shed some light on this problem that would be great! Thanks!
##Stitch Heads 1.0
## BEFORE YOU START
##
##Import the heads to the body mesh
##
## The mesh group should be called "mesh"
## the head should be called "meshHead"
## the body should be called "meshBody"
##
##
import maya.cmds as cmds
import maya.mel as mel
rawName = cmds.file(query = True, sceneName = True);
splitName= rawName.partition('.')
oldFileName = splitName[0];
##sets the name of the first head
##cmds.rename('meshHead', 'manHead0');
##saves temp file
tempFile = 'temp.ma';
cmds.file(rename = tempFile);
cmds.file(save = True, type='mayaAscii');
for i in range(0,6):
##check male or female
if cmds.objExists('meshHead' + str(i)):
nameHead = 'meshHead'+ str(i);
nameBody = 'meshBody';
meshGroup = 'mesh';
print i;
##duplicate then combines and binds skin
cmds.select(clear = True);
cmds.select(nameBody);
cmds.duplicate(cmds.ls(selection = True));
dupHead = cmds.ls(selection = True);
cmds.select(clear = True);
cmds.select(nameHead);
cmds.duplicate(cmds.ls(selection = True));
dupBody = cmds.ls(selection = True);
##dupMeshes = cmds.ls(selection = True);
cmds.polyUnite(dupHead ,dupBody);
cmds.rename('polySurface1', 'Body');
##merges head
cmds.select(clear = True);
cmds.select('Body');
cmds.polyListComponentConversion( toVertex = True);
cmds.polyMergeVertex( d=0.001 );
##smooth verts!!
cmds.select(clear = True);
cmds.select('Body');
cmds.polySoftEdge( a=180 );
##delete history and fixing broken shaders
cmds.delete( 'Body' , constructionHistory = True);
mel.eval('AEshadingEngineShadersReplace( "initialShadingGroup.surfaceShader", "initialShadingGroup.volumeShader", "initialShadingGroup.imageShader", "initialShadingGroup.displacementShader", "initialShadingGroup.defaultShadows" );');
mel.eval('defaultNavigation -dtv -d initialShadingGroup.surfaceShader;');
cmds.delete(dupHead, dupBody);
##bind skin to skeleton
cmds.skinCluster('Body', 'Hips', maximumInfluences = 2);
##copy body and head mesh weights
cmds.select(clear = True);
cmds.select(nameHead, nameBody, 'Body');
##cmds.eval('copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation closestJoint;');
cmds.copySkinWeights(influenceAssociation= 'closestJoint' , surfaceAssociation = 'closestPoint', noMirror = True);
cmds.delete(meshGroup);
cmds.select(clear = True);
cmds.select('Hips', 'Body');
##saving merged body
newFileName = oldFileName + str(i) + '.fbx';
print newFileName;
mel.eval('FBXExport -FBXExportFileVersion FBX201000 -f"' + newFileName + '";');
print oldFileName;
print newFileName;
cmds.delete('Body');
##refreshes the scene for the next head
##cmds.file(tempFile, open = True, force = True);
##cmds.file(rawName, open = True, force = True);