Created
October 9, 2017 06:02
-
-
Save RedForty/1096ea845e0302b345506f045c8ecdda to your computer and use it in GitHub Desktop.
Working with relative paths in the reference editor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os.path | |
import maya.cmds as cmds | |
import maya.mel as mel | |
import maya.OpenMaya as OpenMaya | |
mel.eval('string $MyScenes; \ | |
putenv $MyScenes "C:/Users/Admin/Desktop/fairy/"') | |
def foo(retCode, fileObject, clientData): | |
print "Callback was given %s" % fileObject.rawFullName() | |
rel = "$MyScenes/" | |
rel = rel + (os.path.basename(fileObject.rawFullName())) | |
print "Callback changed this to %s" % rel | |
fileObject.setRawFullName(rel) | |
OpenMaya.MScriptUtil.setBool(retCode, True) | |
id = OpenMaya.MSceneMessage.addCheckFileCallback(OpenMaya.MSceneMessage.kBeforeReferenceCheck, foo) | |
# for deleting the callback | |
OpenMaya.MMessage.removeCallback(id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment