Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / Python / Project Directory with Python?
  RSS 2.0 ATOM  

Project Directory with Python?
Rate this thread
 
53058
 
Permlink of this thread  
avatar
  • Total Posts: 10
  • Joined: 03 October 2008 12:38 PM

Hi,

I’m currently working on a Python based simulation project for my university degree. Part of this project involves saving a proprietary file in the user’s current project directory. Now I’ve searched high and low to find the answer, but as of yet cannot: is there any way to query the Maya API and return the currently selected project directory?

os.getcwd() only ever returns the Maya binary folder (since that’s where the OS is running Maya from) and whilst a setProject command exists, there’s no getProject alternative.

It seems a bit odd that there’s no exisiting commands to bring up the project directory, as I’d imagine thats a fairly obvious step for a lot of custom tools…

Any ideas?

Thanks!



Replies: 0
avatar
  • cgriders
  • Posted: 07 March 2011 10:17 PM

workspace



Replies: 1
/img/forum/dark/default_avatar.png

Genius, thanks.

I can’t believe it was as simple as that, I feel a little bit dumber for not finding that now!

Author: Tom Rowell

Replied: 07 March 2011 10:22 PM  
avatar

Actually, having tested out this command, cmds.workspace( q=True, dir=True ) only returns the directory at which Maya expects to find projects (i.e /username/documents/maya/projects) rather than the actual set project directory (for example in this case /username/my projects/project_name).

Any other suggestions?



Replies: 0
avatar
  • cgriders
  • Posted: 10 March 2011 08:45 PM

import maya.cmds as cmds
import os
.path

projectDirectory 
cmds.workspace(q=Truerd=True)
currentScene os.path.abspath(cmds.file(q=Truesn=True))
if 
'scene' in cmds.workspace(q=Truefrl=True):
       
sceneDirectory os.path.join(projectDirectorycmds.workspace(fre='scene'))


Replies: 1
/img/forum/dark/default_avatar.png

Is there any other way? cause the workspace command, when it’s called in python code without Maya GUI, doesn’t give back any other workspace beside the default one?

Author: malena86

Replied: 18 November 2011 09:16 AM  
avatar

when you say without maya GUI is you’re doing stuff with maya batch? you could always setup an optionvar with your working directory and synchronize it whenever the workspace changes



Replies: 0