pymel.core.workspace.getcwd() doesn't return project directory as intended

491 views Asked by At

I try to make simple tools in maya. I use this script to get the current project directory:

pymel.core.workspace.getcwd()

Sometimes this script is going well. But sometimes the results were not appropriate, like this : D:\MyProject\Movie\EP01\SQ010\SH001

My maya file is in : D:\MyProject\Movie\EP01\SQ010\SH001\scenes

Well, sometimes missing one folder (it's weird)

After searching in google, i get this link : https://github.com/LumaPictures/pymel/issues/32

They say, i should use

getPath()

than

getcwd()

I have tried but, this script still not work because the result is : C:\Users\aditya\Documents\maya\projects\default

Any suggestions? Or what did i miss? I'm using maya 2016 by the way..

1

There are 1 answers

1
Mehdi Louala On

Instead of using PyMel I would recommand to use the conventional Maya command, from Maya's documentation using the command internalVar with the flag userWorkspaceDir should return your current project directory. As follow ;

project_dir = cmds.internalVar(userWorkspaceDir=True)
print project