PDA

View Full Version : Creating and launching a folder with MEL


PozestStar
12-16-2011, 09:20 AM
I've been trying to figure this out forever. I ran into this thread:
http://forums.cgsociety.org/showthread.php?t=988313

I tried it out for myself, and it worked! I wanted to see if it would work if my root directory was anywhere, so I made a project folder on my desktop and tested this same script there. It didn't work. It opens My Documents, and I have no idea why. Have I done something wrong here?


string $s = ("snapshots");
string $currentDir = `workspace -q -rd`; //query root directory
string $snapshotDir = `workspace -cr $s`; //create snapshots folder in directoy
string $snapshotPath = $currentDir + $s; //add snapshot to end of root directory so it can be finagled with
string $snapshotFolder = `toNativePath $snapshotPath`; //switch / to \\ so windows can read it
string $openIt = system ("start explorer \""+$snapshotFolder+"\""); //open the snapshots folder

NaughtyNathan
12-16-2011, 10:38 AM
Your problem here is that: workspace -cr does NOT create a folder in the root dir, it creates it in the -directory and, as -rd and -dir could well be different paths, you may just be creating the $snapshots folder in the wrong place. query both -rd and -dir on your PC and see where they both point, chances are you have a "snapshots" folder in -dir and not in the -rd.

Due to this, you will be passing an invalid path to explorer and this results in explorer simply opening your "My Docs" folder.

You could supply a full path to the -cr flag which would avoid this issue. in your case:
workspace -cr $snapshotPath;also, the -cr flag doesn't return any value, so you don't need to bother capturing it as $snapshotDir

:nathaN

PozestStar
12-16-2011, 06:21 PM
That was it. Thanks so much.

CGTalk Moderation
12-16-2011, 06:21 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.