| Home Page | Recent Changes | Preferences

PerformCreateUTSet.Mel

This is a little MEL script I wrote to help me prepare static meshes for export from Maya PLE with unEditor. It appears that unEditor doesn't support the Scale parameter that all the old howtos say it does (broke in 4.5?) but it supports the group to a limited extent (without a group it generates sequential bogus group numbers). A lot of this code is stolen from performCreateSet.mel and a few other built in scripts.

performCreateUTSet.mel:

proc setOptionVars (int $forceFactorySettings)
{
    // The variables in this "option" box are not options          
}

global proc performCreateUTSetSetup (string $parent, int $forceFactorySettings)
{
    setParent $parent;
    
    textFieldGrp -edit -tx "myLevel" createUTSetPackage;
    textFieldGrp -edit -tx "" createUTSetGroup;
    textFieldGrp -edit -tx "" createUTSetMesh;
}

global proc performCreateUTSetCallback (string $parent, int $doIt)
{
    setParent $parent;
    
    if ($doIt) {
        performCreateUTSet 0;
        addToRecentCommandQueue "performCreateUTSet 0" "CreateUTSet";
    }
}

global proc createUTSetOptions ()
{
    string $commandName = "performCreateUTSet";
    string $callback = ($commandName + "Callback");
    string $setup = ($commandName + "Setup");
       
    string $layout = getOptionBox();
    setParent $layout;
    setUITemplate -pushTemplate DefaultTemplate;
    waitCursor -state 1;
    
    string $parent = `columnLayout -adjustableColumn 1`;
    
    textFieldGrp -label "Package" -tx "myLevel" createUTSetPackage;
    textFieldGrp -label "Group" -tx "" createUTSetGroup;
    textFieldGrp -label "Name" -tx "" createUTSetMesh;
    
    setUITemplate -popTemplate;
       
    string $applyBtn = getOptionBoxApplyBtn();
    button -edit -label "CreateUTSet"
           -command ($callback + " " + $parent + " " + 1)
        $applyBtn;
    string $saveBtn = getOptionBoxSaveBtn();
    button -edit 
        -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
        $saveBtn;
    string $resetBtn = getOptionBoxResetBtn();
    button -edit 
        -command ($setup + " " + $parent + " " + 1)
        $resetBtn;
             
    setOptionBoxTitle("Crete UT Set Options");

    waitCursor -state 0;
    
    setOptionBoxHelpTag( "createUTSet" );

    eval (($setup + " " + $parent + " " + 0));      
    showOptionBox();
}


proc string assembleCmd()
{
    string $SMName = `textFieldGrp -q -text createUTSetMesh`;
    string $PackName = `textFieldGrp -q -text createUTSetPackage`;
    string $GrpName = `textFieldGrp -q -text createUTSetGroup`;
    
    string $cmd = "";
    
    $cmd += "$createUTSetResult = `sets -name "+$SMName+"`;";
    $cmd += "addAttr -ln package -dt \"string\" "+$SMName+";";
    $cmd += "addAttr -ln group -dt \"string\" "+$SMName+";";
    $cmd += "setAttr -type \"string\" "+$SMName+".package \""+$PackName+"\";";
    $cmd += "setAttr -type \"string\" "+$SMName+".group \""+$GrpName+"\";";
    
    return $cmd;
}

global proc string performCreateUTSet(int $action)
{
    string $cmd = "";

    switch ($action) {

        //  Execute the command.
        //
        case 0:
            //  Get the command.
            //
            $cmd = `assembleCmd`;

            //  Execute the command with the option settings.
            //
            evalEcho($cmd);

            break;

        //  Show the option box.
        //
        case 1:
            createUTSetOptions;
            break;

        //  Return the command string.
        //
        case 2:
            //  Get the command.
            //
            $cmd = `assembleCmd`;
            break;
    }
    return $cmd;
}

To install this script, paste the text into a file (Notepad works) and save it as performCreateUTSet.mel in C:\Program Files\AliasWavefront\Maya 4.5 Personal Learning Edition\scripts\other. To make a shelf button to run it, type "performCreateUTSet 1" in the command bar at the bottom left of the main window and then open up the script editor window (button to the right of the script output bar). Select the command from the upper pane of the script editor and either left or middle drag it to the shelf. To set a key to run it open the key mapper and assign "performCreateUTSet 1" to a key.


Tarquin: what's a mel script?

Mychaeel: Given the link context I added, I expect it's some sort of import/export script for Maya. :-)

inio: Tarquin: MEL is Maya's internal scripting language. Mychaeel: Thanks for adding the context. I just wanted to get this posted once I had it working last night.

MythOpus: Please Ignore The Fact that I have no Idea how to work Maya, but what does the script do?

inio: It automates the process of creating a set, adding "package" and "group" attributes to it, and setting those attributes. This normally requires about 10 clicks, a few menu selects, and typing in "package" and "group" (every time you want to set up a new mesh). Using this script it takes 3-5 clicks, and no unnecessary typing.

Related Topics


Category Modeling

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

Mapping Topics

Mapping Lessons

UnrealEd Interface

Questions&Answers

Scripting Topics

Scripting Lessons

Making Mods

Class Tree

Questions&Answers

Modeling Topics

Questions&Answers

Log In