The script below is incomplete, but im just interested in this first section.
It checks whether a custom data folder has been created, if not, it creates it in this
location : C:\Users\John\Documents\maya\projects\customData
and opens the ‘save as’ window to save the file.
I would like to specify this location instead: \Users\John\Desktop\3D Projects\Doleman_Project
How would I do that ?
import os
import maya.cmds as cmds
def browseCustomData() :
projDir = cmds.internalVar( userWorkspaceDir = True)
newDir = os.path.join(projDir, 'customData')
if (not os.path.exists(newDir)) :
os.makedirs(newDir)
cmds.fileDialog2(startingDirectory = newDir)
browseCustomData()
though personally, I would avoid 1) using a project folder on your desktop, and 2) intentionally using a folder name with a space in it. I’d suggest using something like: c:\users\john\documents\3d_projects\doleman_project
Yes, I totally agree about desktop and space between folder name.
I do however want to know the process for saving a file to the desktop, so I’ll keep
it in for now and thanks for explaining that.
Its still not creating the customData folder in Doleman_Projects. You didn’t re-insert
the ‘customData’ string on the last thread, so I did it (below), but its still not creating the customData file or opening the correct ‘save as’ dialog box. ??? I know my syntax below is probably incorrect…
Thank you in advance for your help !
If you want ‘customData’ folder to be inside ‘Doleman_Project’, put it in the end, passed as last argument.
When calling os.path.join(), it’s literally joining strings in order you have passed them in, so, in your version, you get ‘customData’ folder under projDir, and all other folders beneath previous ones.
Just rearrange order of string arguments to match your intended outcome.