I've just moved the MasterClass modules into a sub-folder in Google Docs as it's really confusing now linking to Python modules, it just looks like the files don't exist when you click on them. Thanks to Jaewon Song for pointing this out.
Download link : MasterClass Python Module (Pymel and Cmds versions)
Welcome to my blog, this is the random mutterings from a Senior Pipeline TD currently working for Crytek UK. Thoughts, tips and moans on any subject loosely associated with Autodesk Maya / Python / Pymel / 3d in general. If you've nothing better to do then stick around.
Friday, March 2, 2012
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)
#Result: [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.
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!Mark
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
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
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
Saturday, December 31, 2011
Maya Audio Offset in 2012
In a previous post I mentioned that since Maya2011 they'd changed the way the offset attribute on sound nodes worked:
"So, 2 sets of attrs work together. Offset and EndFrame, SourceStart and
SourceEnd. The Offset is no longer what it used to be, this is the start
of the clip nothing more. If like us you have tons of sound code
designed to offset audio then it's all stuffed! you need to manage both
Offset and EndFrame at the same time now in order to shift a sound node
along time."
Mark
Friday, December 16, 2011
Bug: Duplicate Nodes with Message Links
This is a bug that we had quashed back in 2009 but we've just noticed that it reappeared in 2011 when we were debugging some really unstable animation scenes. Basically you have 2 nodes in Maya with array message links, you duplicate one node and that then generates an exponential amount of message links between the 2 original nodes. In the example below you end up with something close to 100 message links between the 2 original Cube and Cone....EEEEk!
import pymel.core as pCore
Cone=pCore.polyCone()[0]
Cube=pCore.polyCube()[0]
Cone.addAttr('SampleSpace', at='message', m=True, im=False)
Cube.addAttr('SampleSpace', at='message', m=True, im=False)
pCore.connectAttr(Cone.SampleSpace,Cube.SampleSpace, na=True)
for n in range(10):
pCore.duplicate(Cone)
Thursday, November 24, 2011
Python, shit what did we do before it????
So I've been playing with some string formatting for one of our legacy UI's which is basically just a textScroller that gets filled in a loop with all the export Tag information for the current scene, but I wanted to line up the data nicely. In mel this was just horrible but Python..... 1 line!
The format calls on strings are just fabulous, if you've not taken a look at them them I recommend you do so, here's the Python docs that relate to them:
http://docs.python.org/library/string.html
So in the example here we have some string data that we want to carefully format. We want to make sure each entry in the line is the same length and some of them want to be left, right or center justified.
The above tells the format to replace the key 'this' with the passed in arg, then the '.<' tells it that it's left justified and any gaps should be replaced with '.' finally the number after it is the length to pad the data out to.
Similarly the '_^12' is formatting to center justify and adding '_' to the padding. Now that line fed to a loop thats filling the textScroll with scene data formats and lines everything up (as long as you set the fontType to the scroll to be fixedWidth that is)
Now that in Mel was the length of this blog!
The format calls on strings are just fabulous, if you've not taken a look at them them I recommend you do so, here's the Python docs that relate to them:
http://docs.python.org/library/string.html
So in the example here we have some string data that we want to carefully format. We want to make sure each entry in the line is the same length and some of them want to be left, right or center justified.
this='This is'
nice='nicely'
form='formatted'
data='data'
print '{this:.<15}:{nice:_^12}:{form:<20}:{data:>7}'.format(\
this=this,nice=nice,form=form,data=data)
#This is........:___nicely___:formatted : data
So :
{this:.<15}
The above tells the format to replace the key 'this' with the passed in arg, then the '.<' tells it that it's left justified and any gaps should be replaced with '.' finally the number after it is the length to pad the data out to.
Similarly the '_^12' is formatting to center justify and adding '_' to the padding. Now that line fed to a loop thats filling the textScroll with scene data formats and lines everything up (as long as you set the fontType to the scroll to be fixedWidth that is)
Now that in Mel was the length of this blog!
Subscribe to:
Posts (Atom)
