MEL Autocompletion for Sublime and MayaSublime

Justin Israel made an awesome extension for the Sublime Text editor called MayaSublime.
https://github.com/justinfx/MayaSublime

But I noticed there is no auto completion file for the MEL syntax so I decided to generate one.

This contains all MEL commands that I can find. Half of these are generated by the help of the Maya help command:
help -list “*”

The rest is generated by parsing all the MEL scripts and taking all “global procs” in the Maya installation scripts folder.

Hope this is of some help to people still having to manage legacy MEL scripts ^^.

I also added the script that I wrote to generate this which might be useful if you are working in a different version of Maya than this file is generated from. (Maya 2014)

Feel free use edit and or modify these files in any way you see fit.

The zip file contains the MEL.sublime-completions and the Python file used to generate this file.

SublimeAutoComplete  < CLICK HERE >

(links dont show up properly yet XD)

Copy the MEL.sublime-completions here:

C:\Users\<userName>\AppData\Roaming\Sublime Text 3\Packages\MayaSublime

If you want to generate this file do the following steps:

1) Copy the SublimeMelAutocompletion.py into your scripts folder.

2) C:\Users\<UserName>\Documents\maya\<Maya Version>\scripts

3) Load up maya.

4) open the script editor

5) type:

Flags:

mayaOnly = This will export only maya commands and scripts that are in the install folder ( C:\Program Files\Autodesk\<mayaVersion>\scripts)

Setting this to False will look in all possible scripts paths defined in the environment variable called: MAYA_SCRIPT_PATH

apiOnly = only generate the commands that are listed in the maya command reference.

filePath = The file path the document will be exported to. i.e. C:\MEL.sublime-completions

If you leave the filePath argument out of it then it will export to the default sublimeText3 mayaSublime folder if it exists:

C:\Users\<userName>\AppData\Roaming\Sublime Text 3\Packages\MayaSublime

It will try to detect your user name automatically.

 

 

14 thoughts on “MEL Autocompletion for Sublime and MayaSublime

  1. Thanks it works great !

    But now i’m trying to get auto completion for the command under python as
    maya.cmds or cmds.

    Because when i use python :
    import maya.cmds as cmds
    then start typing cmdx, I don’t get any completions.

    Do you have a way of creating autocompletion for maya python ?

    Thanks.

    • I assume you are using sublime for you python editing.
      If not then I think you are using maya’s script editor. (in the script editor goto Command -> command completion to turn on the autocompletion in maya)

      If you are using sublime. A few sanity checks.
      a) Are you working from a python file.
      b) check that in the bottom right of sublime the file type is set to python.

      If that’s all set try the following

      1) Make sure you have “Package Control” Installed
      https://sublime.wbond.net/installation
      2) Install a python auto completion package for sublime. (I’m quite fond of Jedi so far)
      (a: open package control Preferences->package control; b: type “install package” enter; C: type “jedi” enter)
      Wait a few seconds for the package to install.
      3) Add the maya python auto completion path to the Jedi settings
      (Preferences -> package settings -> jedi -> settings user (*Note do not use the default settings, these will be overwritten every time the package updates)
      and add the following lines : (change the maya path accordingly to your version)

      {
      // additional python package path list
      "python_package_paths": ["C:/Program Files/Autodesk/Maya2014/devkit/other/pymel/extras/completion/py"],
      }

      Just to be sure give the settings file a save and close and reopen sublime. (normally you should not have to do this but i can remember i had to give it a restart before it worked as i expected)

      Now open a python file in sublime.
      type
      import maya.cmds as cmds
      cmds.

      et voilla it should now give you a list of completions.
      If it does not try pressing (ctrl-spacebar ) that should force the options to come up.
      That should do the trick 🙂
      Let me know if it does not.

      (oh there is a chance that the first line “import maya.cmds as cmds” wont autocomplete yet. any import you do afterwards should work fine 🙂 )

      • Hi Jan,

        I’ve just tried following your steps above to get the auto complete working correctly for maya.cmds. But I’m still having problems.. In my jedi user settings I have this and this only but the only auto complete options I get are ‘cmds’, ‘as’, ‘maya’ and ‘import’. Any ideas would be much appreciated! Thanks in advance.

        {
        // additional python package path list
        “python_package_paths”: [“C:/Program Files/Autodesk/Maya2014/devkit/other/pymel/extras/completion/py”],
        }

        • Hi Rich,

          I just tried it myself. My guess is that you need to save the file. I notice i get the same result as you until I save the file.

          Let me know if that worked for you!

          Cheers,
          Jan

          • Hi jan,

            nope still no-auto complete for Maya Python commands unfortunately 🙁

            e.g.
            import maya.cmds as cmds
            cmds.g
            (gives me no dropdown box for ‘getAttr’, etc. Ctrl+Space opens the dropdown but with only the previously mentioned commands).

            I have Sublime Text 3 all options as they come straight out the box. Have installed MayaSublime, Package Control and Jedi.

            Whilst I am a Python novice I thought I’d have this up and running! Maybe worth trying Sub 2?

            Thanks for your help!
            Rich

          • Hi Rich,

            I’m afraid I have no idea what could be wrong on your machine. But there are a few things we can check :).
            I just did a fresh install on a new machine with Sublime3 setup all the packages. Gave sublime a restart created a python file saved it and it works however:
            A few things that come to mind.

            1) Did you check if your maya install path is the same as the example i provided / or perhaps you are using a different version of maya and you forgot to change the file path.
            2) Check the contents of that file path “C:/Program Files/Autodesk/Maya2014/devkit/other/pymel/extras/completion/py” Make sure there is a /maya and a /pymel folder in there.
            (i.e. if i put an invalid file path there and restart sublime i get the same result as you)
            3) if all that doesn’t work try the following as a check:
            make a python file. (save a file with a .py extension etc)
            at the top write the following code: Be sure to check if that file path exists on your system of course and change it where needed.

            import sys
            sys.path.append(r"C:\Program Files\Autodesk\Maya2014\devkit\other\pymel\extras\completion\py")
            import maya.cmds as cmds

            A: go to Tools -> Build (if a box pops up select python) (ctrl-b)
            B: you will see a small console window in the bottom of sublime pop up.
            C: Now type cmds.g and do ctrl-space see if that shows up your completions.
            D: If it does I have no idea what could be wrong haha. And id suggest to reinstall sublime.
            E: If it doesn’t. Then your file path is most likely incorrect.
            (Or a highly unlikely situation) You might have a folder called maya/cmds inside of your default python “site packages” folder. The chance of this happening is extremely small but maybe while playing around that happened. This would create a conflict with file paths.
            E1: The easiest way to check this is to run the following code:

            import sys
            sys.path.append(r"C:\Program Files\Autodesk\Maya2014\devkit\other\pymel\extras\completion\py")
            import maya.cmds as cmds
            print cmds

            This should print:

            module ‘maya.cmds’ from ‘C:\Program Files\Autodesk\Maya2014\devkit\other\pymel\extras\completion\py\maya\cmds\__init__.pyc’
            [Finished in 0.1s]”

            If it gives an error like:

            ImportError: No module named maya.cmds

            Then your path is incorrect / you might have some hidden maya/cmds folder somewhere.
            If it prints the same then the path is correct and I’m at a loss hahaha.

            4) If all else fails I’d suggest to make a backup of your sublime folder:
            C:\Users\\AppData\Roaming\Sublime Text 3
            Uninstall sublime,
            Delete that folder.
            And start from fresh. Hopefully that works.

            Lemme know if you found the problem 😀
            Cheers,
            Jan

  2. I have the exact same problem as in this thread, and am going slowly crazy trying to get it to work.

    I have the conflicting folder as you mentioned might be the case i.e.
    C:\Program Files\Autodesk\Maya2014\Python\Lib\site-packages\maya\cmds\__init__.py

    and I can see then one that it needs to be initializing here:
    C:\Program Files\Autodesk\Maya2014\devkit\other\pymel\extras\completion\py\maya\cmds\__init__.py

    so I deleted the offending first folder and contained files but it still refuses to see the the correct one, saying that there’s no such module.

    Any thoughts as to why it still wouldn’t see it?

    • Hi,

      Sorry for the miscommunication.
      That folder you are talking about
      C:\Program Files\Autodesk\Maya2014\Python\Lib\site-packages\maya\cmds\__init__.py
      is NOT a conflicting folder that one is supposed to be there haha.
      If you delete that Maya Python will no longer work correctly.

      I am talking about this path as python will search here by default:
      C:\Python27\Lib\site-packages

      So unless you defined an environment variable in your system or in sublime there is no reason it should find any conflicting files.

      I am afraid you will have to give me some more info.
      Did you try the step E1 from the other post ?

      import sys
      sys.path.append(r"C:\Program Files\Autodesk\Maya2014\devkit\other\pymel\extras\completion\py")
      import maya.cmds as cmds
      print cmds

      Run that in sublime and what does it print ?

  3. Yep, I discovered that soon after I posted (Python and Maya stopped working…). Thankfully, it was retrievable.

    So, when I run through steps in E1 i.e.:

    import sys
    sys.path.append(r”C:\Program Files\Autodesk\Maya2014\devkit\other\pymel\extras\completion\py”)
    import maya.cmds as cmds
    print cmds

    it prints the following:

    In the folder/file it’s meant to be pointing to all of the necessary completions are there in the file i.e.
    C:\Program Files\Autodesk\Maya2014\devkit\other\pymel\extras\completion\py\maya\cmds\__init__.py
    (there is no .pyc file though if there should be?)

    I’ve tried various combinations of setting the python_interpreter in the default, user and project settings but to no avail.

    Here’s my current user sublime_jedi.sublime-settings file:

    {
    “python_interpreter”: “C:/Program Files/Autodesk/Maya2014/bin/mayapy.exe”,
    // additional python package path list
    “python_package_paths”: [
    // My python package path

    // Maya’s python stubs
    “C:/Program Files/Autodesk/Maya2014/devkit/other/pymel/extras/completion/py”
    ]
    }

    and the default sublime_jedi.sublime-settings is unmodified as of install of Jedi.

    • Hi

      Can you send what it prints again but remove the bigger and smaller than characters as it will strip it out of the message.
      Wordpress limitation I guess XD
      No there is no need for the pyc files to be there. As they are created automatically upon import.
      I’d remove setting the python interpreter and let it use the default for starters. (it works fine here though)

      EUREKA!!!

      I think i might have found the issue.
      Wordpress changes the quotations to the wrong quotations in normal text. So double check you are using the right ones.

      Make sure you use these:

      {
      "python_interpreter": "C:/Program Files/Autodesk/Maya2014/bin/mayapy.exe",
      // additional python package path list
      "python_package_paths": ["C:/Program Files/Autodesk/Maya2014/devkit/other/pymel/extras/completion/py"]
      }

      If all that fails I am at a loss.

  4. Unfortunately my quotations are correct – it was just a paste into this form that messed it up:

    If I do:
    print sys.path

    I get this

    [‘D:\\Projects\\programming\\maya\\python’, ‘C:\\Program Files\\Autodesk\\Maya2014\\bin\\python27.zip’, ‘C:\\Program Files\\Autodesk\\Maya2014\\Python\\DLLs’, ‘C:\\Program Files\\Autodesk\\Maya2014\\Python\\lib’, ‘C:\\Program Files\\Autodesk\\Maya2014\\Python\\lib\\plat-win’, ‘C:\\Program Files\\Autodesk\\Maya2014\\Python\\lib\\lib-tk’, ‘C:\\Program Files\\Autodesk\\Maya2014\\bin’, ‘C:\\Program Files\\Autodesk\\Maya2014\\Python’, ‘C:\\Program Files\\Autodesk\\Maya2014\\Python\\lib\\site-packages’, ‘C:\\Program Files\\Autodesk\\Maya2014\\devkit\\other\\pymel\\extras\\completion\\py’]

    The final two paths both contain: maya\\cmds\\__init.py file in them, so a conflict.
    It seems like it’s just using the first one it comes to, rather than the one I want. If they both need to be there, then I’m confused as how it would work for anyone (but then I clearly don’t know enough about it as I can’t get t to work…).

    Maybe a separate install of Python27 might work, just seems unnecessary.

    Cheers for your help, I’m sure I’ll get it working eventually. At least the mel completions work fine for me…

  5. Hey,

    I am trying to add mel autocomplete to Sublime by copying

    MEL.sublime-completions to

    C:\Users\\AppData\Roaming\Sublime Text 3\Packages\MayaSublime

    but I can’t actually find the folder.

    Would there be anywhere else I can copy the file so that it gets picked up by Sublime?

    Thanks
    Paul

    • In case someone else faces the same problem:

      The MayaSublime folder needs to be created under:

      C:\Users\\AppData\Roaming\Sublime Text 3\Packages\

Leave a Reply

Your email address will not be published. Required fields are marked *