On Thu, Jun 27, 2019, 6:20 PM Vishal Kadam <vishalkadam...@gmail.com> wrote:

> I already have hotkeys and its working fine, Actually i'm trying to create
> a GUI for all my custom hotkeys to a single GUI using buttons, when I run
> the script manually it works fine but when I try to run it from a button
> its not working.
>
> from maya import cmds
> if(cmds.window('window1',q=1,ex=1)):cmds.deleteUI('window1')
> cmds.window('window1',t='test file',mb=1)
> cmds.columnlayout()
> cmds.button(c='testMEL()',l='test')
> cmds.columnlayout(p='window1')
> cmds.button(c='straightenUVs()',l='test2')
> cmds.showWindow('window1')
>
> def straightenUVs():
>     execfile("//usr/people/vishal/MB_straightenUVs_Tool.py")
>
> def testMEL():
>     mel.eval('source "/usr/people/vishal/test.mel"')
>

You are already in a python script. There is no need to use execfile as
long as the tool is in the Maya PYTHONPATH. The button command can accept a
python callable object.

import MB_straightenUVs_Tool

from maya import cmds
if(cmds.window('window1',q=1,ex=1)):cmds.deleteUI('window1')
cmds.window('window1',t='test file',mb=1)
cmds.columnlayout()
cmds.columnlayout(p='window1')
cmds.button(c=MB_straightenUVs_Tool.MB_straightenUVs, l='test2')
cmds.showWindow('window1')



>
>
>
>
> On Thursday, June 27, 2019 at 12:46:34 AM UTC+5:30, Justin Israel wrote:
>>
>>
>>
>> On Thu, Jun 27, 2019, 12:50 AM Vishal Kadam <vishalk...@gmail.com> wrote:
>>
>>> import MB_straightenUVs_Tool
>>> MB_straightenUVs_Tool.MB_straightenUVs()
>>>
>>> do I need to add the above two lines in python script, please guide me
>>> I'm very new to this scripting
>>>
>>
>> I'm not sure how you are trying to apply this. In that archive there is
>> already a complete python script. Those two lines that I pasted are taken
>> from the Mel script that launches the python script. You can paste those
>> two lines into the Script Editor or a python hotkey, etc. Can you please
>> explain where you are stuck?
>>
>>
>>> On Wednesday, June 26, 2019 at 1:16:08 AM UTC+5:30, Justin Israel wrote:
>>>>
>>>>
>>>>
>>>> On Tue, Jun 25, 2019, 11:13 PM Vishal Kadam <vishalk...@gmail.com>
>>>> wrote:
>>>>
>>>>> hi,
>>>>>
>>>>> Please find the attachment
>>>>> A script by Martin Baadsgaard
>>>>> <https://www.highend3d.com/users/martin-baadsgaard>
>>>>>
>>>>> can this script be written in a single python rather than calling from
>>>>> mel
>>>>>
>>>>
>>>> It is already written in Python. The Mel script is just for the
>>>> convenience of exposing it as a global proc in Mel, with a few lines. You
>>>> could completely ignore it and do this from python:
>>>>
>>>> import MB_straightenUVs_Tool
>>>> MB_straightenUVs_Tool.MB_straightenUVs()
>>>>
>>>> --
>>>>> 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_maya+unsubscr...@googlegroups.com.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/python_inside_maya/51351af2-4fd4-4383-9d8d-c5b5af28572b%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/python_inside_maya/51351af2-4fd4-4383-9d8d-c5b5af28572b%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>> --
>>> 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_maya+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/7a1d5821-8c04-43eb-90b9-99dab458161e%40googlegroups.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/7a1d5821-8c04-43eb-90b9-99dab458161e%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/e22c780e-a39e-4ae8-8f8e-8b07d001b73e%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/e22c780e-a39e-4ae8-8f8e-8b07d001b73e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0igtcKA9DNuPN1BxUWutpeEHAnOc8gg5H50ruW4_6RUQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to