Tuesday, May 13, 2025

Script call from file as shelf item in Maya

Here's a nifty way to dynamically source a file as a shelf command but add a bit of error handling in it to make sure it exists! replace YOURSCRIPT.EXTENSION and YOURPROCEDURE as appropriate.


    string $filePath = `internalVar -userAppDir` + "scripts/YOURSCRIPT.EXTENSION";
string $procedureName = "YOURPROCEDURE()";

// Check if the procedure exists and clear it if it does
if (`exists $procedureName`) {
    print($procedureName + " exists. Clearing.\n");
    eval("global proc " + $procedureName + "() {}");
}

// Check if the file exists
if (`filetest -f $filePath`) {
    print("File found: " + $filePath + "\n");
    eval("source \"" + $filePath + "\""); // Use eval to source the file
    // Check if the procedure exists after sourcing the file
    if (`exists $procedureName`) {
        print("Procedure found: " + $procedureName + "\n");
        eval($procedureName + "()");
    } else {
        warning("Procedure not found after sourcing: " + $procedureName);
    }
} else {
    warning("File not found: " + $filePath);
}

Tuesday, April 29, 2025

Control Curve Creator Script

This one's still a bit of a WIP but I wanted to publish it so I didn't lose it later.



I have spent a fair amount of time over the last 2 months trying to find a script to easily create curve controls for rigs from existing MEL and python curve files.

Because most of these were written in Python they need extra libraries and are a lot more bloated than something simple should be.

I threw this one together, it takes existing MEL and Python curve creation scripts and adds them into a UI to easily add them. You have to make an icon too :)

Functionality isn't quite all there for the grouping but the curves definitely work. 

Download it here