You could also just cast to a string using str() around your EpisodeName
but honestly the removal of back ticks makes more sense (in the future if
you ever find you can't remove the leading 'u' otherwise). Also since
you're already using the os module you should be using os.path.join instead
of the string concatenation you're currently doing to mitigate any possible
formatting issues around file paths.
On Monday, April 17, 2017 at 10:28:57 AM UTC-4, Robert White wrote:
>
> Try it without the backticks around cmds.textField.
>
>
> SBpath = 'G:\\ProjectPath\\'
> import maya.cmds as cmds
> import os, glob, time
>
> def buttonLGTPressed(*args):
> EpisodeName = cmds.textField("Episode", query = True, text = True)
> print EpisodeName
> rootEp = SBpath + "{}\\".format(EpisodeName)
> print(rootEp) # EXPECTED: G:\ProjectPath\*\241\ # RESULT:
> G:\ProjectPath\u'241'\
>
> window = cmds.window(title = "Open Last scene", width = 150, height = 100)
> cmds.rowColumnLayout( numberOfColumns=2, columnAttach=(1, 'left', 0),
> columnWidth=[(1, 100), (2, 250)] )
> cmds.textField( "Episode", text = "001")
> cmds.button('OpenLGT', l="Open Last LGT scene", w=180, h=30, command=
> buttonLGTPressed)
> cmds.showWindow()
>
>
> On Monday, April 17, 2017 at 8:29:59 AM UTC-5, gnn wrote:
>>
>> did someone know how to convert this result: u'001 in : 001
>> To put it in a variable path: Z:\ProjectPath\001\
>> By advance, thanks a lot for your help!!
>> <http://stackoverflow.com/questions/43449099/python-convert-u001-to-001-in>
>>
>> SBpath = 'G:\\ProjectPath\\'
>> import maya.cmds as cmds
>> import os, glob, time
>>
>> def buttonLGTPressed(*args):
>> EpisodeName = `cmds.textField("Episode", query = True, text = True)`
>> print EpisodeName
>> rootEp = SBpath + "{}\\".format(EpisodeName)
>> print(rootEp) # EXPECTED: G:\ProjectPath\*\241\ # RESULT:
>> G:\ProjectPath\u'241'\
>>
>> window = cmds.window(title = "Open Last scene", width = 150, height = 100
>> )
>> cmds.rowColumnLayout( numberOfColumns=2, columnAttach=(1, 'left', 0),
>> columnWidth=[(1, 100), (2, 250)] )
>> cmds.textField( "Episode", text = "001")
>> cmds.button('OpenLGT', l="Open Last LGT scene", w=180, h=30, command=
>> buttonLGTPressed)
>> cmds.showWindow()
>>
>>
>>
>>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/b1e35a95-65bf-432b-9ca8-49c604e39bbe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.