A Mac IS a PC

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.

I am a PC. I am a Mac.
I am a PC. I am a Mac.
Read More

Re-encode entire folders with ffmpeg

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 "*"/
do
    for file in "$folder"/"*".flv
    do
        ffmpeg -i $file ${file%.*}.mp4
    done
done

It’s easy to understand, so you can adapt it to your own needs easily.

Final Gather Visualizer and Render Layers

Recently a friend of mine was using the Final Gather Map Visualizer to diagnose and set the FG of the scene she was working on. One annoying thing though, it was only visible on one Render Layer. After some reading in the documentation of Maya, it appears the Final Gather Visualizer is actually a node: mapVizShape.

If it is a node, then it must be added to the Render Layer to be displayed on that specific Render Layer. To do so, filter mapViz in the outliner and then add it to the Render Layer or just execute that little piece of Python.

import maya.cmds as cmds
if cmds.objExists("mapViz*"):
    mapViz = cmds.ls ("mapViz*", transforms = True)

    renderLayers = cmds.ls(type = "renderLayer")

    for layer in renderLayers[1:]:
        listConnections = cmds.listConnections(layer, source = False)
        nodePresentInLayer = set(listConnections).intersection(mapViz)
        if not nodePresentInLayer:
            cmds.editRenderLayerMembers(layer, mapViz)

Now all your Render Layers can display the Final Gather points in the viewport! Don’t forget to execute it each time you create a new layer.

MEL: How do I find the Transforms of a list of Shape nodes?

On the great website xyz2.net there is the entry on How do I find the Shape node of a Transform? Or the Transform of a Shape node? But what if you want the Transforms of a list of Shape nodes?

proc string[] getTransform(string $shape[]) {
    string $transform[];
    for ($node in $shape) {
        if ( "transform" != `nodeType $node` ) {
            // If given node is already a transform, just pass on through
            string $parents[] = `listRelatives -fullPath -parent $node`;
            appendStringArray($transform, $parents, size($parents));
        }
    }
    return $transform;
}
def getTransforms(shapeList, fullPath=False):
    transforms = []
    for node in shapeList:
        if 'transform' != cmds.nodeType( node ):
            parent = cmds.listRelatives( node, fullPath=fullPath, parent=True )
            transforms.append( parent[0] )
    return transforms

Infinite loops? Naaah

Did it ever happen to you to feel stupid in front of your program stuck in an infinite loop?

We all now that feeling…

The documentation of Mari’s API and the Python Console are really bad to work with, but at least there is one great thing about Mari: you can very easily stop your scripts if they are stuck.

Simply hit Ctrl+C in the terminal Mari has been launched from and… that’s it, your script stopped and you can continue to work normally. It’s quite useful especially since Mari takes a lot of time to simply print some strings.