Maya Tips and Handy Scripts

Decided to keep a log of useful Maya MELscripts & settings I’ve collected from all over the web!

Camera Switching scripts http://forums.cgsociety.org/archive/index.php/t-983953.html
CameraListDialog.mel
SwitchPerspCam.mel

Wireframe Toggle On/Off (Useful for previewing surfaces on selected objects)
ToggleWireframe.mel

Reload All Textures in scene
UpdateAllSceneTextures.mel

Align Pivot to Central Base of object
BasePivot.mel

Toggle Between OS and QT Import/Export Dialog Window (Useful if Maya’s Dialog Runs Slow!)
OSExplorerDialogSwitcher.mel

Toggle Isolate Select Script
http://nerd.paololazatin.com/toggle-isolate-selected-in-maya/

ToggleIsolateSelected.mel

ToggleXray.mel
ObjectMaterialAttributes.mel
RefreshSelectedSwatches.mel
SetSelectedTextureNodeDirectory.py

Set Selected Objects’ Normal Angles to 45
ToggleXray.mel

Advertisements

3 thoughts on “Maya Tips and Handy Scripts

  1. Select the Material of an Object
    From Dave Girard’s Blog:
    http://polygonspixelsandpaint.tumblr.com/post/43852335734

    //Select the Material of an Object
    global proc materialEditorHotkey()
    {

    string $objectSel[] = `ls -sl`;
    string $bufferObj[];
    tokenize $objectSel[0] “.” $bufferObj;

    if ($bufferObj[1] == “”)//just object selected because token buffer is empty
    {
    openAEWindow; source “dagMenuProc.mel”; showSG $objectSel[0];
    }
    else if ($bufferObj[1] != “”)//component selected
    {
    string $shadery = getComponentShader ($objectSel[0]);
    openAEWindow;
    select -tgl $shadery;
    }
    }

  2. Python Script to Set Texture Directory – From http://mayapy.wordpress.com/2012/04/23/fix-texture-paths-in-maya-python-script/

    import maya.cmds as cmds
    import os

    def renameTex(newName):
    tex=cmds.ls(sl=True,type=”file”)
    for item in tex:

    fullpath = cmds.getAttr(“%s.fileTextureName” %item)
    fileName= fullpath.split(“/”)[-1]
    newPath= os.path.join(newName,fileName)
    cmds.setAttr(“%s.fileTextureName” %item, newPath,type=”string”)

    def selectDir():
    folder=cmds.fileDialog2(cap=”locate folder”,fm=3)
    uniToStr=str(folder)

    filePath=uniToStr.split(“‘”)[1]
    cmds.textField(pathText, edit=True,text=filePath)
    global newName
    newName=filePath

    win=cmds.window(title=”RV TEXTURE PATH FIX”,w=350,h=150)
    cmds.columnLayout(adjustableColumn=True )
    cmds.text(“FIRST > select your file nodes in Hypershade!!”,bgc=(1,0,0))
    cmds.frameLayout(l=”browse folder for textures”)
    cmds.flowLayout()
    cmds.text(“file Path”,h=25)
    pathText=cmds.textField(w=250,h=25)
    loadBtn=cmds.button(w=50,h=25,label=”get”,c=”selectDir()”)

    cmds.setParent( ‘..’ )
    fixit=cmds.button(l=”Fix textures”, c=”renameTex(newName)”)
    cmds.setParent( ‘..’ )

    cmds.showWindow(win)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s