How to link Python Consoles from PyCharm to Maya 2018.4?

Hi TA.org,

Fairly new to scripting with an IDE, but loving Pycharm so far.

Is it possible to type (or link) into Pycharm’s python console and have that link input/output to Maya’s python console (similar to how I type into Maya’s script editor???)

I can execute code and I get the results and feedback from Maya back into Pycharm, which is great.

But the python console in Pycharm itself seems to only work with standard python? Is this normal? Can it be linked to Maya as well? (Hope this is clear, sorry bit of a newbie re: scripting IDE).

Much Thanks,
Dive

I got syntax highlighting and auto complete for pymel, python api, and cmds to work in Pycharm, as well as remote debugging thanks to a few posts on here. Python console linking is the last thing I’m trying to figure out between Pycharm <—> Maya

You can point the console at mayapy.exe but this will have no impact on a running instance of Maya.

I suppose you can probably rig up some kind of RPC / proxy system over commandPort to simulate interaction between the console and a running Maya instance, but I don’t know if any such system exists.

1 Like

I believe I did point it, I’ll check that, thanks R.White.

Commandport seems a bit over my head for now, maybe I’ll try it later on.

Yeah it’s a nice to have to be able to interact with maya console from PyCharm’s internal python console.

I can easily just use the script editor in Maya for my needs. Got everything else working in PyCharm though, so happy about that! (remote debugging/api autocompletion/all the benefits of an IDE vs notepad lol)

Hello dive!

There is a PyCharm Plugin called MayaCharm. You can easily install it in PyCharm via “Settings -> Plugins”. Once you got a hang of it, it is more or less what you want. :slight_smile:

1 Like

Hey Fasbue!
Yeah I have MayaCharm,
What I was asking for was live console linking from PyCharm, where the output can effect things in Maya. I do have maya completion in the console, and even cmds imports via the live console. Things don’t really happen in Maya though if I say

cmds.select(‘pCube1’) # from the live python console, this works from a regular python script however

I don’t think its possible, but its not too big of a deal. Pycharm provides so many other tools and connections, I was just curious.

Hi dive!

Sorry, I just missunderstood your problem. The Python console in PyCharm is basically its own little instance of python and does not have a connection to Maya. You can however setup Mayapy (found right beside the regular Maya.exe) as PyCharms Console. Once you have set everything up you can think of Mayapy as a Maya instance without any GUI and all you have to control it is the script editor. You have to modify the startup script for the Python Console a bit ( File | Settings | Build, Execution, Deployment | Console | Python Console ) to load maya.standalone but then you are good to go (I dont have the exact code in mind but I highly recommend Chad Vernon s Blog post about Unittesting Maya . You should find everything you need there.).
So this all does not connect the Python console to the Maya script editor, BUT I can tell you that as a developer 80% of the time you do not need that GUI feedback in Maya. Build your scripts, run them against Mayapy and only switch back to the GUI once you have all the main goals achieved. The main advantage of Mayapy is its speed. It boots up in 10 sec at our facility where the regular Maya takes almost 5 min. The RAM footprint is also significantly lower (we had times were scenes took 90% less RAM). My point is: Once you have set it up, it opens up huge possibilities for automation and testing to a point where the loop back to the regular Maya is almost redundant IMHO. :slight_smile:

Hope that helps a little bit,
Fabian

1 Like

You can look through the source code for the sublime maya plugin to see if that helps:
https://packagecontrol.io/packages/MayaSublime

1 Like

Or: http://www.emeraldartist.com/remotely-execute-code-in-maya-using-pycharm/

1 Like