CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 02-01-2013, 03:22 AM   #1
Froyok
New Member
 
Froyok's Avatar
portfolio
Piquet Fabrice
Student
Belgium
 
Join Date: Apr 2010
Posts: 8
Send a message via MSN to Froyok
[solved] (MEL) Open an explorer window of an other drive

Hello,

I wanted to add a little feature to one of my script which would have be to open a folder from a given path by the user. Unfortunately I have something like a bug/restriction with the "system" command of Maya. I'm using Windows 7 x64 and Maya 2013.

While this work without any problem (it opens the C:\ drive with a new explorer window) :
Code:
system("explorer c: ");


The following one doesn't work and open the "user" folder ("My documents" folder) :
Code:
system("explorer d: ");


Maya is installed on my C:\ drive, so I suspect a sort of restriction... Is there a possible workaround ? Both commands work fine under a command line window, it looks like with the "system" command it's not the case.
__________________
Dev-blog : http://www.froyok.fr/blog

Last edited by Froyok : 02-01-2013 at 02:10 PM.
 
Old 02-01-2013, 11:24 AM   #2
Nyro
Lurking
 
Nyro's Avatar
portfolio
A. D.
Vertex Slinger
Munich, Germany
 
Join Date: Dec 2006
Posts: 1,436
Where Maya is installed doesn't matter, there are no restrictions other than those set by your user or group policy.

When you say running 'system("explorer D:")' doesn't work, what exactly do you mean?

Try running 'exec("explorer D:")' and see if you get a result other than 0 (0 meaning success).
 
Old 02-01-2013, 01:33 PM   #3
Froyok
New Member
 
Froyok's Avatar
portfolio
Piquet Fabrice
Student
Belgium
 
Join Date: Apr 2010
Posts: 8
Send a message via MSN to Froyok
Thanks for your response !

What I'm saying is that Maya open a folder, but the one I want.
Every folder I try to open which are located on my C: drive is a success. However, when I try to open a folder located on my second drive, named "D:", I get the "My Documents". It's always the same.

I tried :
Code:
exec("explorer D:")

It works (I get 0), because the explorer is launched without any problem, but not where I want (it's not the folder I asked).


This morning, after the reboot of my computer it seems that
Code:
system("explorer D:")

works and open my drive D: folder (which was not the case yesterday), however, if I try to open any folder located on this drive I get the same problem as before : it opens my "My Documents" folder.


[EDIT] Haaa, I think I found why it's not working : I was not using the double "\\" (double backward slash).
Since I was calling a system command I didn't thought that the path have to be like that.
__________________
Dev-blog : http://www.froyok.fr/blog

Last edited by Froyok : 02-01-2013 at 01:41 PM.
 
Old 02-01-2013, 01:40 PM   #4
Nyro
Lurking
 
Nyro's Avatar
portfolio
A. D.
Vertex Slinger
Munich, Germany
 
Join Date: Dec 2006
Posts: 1,436
Could you please post the exact code you use in each example and cleary explain the result?

e.g.:

Code:
system("explorer D:"); // Result: Opened "C:\Users\User\My Documents"

or
Code:
system("explorer D:/myFolder"); // Result: Opened "D:\"
 
Old 02-01-2013, 01:43 PM   #5
Froyok
New Member
 
Froyok's Avatar
portfolio
Piquet Fabrice
Student
Belgium
 
Join Date: Apr 2010
Posts: 8
Send a message via MSN to Froyok
As I just edited in my post above : I wasn't using the double backward slash (-> \\ ) and that was the problem.
I don't know why I didn't think about sooner...
__________________
Dev-blog : http://www.froyok.fr/blog
 
Old 02-01-2013, 01:55 PM   #6
Nyro
Lurking
 
Nyro's Avatar
portfolio
A. D.
Vertex Slinger
Munich, Germany
 
Join Date: Dec 2006
Posts: 1,436
I thought so:

in Maya, always use forward slashes (/) to delimit folders in pathnames.

Make use of the following commands when dealing with system paths if you need a specific format:

toNativePath(string)
// Convert from '/' to '\\' path formats on Windows, otherwise does nothing. Use this proceedure to convert pathnames retrieved from Maya to more Windows-like backslash-separated pathnames (note that most Windows system calls do handle forward slashes as path-delimiters).

fromNativePath(string)
Convert from '/' to '\' path formats on Windows, otherwise does nothing. This procedure can be used to try to unify path data to use the forward slash character (a safer and more cross-platform way of handling paths, since the forward slash is what Maya uses internally to separate path names).
 
Old 02-01-2013, 02:09 PM   #7
Froyok
New Member
 
Froyok's Avatar
portfolio
Piquet Fabrice
Student
Belgium
 
Join Date: Apr 2010
Posts: 8
Send a message via MSN to Froyok
Quote:
Originally Posted by Nyro
in Maya, always use forward slashes (/) to delimit folders in pathnames.

My path was already using it, since it was a path that I get from a fileDialog2 command.

Quote:
Originally Posted by Nyro
toNativePath(string)
// Convert from '/' to '\\' path formats on Windows, otherwise does nothing. Use this proceedure to convert pathnames retrieved from Maya to more Windows-like backslash-separated pathnames (note that most Windows system calls do handle forward slashes as path-delimiters).

Thanks ! It's exactly what I was looking for !


Thanks for your help !
__________________
Dev-blog : http://www.froyok.fr/blog
 
Old 02-01-2013, 02:09 PM   #8
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:39 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.