Making_the_Script_Editor_spit_back_Python_code_instead_of_MEL

35 views
Skip to first unread message

Sahak Sahakian

unread,
Oct 21, 2011, 5:44:41 AM10/21/11
to python_in...@googlegroups.com
Hi guys.

How wold one go about making ScriptEditor spit back its history in Python?

cheers


Jan:

unread,
Oct 21, 2011, 8:00:00 AM10/21/11
to python_in...@googlegroups.com
For pymel you can use the tools provided with it.
Maya2012\Python\lib\site-packages\pymel\tools\scriptEditor

Put the pymelScrollFieldReporter into the plugins dir

Replace the original scriptEditorPanel.mel file inside:
Maya2012\scripts\startup
with the one from the pymel tools folder

you need to change a few lines though in the py file to make it work with maya 2011 and 2012:
add:
from pymel.tools.mel2py import melparse

change :
mparser = mel2py.MelParser()
to:
mparser = melparse.MelParser()

As for maya python itself there should be a simmilar way but i have not looked into it.
Note though that using the pymel script editor panel slows down your code quite a lot especially when printing.
and some features are disabled in the script editor!!!


2011/10/21 Sahak Sahakian <loves2...@gmail.com>
Hi guys.

How wold one go about making ScriptEditor spit back its history in Python?

cheers

Eric Nersesian

unread,
Oct 21, 2011, 10:22:45 AM10/21/11
to python_inside_maya
Hi Jan,

I followed your instructions but my script editor is still spitting
out MEL. I made sure that pymelScrollFieldReporter.py is both loaded
and auto loaded in Maya's Plug-in Manager but its still showing MEL.
When I start up Maya these warnings are shown in the Output Window:

WARNING: No t_error rule is defined
WARNING: Token 'COMMENT_BLOCK' defined, but not used
WARNING: Token 'COMMENT' defined, but not used
WARNING: There are 2 unused tokens
WARNING: no p_error() function is defined
WARNING: Symbol 'element_list' is unreachable

Also, let me walk you through what I did to see if I followed your
instructions correctly:

1. Copy Maya2012\Python\lib\site-packages\pymel\tools\scriptEditor
\pymelScrollFieldReporter.py to Maya2012\bin\plug-ins

2. Replace Maya2012\scripts\startup\scriptEditorPanel.mel with
Maya2012\Python\lib\site-packages\pymel\tools\scriptEditor
\scriptEditorPanel.mel

3. Within Maya2012\bin\plug-ins\pymelScrollFieldReporter.py:
add: from pymel.tools.mel2py import melparse
change: mparser = mel2py.MelParser() to mparser =
melparse.MelParser()

Thanks for any help you can provide,
Eric

On Oct 21, 8:00 am, "Jan: " <jan....@gmail.com> wrote:
> For pymel you can use the tools provided with it.
> Maya2012\Python\lib\site-packages\pymel\tools\scriptEditor
>
> Put the pymelScrollFieldReporter into the plugins dir
>
> Replace the original scriptEditorPanel.mel file inside:
> Maya2012\scripts\startup
> with the one from the pymel tools folder
>
> you need to change a few lines though in the py file to make it work with
> maya 2011 and 2012:
> add:
> from pymel.tools.mel2py import melparse
>
> change :
> mparser = mel2py.MelParser()
> to:
> mparser = melparse.MelParser()
>
> As for maya python itself there should be a simmilar way but i have not
> looked into it.
> Note though that using the pymel script editor panel slows down your code
> quite a lot especially when printing.
> and some features are disabled in the script editor!!!
>
> 2011/10/21 Sahak Sahakian <loves2anim...@gmail.com>

Jan:

unread,
Oct 21, 2011, 10:31:36 AM10/21/11
to python_in...@googlegroups.com
oh sorry forgot to mention one thing.
in the script editor goto:
History -> HistoryOutput -> Convert mel to Python.

That should do the trick.


2011/10/21 Eric Nersesian <eric.ne...@my3dti.com>

Eric Nersesian

unread,
Oct 21, 2011, 10:46:14 AM10/21/11
to python_inside_maya
Yup, that did it for me. Thanks for the help! This is an awesome way
to just do the full conversion to python mentally for me.

On Oct 21, 10:31 am, "Jan: " <jan....@gmail.com> wrote:
> oh sorry forgot to mention one thing.
> in the script editor goto:
> History -> HistoryOutput -> Convert mel to Python.
>
> That should do the trick.
>
> 2011/10/21 Eric Nersesian <eric.nerses...@my3dti.com>
Reply all
Reply to author
Forward
0 new messages