LumaPictures / pymel

Python in Maya Done Right
Other
490 stars 131 forks source link

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

Closed AdityaNSukarsono closed 7 years ago

AdityaNSukarsono commented 7 years ago

Hi, 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)

I have search for this issue and found this link : https://github.com/LumaPictures/pymel/issues/32 I have tried to use workspace.path() 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..

pmolodo commented 7 years ago

Aditya - have your ever explicitly created or set a "project"? Ie, go the "File Menu" > "Project" > "Project Window" or "Set Project"?

This project directory is what the "workspace" path will refer to. A project is maya's way of providing a standardized directory structure / location for various types of assets (like textures, animation, etc), in addition to just maya scenes.

It sounds like what you want is simply the "directory that current scene lives in", which you can get with just:

pm.sceneName().parent

or

pm.sceneName().dirname()

Also, just for completeness - pymel.core.workspace.getcwd() is neither of these, it's essentially just the path that maya will open it's file dialogs at by default (and it will update whenever you browse to a different path).

Going to close this unless you confirm that you wanted something different, and there definitely is a bug.

AdityaNSukarsono commented 7 years ago

Hai elrond79,

Sorry for late response

Aaah... Yes, this is what i mean -> "directory that current scene lives in". Thank you, my problem solved now.