pymel.core.system.dirmap

static system.dirmap(*args, **kwargs)

Use this command to map a directory to another directory. The first argument is the directory to map, and the second is the destination directory to map to. Directories must both be absolute paths, and should be separated with forward slashes (‘/’). The mapping is case-sensitive on all platforms. This command can be useful when moving projects to another machine where some textures may not be contained in the Maya project, or when a texture archive moves to a new location. This command is not necessary when moving a (self-contained) project from one machine to another - instead copy the entire project over and set the Maya project to the new location. For one-time directory moves, if the command is enabled and the mapping configured correctly, when a scene is opened and saved the mapped locations will be reflected in the filenames saved with the file. To set up a permanent mapping the command should be enabled and the mappings set up in a script which is executed every time you launch Maya (userSetup.mel is sourced on startup). The directory mappings and enabled state are not preserved between Maya sessions. This command requires one mainflag that specifies the action to take. Flags are:-[m|um|gmd|gam|cd|en]

Flags:
Long name (short name) Argument Types Properties
convertDirectory (cd) unicode ../../../_images/create.gif
 

Convert a file or directory. Returns the name of the mapped file or directory, if the command is enabled. If the given string contains one of the mapped directories, the return value will have that substring replaced with the mapped one. Otherwise the given argument string will be returned. If the command is disabled the given argument is always returned. Checks are not made for whether the file or directory exists. If the given string is a directory it should have a trailing ‘/’. Flag can have multiple arguments, passed either as a tuple or a list.

enable (en) bool ../../../_images/create.gif ../../../_images/query.gif
 

Enable directory mapping. Directory mapping is off when you start Maya. If enabled, when opening Maya scenes, file texture paths (and other file paths) will be converted when the scene is opened. The -cd flag only returns mapped directories when -enable is true. Query returns whether mapping has been enabled.

getAllMappings (gam) bool ../../../_images/create.gif
 
Get all current mappings. Returns string array of current mappings in format: [redirect1, replacement1, ... redirectN, replacementN]
getMappedDirectory (gmd) unicode ../../../_images/create.gif
 
Get the mapped redirected directory. The given argument must exactly match the first string used with the -mapDirectory flag.
mapDirectory (m) unicode, unicode ../../../_images/create.gif
 
Map a directory - the first argument is mapped to the second. Neither directory needs to exist on the local machine at the time of invocation.
unmapDirectory (um) unicode ../../../_images/create.gif
 
Unmap a directory. The given argument must exactly match the argument used with the -mapDirectory flag.

Derived from mel command maya.cmds.dirmap

Example:

import pymel.core as pm

pm.dirmap( en=True )
pm.dirmap( m=('/usr/maya/textures', '/share/store/textures') )
pm.dirmap( cd='/usr/maya/textures/characters/skin1.iff' )
# Result: u'/share/store/textures/characters/skin1.iff' #
# Result: /share/store/textures/characters/skin1.iff"
pm.dirmap( m=('D:/mySoundfiles', '/usr/me/sounds') )
pm.dirmap( cd='D:/mySoundfiles/' )
# Result: u'/usr/me/sounds/' #
# Result: /usr/me/sounds/

Previous topic

pymel.core.system.dgtimer

Next topic

pymel.core.system.diskCache

Core

Core Modules

Other Modules

This Page