About Me

Thursday, January 26, 2012

Maya 2012 SP2

Maya 2012 Service Pack 2 has just gone up for download.

As usual the Bug Fix list is completely useless for anybody in serious development. I still to this day don't understand why the AD bug database isn't opened up more so developers can actually track what the bug was and what it's effect is. Saying :

MAYA‐6772: Referencing in an object causes crash

Is completely meaningless except for the guy who submitted the bug in the first place. I want to know what the actual details of the crash were so we can test our pipeline and maybe remove wrapper code that we added to deal with it.

ReferenceQuery Madness!

If you're managing references in Maya and coding functions around it you'll know that the reference commands and query commands available to you are very limited. But here's a kicker that I found yesterday that to me, makes absolutely no sense what-so-ever!
So we all know how flaky the referenceEdit list is, but here's a bit of logic for you that we didn't realize until one of our tools started playing around.

Simple test, make a sphere in a fresh scene and save it, then reference it back into a new scene. Now make a cube and parentConstraint the referenced sphere to it. Now look at the referenceEdits, you should see this:

All well and good. So you'd think that if you queried the refEdits that's exactly what you'd get right? No
cmds.referenceQuery('SphereRN', successfulEdits=True, failedEdits=False, es=True) 
[u'parent -s -r "|SphereRNfosterParent1|Sphere:pSphere1_parentConstraint1" "|Sphere:pSphere1"',
 u'connectAttr "|SphereRNfosterParent1|Sphere:pSphere1_parentConstraint1.constraintTranslateX" "|Sphere:pSphere1.translateX"',
 u'connectAttr "|SphereRNfosterParent1|Sphere:pSphere1_parentConstraint1.constraintTranslateY" "|Sphere:pSphere1.translateY"',
 u'connectAttr "|SphereRNfosterParent1|Sphere:pSphere1_parentConstraint1.constraintTranslateZ" "|Sphere:pSphere1.translateZ"',
 u'connectAttr "|SphereRNfosterParent1|Sphere:pSphere1_parentConstraint1.constraintRotateX" "|Sphere:pSphere1.rotateX"',
 u'connectAttr "|SphereRNfosterParent1|Sphere:pSphere1_parentConstraint1.constraintRotateY" "|Sphere:pSphere1.rotateY"',
 u'connectAttr "|SphereRNfosterParent1|Sphere:pSphere1_parentConstraint1.constraintRotateZ" "|Sphere:pSphere1.rotateZ"',
 u'connectAttr "|Sphere:pSphere1.rotateOrder" "|SphereRNfosterParent1|Sphere:pSphere1_parentConstraint1.constraintRotateOrder"',
 u'connectAttr "|Sphere:pSphere1.parentInverseMatrix" "|SphereRNfosterParent1|Sphere:pSphere1_parentConstraint1.constraintParentInverseMatrix"',
 u'connectAttr "|Sphere:pSphere1.rotatePivot" "|SphereRNfosterParent1|Sphere:pSphere1_parentConstraint1.constraintRotatePivot"',
 u'connectAttr "|Sphere:pSphere1.rotatePivotTranslate" "|SphereRNfosterParent1|Sphere:pSphere1_parentConstraint1.constraintRotateTranslate"']
So when you use the default query calls you actually get the edits back as if the refNode was in an unloaded state, note the connections to the fosterParent which would get created if I actually did unload the reference! Why, why the hell would you want the default option to return the data in an format that was currently invalid.

So there is a way round it, you use the 'liveEdits' flag. All good right, NO, the liveEdit flag returns the data WITHOUT THE DAG PATH! Short names, who the hell returns short names in any code blocks.
cmds.referenceQuery('SphereRN', successfulEdits=True, failedEdits=False, es=True, le=True)
Rant over, gotta go find a way round this now!


Tuesday, January 10, 2012

fileDialog2 in Maya2012

Just thought I'd point out a change in the Maya fileDialog2 command return in 2012. So lets say you run the following and in the dialogue you type in a filename 'BloodyGreat' but don't add any file extension
import maya.cmds as cmds
print cmds.fileDialog2(fm=0)[0]
In Maya2011 the return would be what ever the path you browsed to + 'BloodyGreat' but in 2012 the return now handles filenames without extensions by adding .* to the path, so the return would now be 'BloodyGreat.*' This has broken a number of our old UI's as we expect to be able to strip the extension off inorder to force the correct one. Easy fix, but a bugger to find the bug in the first place!

Our issue was that we were using `substitute $ext $filepath ""` so now that the $ext is .* you're substituting a wildcard for nothing, which returns, NOTHING!

One last thing to point out with this, if you'd passed in any fileType filters to the command then the return will pick the current type and return that extension, which I guess is a good thing. This .* is only when the dialog is set to 'All Files' Mark