Sublime Forum

Package installation for maya

#1

Hi all, I am having some issues in understanding on how the package should work and please do bear with me.
Anyway, I have chanced upon sublime text and it seems that they have maya commands (mel and python compatible) which is great!

So I have installed the mayaSublime from here https://github.com/justinfx/MayaSublime as well as this https://github.com/srusskih/SublimeJEDI
First thing first, I am on mac os x 10.7.5. After installing the said packages (I have not done any other things), I tried to run a simple python script that consists of two lines which are:

import maya.cmds as cmds cmds.camera()
However, I was prompted with ImportError: No module named maya.cmds if I try building it, or a popup window citing Failed to communicate with Maya etc… if I try pressing ctrl+Enter on my keyboard

So where and how am I doing it wrong?
Though in the sublimeJedi, there seems to be more info, the terms written are making me confused than ever :open_mouth:

Help?

0 Likes

#2

The way the MayaSublime package works is that it essentially sends commands over a network port to Maya. You do not use the build system. The general process is:

  1. Tell Maya to listen for commands. Inside the Maya Script Editor, run cmds.commandPort(name=":7002", sourceType="python")

  2. In Sublime, write your code in a Python file (or set your syntax to Python in a scratch file). Then, right-click and choose “Send to Maya” (or Ctrl+Numpad Enter). You can select lines if you want to only send a portion of the file to Maya.

Unfortunately it does not seem to display the output of any command. See the MayaSublime docs for more detail.

Or, are you interested in writing Maya plugins? Then the process is a little different, but I still wouldn’t bother with using a build system. Just save the python files in the “plug-ins” directory and Maya should pick it up.

0 Likes

#3

Hi sorry for the late reply.

I would say I am trying to do both, normal scripting plus some plugin writing, but I am prone to do the fomer than the latter.

So would this means to say I will need to have Maya open before so that it can be executed? Cause I am hoping that there isn’t a need to do so (else it is eating up my Mac memory)

0 Likes

#4

You do not need to have Maya open in order to use the scripting. It comes with a special version of Python that is configured to run Maya scripts. You can find it at Maya.app/Contents/bin/mayapy.

You’ll need to initialize the standalone environment by running this code:

import maya.standalone
maya.standalone.initialize()

It is possible to use your own version of Python 2.7, but I do not recommend trying.

All of this is described in the Scripting section of the Maya documentation. Since most of this is unrelated to Sublime, I recommend you try some of the Maya discussion groups if you have more questions. I have noticed a lot of Maya Python scripters use Sublime anyways, so you may have better luck with them.

0 Likes