Just a little reminder to get all the different ways of passing arguments from a native Maya UI.
Just type anything and see the result in the text field at the bottom. You can see that when you use a class, the basics methods offered by Maya do not work.
Some methods are obviously better than others, personally I totally recommend the use functools.partial, it gives only advantages over the others. Pymel is great, but I personally don’t use it any more as some studios don’t support it—as well as Autodesk—and because I had some crash problems with it in batch mode in the past, and don’t forget the 2 seconds freeze from its first import.
The Qt (cute) framework is easily available since Maya 2011 switching to PySide in Maya 2014 but I will not cover those cases for now.
Turtle is a lighting and baking renderer originally developed by Illuminate Labs, available as a beta in June 2003 and released as 1.0 version the 31 June 2004. Predominantly used for fast baking textures in the game industry in conjunction with Beast, it is owned by Autodesk since July 2010 when they acquired the company Illuminate Labs.
It was first bundled with the 2011 Autodesk Maya Entertainment Creation Suite Premium, and then for everyone in Maya 2014 even though it seems to fall into abeyance… strange thing coming from Autodesk.
It can be very useful for ambient occlusion, it is much more faster and cleaner than mental ray… and clunky, especially when using the MEL commands. The documentation is incomplete and nearly non-existent.
One problem I stumbled across was those crazy artefacts you get sometimes when baking Ambient Occlusion. From what I have seen, those come when you try to bake several meshes with the same shaders or with separate UV shells AND if you try to bake in more than 2K.
Taken from this sadly very alone post.
Others can be found here and here (which the user have found the solution, but does not say it, great) and here.
Sometimes the proxy managers in a scene will break and all the proxies will be spread out instead of being linked to a single reference.
Usually it’s better to go back to the last version of the scene since there is not a lot of changes between versions, but for this one, the last clean version was older than a week…
Yes, one week.
The scene was broken for more than a week, but the animator couldn’t see it because he never reopened its scene during that time. The status of Maya/the scene was unstable while the artist was working on it, and each time he saved, it was saved in that unstable state… thus why we couldn’t recover any version less than a week old.
So here I am with no proxy managers, no animation and a week of work vanished.
As a TD, you are often asked to trace a bug or a crash, and it is way more easy when you have all the actions and logs done by the user/software.
To do so, you usually have to modify the userSetup.mel of the user when you can and begin the logging… Then remove it when you are done.
The Maya command cmdFileOutput is quite handy for that.
What a hassle to do that for every single user each time you want to trace and debug something. It can be very cumbersome especially if you have a lot of users to manage. So what about a global and automatic solution that activate only for specific users at a time?
All you need to do is to put the script in the global startup of Maya, and activate it only if the username is in a specific file that you can access and modify very easily.
Sometimes the colors of the animation curves in the graph editor are not in RGB anymore, either it was changed by a tool or by another human, it’s hard for you to work with those weird colors. Here is the little quick tip.
To restore the original color of a curve, select a node curve by right clicking on a red field in the Attribute Editor and uncheck ‘Use Curve Color’ in the ‘Anim Curve Attributes’ section, or use this script to do it for every animation curve in a scene:
objList = cmds.ls(type="animCurve")
for objName in objList:
cmds.setAttr(objName + ".useCurveColor", 0)
string$objList[] = `ls -type "animCurve"`;
string$objName;
for ($objName in $objList) {
setAttr ($objName + ".useCurveColor") 0;
}
In my last article you may have noticed the Context commands were not actually waiting for the user input. All the commands following them would be executed even though the user didn’t complete the Context tool.
The trick (without using the API) is to use a scriptJob that got executed only once, and that is immediately destroyed after its execution.
You call your context tool and create the scriptJob, then that scriptJob will execute the command when the condition you want is met.
If you are drawing a curve for example, the selection will change as soon as the user release its mouse button, you can then process whatever you want to process.
You still have to do some verifications in case the user didn’t cancel the tool.
You can do so by checking if the new selection is what you were expecting, or/and if new nodes were created. Keep in mind that neither of those checks are full proof in this situation.
The final code:
You can even do that for each curve the user draw without exiting the current Context Tool. Do not set the scriptJob with runOnce, and destroy it once the conditions are not checked in the executed_after_action(). That’s it!
Lately I was doing a script involving the Paint effects tool. The command is not available in the documentation so I just used, as usual, the script editor in conjunction of ‘Echo all command’ to get the mysterious MEL command: PaintEffectsTool. Everything’s good, my script is going well but one thing annoys me… I want to pause my script while the user is painting and then do something with his input. The problem is, all the following commands of my script get executed immediately after calling the Paint Effect Tool. It never waits for the user input. I continued my investigation on how to do this… and finally stepped upon the scriptCtx command:
This command allows a user to create their own tools based on the selection tool. A number of selection lists can be collected, the behaviour of the selection and the selection masks are fully customizable, etc.
It kinda worked but not quite well, and I was not satisfied with the result. I then noticed in the command reference of Maya a lot of commands with the suffix Ctx and especially the currentCtx command:
This command returns the currently selected tool context.
Yeah, that’s it, I love that title. Just enough to alert the cortex of everyone, Apple fanboys have their blood boiling hard now, and some may think “What the hell is he talking about?”.
Because yes, the essence of Apple differentiating the two worlds of Mac and PC since several years now, is to make two different clan that feels really different to each others and have to fight for their kingdom. It’s totally marketed and it works. “Think different” is one of the adage of Apple, and its idea of making a Mac so “different” from a PC is a direct result of that.
Keep in mind that when a company is advertising, most of the time, the ads are not directed directly to new clients, but to existing clients who already know their products, this way they will tell to other people how “awesome” the product they bought is, it’s a lot more powerful and have a huge impact on the others.
People need to show to other people how nice their purchase is, to convince themselves that they made the right choice for buying it. And the more the owners get remarks or feel threatened by other people, or feel unique/different, and the more they will defend it no matter what.
If you need to re-encode a lot of videos all at once, each video being in a different folder, here is a little bash script for you.
Just put everything in a file and execute it. The file needs to be executed in the main directory where all the children folders are. If you have spaces in the name of the files, it’ll still work.
#!/bin/bash
for folder in"*"/
dofor file in"$folder"/"*".flv
do
ffmpeg -i $file${file%.*}.mp4
donedone
It’s easy to understand, so you can adapt it to your own needs easily.