Dialog2 output

38 views
Skip to first unread message

MA07

unread,
Apr 18, 2017, 7:11:47 AM4/18/17
to Python Programming for Autodesk Maya
Hello,
Here is my code.


input
import maya.cmds as cmds

dirPath =cmds.fileDialog2()

filePath=str(dirPath)

print filePath



output
import maya.cmds as cmds

dirPath =cmds.fileDialog2()

filePath=str(dirPath)

print filePath
[u'C:/Users/Documents/pymel.log'] # can someone explain to me is this considered as string or list??? Is it possible to convert it to either way? is it using str().?

im not very sure how to convert the path from the dialog2

I would like to get something like this when the path is printed

C:/Users/Documents/pymel.log  rather than this  [u'C:/Users/Documents/pymel.log']

Thank you

Marcus Ottosson

unread,
Apr 18, 2017, 7:17:51 AM4/18/17
to python_in...@googlegroups.com

You’re seeing a list of paths, as the dialog could return multiple paths at once, if multiple paths were selected in the dialog.

If you only expect one, then it’d be safe to supply an index to the result.

print filePath[0]

MA07

unread,
Apr 18, 2017, 7:31:17 AM4/18/17
to Python Programming for Autodesk Maya
C:/Users/Documents/pymel.log  rather than this  [u'C:/Users/Documents/pymel.log']

why I received different result when is used cmds.fileDialog2(),[u'C:/Users/Documents/pymel.log']

but I got C:/Users/Documents/pymel.log when I used cd("C:/Users/Documents/pymel.log").

why I did not receive the same output ? one seems like list [ ] and another seems like string for me.. not sure.could you explain to me..?

thank you

Justin Israel

unread,
Apr 18, 2017, 5:04:47 PM4/18/17
to python_in...@googlegroups.com
On Tue, Apr 18, 2017 at 11:31 PM MA07 <amirahsya...@gmail.com> wrote:
C:/Users/Documents/pymel.log  rather than this  [u'C:/Users/Documents/pymel.log']

Where are you comparing these different return values?
 

why I received different result when is used cmds.fileDialog2(),[u'C:/Users/Documents/pymel.log']

but I got C:/Users/Documents/pymel.log when I used cd("C:/Users/Documents/pymel.log").

What is "cd()"?
 


why I did not receive the same output ? one seems like list [ ] and another seems like string for me.. not sure.could you explain to me..?

Yes one is a list and one is a string. Can you please be very specific about *when* you are encountering a string vs a list and why you expect them to be the same? When are you suggesting that you get a string when you expect a list, or the other way around?
 

thank you

On Tuesday, April 18, 2017 at 12:17:51 PM UTC+1, Marcus Ottosson wrote:

You’re seeing a list of paths, as the dialog could return multiple paths at once, if multiple paths were selected in the dialog.

If you only expect one, then it’d be safe to supply an index to the result.

print filePath[0]

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/f9bd8fd7-f8b0-4367-b00c-22860fd4b8e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

MA07

unread,
Apr 18, 2017, 7:18:32 PM4/18/17
to Python Programming for Autodesk Maya
I just realised It does not make sense.. Thank You,

I just thought the utility of cmds.fileDialog2 () and cd/ os.chdir() are kinda same.

sorry,guess I misunderstood the concept. thank you again.

Justin Israel

unread,
Apr 18, 2017, 9:05:00 PM4/18/17
to Python Programming for Autodesk Maya


On Wed, Apr 19, 2017, 11:18 AM MA07 <amirahsya...@gmail.com> wrote:
I just realised It does not make sense.. Thank You,

I just thought the utility of cmds.fileDialog2 () and cd/ os.chdir() are kinda same.

sorry,guess I misunderstood the concept. thank you again.

Oh I see. Yes os.chdir() expects a string directory path as an argument. The Maya fileDialog2() will return a list, since multi selection is possible. You need to handle that and pass just one string from the list.



On Tuesday, April 18, 2017 at 12:11:47 PM UTC+1, MA07 wrote:
Hello,
Here is my code.


input
import maya.cmds as cmds

dirPath =cmds.fileDialog2()

filePath=str(dirPath)

print filePath



output
import maya.cmds as cmds

dirPath =cmds.fileDialog2()

filePath=str(dirPath)

print filePath
[u'C:/Users/Documents/pymel.log'] # can someone explain to me is this considered as string or list??? Is it possible to convert it to either way? is it using str().?

im not very sure how to convert the path from the dialog2

I would like to get something like this when the path is printed

C:/Users/Documents/pymel.log  rather than this  [u'C:/Users/Documents/pymel.log']

Thank you

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages