Python scripting problem in Maya 2012

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);

my guess is that it is dropping out on this check:

if cmds.objExists('meshHead' + str(i))

Does “meshHead0” exist in the file without namespaces? Can you select it by typing that name into the “select by name” textbox?

…wow yeah your right that was probably it. I wrote this script 3 months ago and I need to make sure I comment that info out. Thanks so much!

Now I feel extremely silly for posting this!!! ><

I haven’t gone through the whole script to debug, but I at least get a syntax error when I run it.

If nothing is happening, can you confirm that you can run a simpler script successfully?

Ahhhh. Well the problem was that when cmds.select is empty(b/c meshHead in my scene file should have been called meshHead0) it doesn’t pass a null exception… or effect the rest of the script. I never wrote in a debug case for meshHead or meshBody or mesh being wrong. I just expected an error debug to occur when I shouldn’t have.