简体   繁体   中英

How to execute Maya python scripts in PyCharm

I'm writing some simple pipeline scripts for my company. I did lots of houdini work in pycham and it works as expected: When you work in houdini python interpreter it is like working in houdini without UI. BUT, with Maya I cant get anything working inside PyCharm, I have to execute everything in Maya using MayaCharm plug in. Completition works, imports work, but whatever I do, whatever function, methods, .. I call I'm always getting 'None' as results. Not errors, just 'None' as result. I tried solution from: How do I execute Maya script without lauching Maya? but it also don't work. Result of "my_cube = cmds.polyCube()" is "None". Even if I just call cmds.ls() I'm getting "None" Any help or ideas?

If you launching your script with mayapy, you might wanna initialize maya first: https://help.autodesk.com/cloudhelp/2016/CHS/Maya-Tech-Docs/PyMel/standalone.html

import maya.standalone
maya.standalone.initialize(name='python')
import maya.cmds as cmds

If you trying to launch something from PyCharm right in the live Maya session, then MayaCharm is they way to go I believe.

如果要在Maya中执行但使用Pycharm作为编辑器,则可能应该仅使用MayaCharm ,它是专门为此目的而设计的。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM