Thursday, February 25, 2010

MAYA_PRESET_PATH is an abortion of shame.

Today the animation lead asked me to make a set of MentalRay render settings presets available for everyone.

One would think that this:
MAYA_PRESET_PATH

Defines the location for Maya presets. Each entry in the path points to the directory above the attrPresets directory.

Would mean what you think it means.

But, that's for a completely different preset API, one defined purely for the attribute editor and actually implented in MEL. The nodePreset built-in command used by the render settings window to build its preset list completely ignores MAYA_PRESET_PATH. So instead of setting an environment variable, I have to copy a preset into everyone's home maya/2009-x64/presets directory.

2 comments:

  1. Really appreciate for this explanation after I wasted my life trying to find out what's wrong with the MAYA_PRESET_PATH

    But I eventually found another annoying problem such that when I tried to use the command "nodePreset" to load some pre-saved preset, ex: mayasax.mel , of which the node type is nCloth

    I got an error message like this:

    Error: Unable to find preset file
    /home/...blahblah.../2009-x64/presets/nClothPreset_mayasax.mel. #

    What!? Why does maya have to put a prefix "nClothPreset_" in front of my preset name?
    And tell me that file doesn't exist?
    I really don't understand maya

    ReplyDelete
  2. In Python:
    from pymel.all import *
    from shutil import copyfile
    import os

    defaultPresetPath = mel.saveAttrPreset(whateverNode.name(), presetName, 0)

    # Move the preset wherever you like
    copyfile(defaultPresetPath, newPresetPath))

    # Remove the local maya preset
    os.remove(defaultPresetPath)

    # Load the preset from a custom location
    mel.applyAttrPreset(matchingNodeTypeName, newPresetPath, 1)

    ReplyDelete