Maya Charm - Maya PyCharm connection

maya
python

#41

Hi passerby,

Is the hostname required? I’m using only a set port but no hostname and things are working fine, but just wondering if you assume there is a hostname in code for a specific feature.

Also, is there a way to add a “Clear all” button to the Maya Log window? I’m still new to PyCharm so I’m not sure if there’s already a way to do this. Thanks!


#42

[QUOTE=solarnoise;28644]Hi passerby,

Is the hostname required? I’m using only a set port but no hostname and things are working fine, but just wondering if you assume there is a hostname in code for a specific feature.

Also, is there a way to add a “Clear all” button to the Maya Log window? I’m still new to PyCharm so I’m not sure if there’s already a way to do this. Thanks![/QUOTE]

just use localhost for the hostname, i just provided that as a option since it does use a udp port so potentially you could use this accross a network.
There is a clear all in the Console, you just have to right click to access it.


#43

[QUOTE=passerby;28647]just use localhost for the hostname, i just provided that as a option since it does use a udp port so potentially you could use this accross a network.
There is a clear all in the Console, you just have to right click to access it.[/QUOTE]

Thanks! And yeah I’ve been using the right-click menu to clear the console, was wondering how difficult it would be to add a button to the side. Not a huge deal, I’ve just found that I miss having the Clear All button from the Maya script editor for usability since I tend to need to clear the log very frequently.


#44

ya i can look at making it a button next time i update it


#45

Just wondering what this plugin does exactly? – is this providing a way to debug in Maya from PyCharm CE the way it works in the full edition? or something else? The Github didn’t have a description – but I am interested in anything that might make PyCharm more useful.

EDIT: So finally pieced together the setup of the plugin. Its pretty slick – will likely save a lot of time… Thanks!


#46

[QUOTE=JasonB;28715]Just wondering what this plugin does exactly? – is this providing a way to debug in Maya from PyCharm CE the way it works in the full edition? or something else? The Github didn’t have a description – but I am interested in anything that might make PyCharm more useful.

EDIT: So finally pieced together the setup of the plugin. Its pretty slick – will likely save a lot of time… Thanks![/QUOTE]

More or less a faster way to execute code your writing in PyCharm, in Maya as if it was running in the script editor. Also it reads the output of the script editor into the IDE.

For testing scripts i find its most useful if you do something like.


if __name__ == "__main__":
    my_method()

at the end of your script.
just lets you run the script as is, and have it all work.

Once i have some time i want to learn more about the Intellij/PyCharm API and implement it as a run-configuration, also am hoping to intergrate the remote debugger in the pro version into it.


#47

[QUOTE=passerby;28720]More or less a faster way to execute code your writing in PyCharm, in Maya as if it was running in the script editor. Also it reads the output of the script editor into the IDE.

For testing scripts i find its most useful if you do something like.


if __name__ == "__main__":
    my_method()

at the end of your script.
just lets you run the script as is, and have it all work.

Once i have some time i want to learn more about the Intellij/PyCharm API and implement it as a run-configuration, also am hoping to intergrate the remote debugger in the pro version into it.[/QUOTE]

The pro version is great for debugging in Maya – but you need to launch from Maya still – this is nice for one offs – but, as you have mentioned, no debugger which is pretty awesome once you start relying on it. :).


#48

You sir, are my new personal hero of the day.

I had this functionality set up with pmip and the stuff from here: http://tech-artists.org/forum/showthread.php?1837-PyCharm-amp-Maya-commands
but not getting the console output back as well was something that has always been bothering me.


#49

[QUOTE=fleity;28752]You sir, are my new personal hero of the day.

I had this functionality set up with pmip and the stuff from here: http://tech-artists.org/forum/showthread.php?1837-PyCharm-amp-Maya-commands
but not getting the console output back as well was something that has always been bothering me.[/QUOTE]

Ya returning the console was a bit of a hack, but it works. If you are interested in how I made it work the source code for it is on my github page. Got it linked in the first post of this topic.

The pmip solution is interesting but I like my, since its native to pycharm and requires no extra tools or libraries.


#50

Been working on this plugin again over the last week, i have refactored and added enough that it might as well be a new product now. Added integration with the Remote Debugger of PyCharm Pro as well as just streamlining things more to make it act more like other features of PyCharm.

MayaCharm
MayaCharm Source

MayaCharm

Maya integration with run and debug configurations for Maya. MayaCharm lets you execute the current document or
arbitrary code as if it was in Maya from PyCharm. For users of the professional version of PyCharm it will also setup
and connect the pydev debugger to Maya as well.

Installation

It requires some minimal setup. The settings panel is in “Settings > Other Settings > MayaCharm” just define your port number
or leave the default and be sure to copy and paste the code it generates into Maya’s userSetup.py

Usage

If using Community Edition just setup the MayaCharm Runner run Configuration than it will work just like a normal python run configuration.
If using Professional Edition you can use the MayaCharm debugger instead which can be used as a runner or debugger.
There is also a Execute Selection and a Execute Documeant actions in the run menu, that can also be accessed via alt+s and alt+a


#51

tried again, in pycharm Maya Log which only can get maya trace back at first time run…
hope you can improve it

Suggestion :
change

add this following to maya userSetup.py
import maya.cmds as cmds
if not cmds.commandPort(’:1111’, q=True):
cmds.commandPort(n=’:1111’)

.
.
to
.
.

import maya.cmds as cmds
try : cmds.commandPort(n=‘127.0.0.1:1111’ , stp = ‘python’)
except : pass

since when user open second maya, userSetup.py will stop at line cmds.commandPort(n=’:1111’)
rest of userSetup.py lines will be not loaded
and
change hostname from “localhost” to “127.0.0.1” is better, search “localhost VS 127.0.0.1”, you can find reason
and set " stp = ‘python’ " to eliminate hidden dangers


#52

hmm wondering what is different about your setup that is causing these problems, also yeah the log is a little buggy im going to be looking at making that work via a socket soon instead of reading a log file and work on have it detect and link file and line numbers in errors. Also thanks for the suggestions i will add the exception handling to the userSetup when i get home


#53

I got MayaCharm Submitted to the official PyCharm and Intellij Plugin Repository now, so you can grab it from the Settings > Plugins > Browse Repos window now, for a easier way to download it and keep it update.

Also can rate it here
https://plugins.jetbrains.com/plugin/8218?pr=


#54

This is fantastic! Thanks so much for this!!


#55

Thanks a lot for MayaCharm! I have been using Wing for Maya debugging up until now. I got Maya Charm working on both OSX and Windows. The instructions are easy to follow and makes for an easy install.

A request for a feature:

In Wing you can use the Debug Probe to send code to Maya at the point of the breakpoint. Say that you want to refresh the viewport at the point of breakpoint. You enter

import pymel.core as pmc
pmc.refresh(force=True)


Would that be possible in PyCharm?


#56

its a little hidden but just hit that button and put it in code fragmeant mode

https://www.jetbrains.com/help/idea/2016.1/evaluating-expressions.html?origin=old_help


#57

thanks :slight_smile:

[QUOTE=passerby;29808]

its a little hidden but just hit that button and put it in code fragmeant mode

https://www.jetbrains.com/help/idea/2016.1/evaluating-expressions.html?origin=old_help[/QUOTE]


#58

I keep getting “Error running ‘MayaCharm’: Failed to find free socket port” when trying to debug. The Execute Document in Maya and Attach to log doesn’t provide any error, but do nothing.

I’ve run the following in Maya, and set the tool to use this port in settings and the remote debugger.:
import maya.cmds as cmds
if not cmds.commandPort(’:7720’, q=True):
cmds.commandPort(n=’:7720’)

print cmds.commandPort(’:7720’, q=True)

I’m using Windows, Pycharm Professional 2017.3 and Maya 2017, Update 3.

Edit: After some restarts the Console log and Send Document to Maya started working. Debugger still complains about not finding a free socket port though.


#59

Hi,

Thanks for the plugin, everything is working except the Maya Log.

For a script like:
print “return maya log”

The Maya Log does this:
maya log
a log

I’m new to the editor. So I don’t know if it’s because I haven’t configured a MayaCharm Debugger. I can create the Runner, but I don’t know how to create the Debugger.

I’m currently using PyCharm Community 2017.3 and Maya 2018 on a Mac OS High Sierra

Does anyone else have this issue?
K


#60

What could be the possible reason for not getting the MayaCharm debugger when you install despite the fact that you run the “Professional Edition” of PyCharm?