2. 1. Compile to sip with PyQt5.
2. How to setting up When you using PyCharm.
3. WING IDE
Overview
3. List of Equipment.
PyQt5 build
Python 2.7.11
SIP 4.19.4
PyQt gpl 5.9.1
Install script as command script
Visual studio 2015 or 2017 as visual studio command prompt.
PyCharm IDE setup for Maya
MayaCharm
python connection of open port script
python connection of remote debug open port script
VSCode Setup for Maya
PTVSD 3.0.0
VSCode python extension
Overview
5. Install python version of 2.7.11
• https://www.python.org/downloads/release/python-2711/
1. Compile to sip with PyQt5.
6. Make Symbolic python.exe mayapy.exe
1. Compile to sip with PyQt5.
1. Run the command console as administrator.
2. Go to “C:Program FilesAutodeskMaya2018bin”
3. Command : mklink python.exe mayapy.exe
7. Install to Autodesk® Maya 2018 - Developer Kit
(aka devkit)
• https://apps.autodesk.com/MAYA/en/Detail/Index?id=552549163637
6351277&appLang=en&os=Win64&autostart=true
1. Compile to sip with PyQt5.
8. Install to Autodesk® Maya 2018 - Developer Kit
(aka devkit)
• List of Replacement directory
• All directory of devkitBase to MayaRoot
1. Compile to sip with PyQt5.
9. Install to Autodesk® Maya 2018 - Developer Kit
(aka devkit)
• C:Program FilesAutodeskMaya2018devkit
1. Compile to sip with PyQt5.
11. Your Maya environments path
https://knowledge.autodesk.com/support/maya/learn-
explore/caas/CloudHelp/cloudhelp/2016/ENU/Maya/files/GUID-228CCA33-4AFE-4380-8C3D-
18D23F7EAC72-htm.html
MAYA_LOCATION
C:Program FilesAutodeskMaya2018
1. Compile to sip with PyQt5.
12. Building to SIP
• Check to exist this bat file as vcvarsall.bat
1. Compile to sip with PyQt5.
13. Create setup.bat
1. Compile to sip with PyQt5.
@echo off
set MAYAVERSION=2018
set ADSKQTVERSION=5.6.1
set SIPVERSION=4.19.4
set PYQTVERSION=5.9.1
set MAYADRIVE=m:
set BUILDDRIVE=v:
if exist %MAYADRIVE%nul subst %MAYADRIVE% /d
subst %MAYADRIVE% "C:Program FilesAutodeskMaya%MAYAVERSION%"
set MAYA_LOCATION=%MAYADRIVE%
set MAYAPYQTBUILD=%~dp0
rem Removing trailing
set MAYAPYQTBUILD=%MAYAPYQTBUILD:~0,-1%
if exist %BUILDDRIVE%nul subst %BUILDDRIVE% /d
subst %BUILDDRIVE% "%MAYAPYQTBUILD%"
set SIPDIR=%BUILDDRIVE%sip-%SIPVERSION%
set PYQTDIR=%BUILDDRIVE%PyQt5_gpl-%PYQTVERSION%
rem set ADSKQTDIR=%BUILDDRIVE%qt-%ADSKQTVERSION%
set QTDIR=%MAYA_LOCATION%
set PATH=%QTDIR%bin;%PATH%
set MSVC_VERSION=2015
set MSVC_DIR=C:Program Files (x86)Microsoft Visual Studio 14.0
set QMAKESPEC=%QTDIR%mkspecswin32-msvc%MSVC_VERSION%
set _QMAKESPEC_=win32-msvc%MSVC_VERSION%
if ["%LIBPATH%"]==[""] call "%MSVC_DIR%VCvcvarsall" amd64
set INCLUDE=%INCLUDE%;%MAYA_LOCATION%includepython2.7
set LIB=%LIB%;%MAYA_LOCATION%lib
14. Building to SIP
• Download to sip-4.19.4
• https://sourceforge.net/projects/pyqt/files/sip/sip-4.19.4/
• Create new directory as name of __sdkext into your “D” drive.
D:__sdkext
Uncompress sip-4.19.4 into __sdkext foler.
1. Compile to sip with PyQt5.
15. Building to SIP
• Create sip.bat
1. Compile to sip with PyQt5.
@echo off
set XXX=%~dp0
if ["%MAYAPYQTBUILD%"]==[""] call
"%XXX%setup.bat"
pushd %SIPDIR%
rem "%MAYA_LOCATION%binmayapy" configure-
ng.py --spec %_QMAKESPEC_%
"%MAYA_LOCATION%binmayapy" configure.py
nmake
nmake install
popd
16. Building to SIP
• Install to Visual studio 2015 or 2017
• Run to visual studio command prompt as administrator mode.
1. Compile to sip with PyQt5.
17. Building to SIP
• Go to your __sdkext in command prompt.
1. Compile to sip with PyQt5.
18. Building to SIP
• Execute setup.bat in command prompt
• Execute sip.bat
1. Compile to sip with PyQt5.
• Checking to import sip in Maya2018
19. Building to PyQt5
• Download PyQt5 source code.
• https://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.9.1/
1. Compile to sip with PyQt5.
20. Building to PyQt5
• Create pyqt.bat
1. Compile to sip with PyQt5.
@echo off
set XXX=%~dp0
if ["%MAYAPYQTBUILD%"]==[""] call "%XXX%setup.bat"
set QMAKESPEC=%QTDIR%mkspecs%_QMAKESPEC_%
if not exist "%QMAKESPEC%qmake.conf" (
echo "You need to uncompress %MAYA_LOCATION%mkspecsqt-5.6.1_vc14-mkspecs.tar.gz !"
goto end
)
if not exist "%MAYA_LOCATION%includeQtQtCoreqdir.h" (
echo "You need to uncompress %MAYA_LOCATION%includeqt-5.6.1_vc14-include.tar.gz in %MAYA_LOCATION%includeQt !"
goto end
)
findstr /L /C:"Headers=include/Qt" "%MAYA_LOCATION%binqt.conf" >nul 2>&1
if ERRORLEVEL 1 (
echo "You need to edit %MAYA_LOCATION%binqt.conf to use 'Headers=include/Qt'"
goto end
)
findstr /L /C:"-lqtmain -lshell32" "%QTDIR%mkspecscommonmsvc-desktop.conf" >nul 2>&1
if ERRORLEVEL 1 (
echo "You need to edit %QTDIR%mkspecscommonmsvc-desktop.conf to use 'QMAKE_LIBS_QT_ENTRY = -lqtmain -lshell32'"
goto end
)
if not exist "%MAYA_LOCATION%includeQtqtnfc.disabled" (
echo "You need to rename %MAYA_LOCATION%includeQtqtnfc to %MAYA_LOCATIONincludeQtqtnfc.disabled"
goto end
)
pushd %PYQTDIR%
rem "%MAYA_LOCATION%binmayapy" configure-ng.py --spec %_QMAKESPEC_%
"%MAYA_LOCATION%binmayapy" configure.py --spec %QMAKESPEC% LIBDIR_QT="%QTDIR%lib" INCDIR_QT="%QTDIR%includeQt" MOC="%QTDIR%binmoc.exe" --
sip="%QTDIR%Pythonsip.exe" --sip-incdir="%QTDIR%Pythoninclude" -w --no-designer-plugin
nmake
nmake install
popd
:end
21. Building to PyQt5
• Must check item.
1. Compile to sip with PyQt5.
"You need to rename %MAYA_LOCATION%includeQtqtnfc to %MAYA_LOCATIONincludeQtqtnfc.disabled"
C:Program FilesAutodeskMaya2018includeQtqtnfc
Folder name to qtfnc.disabled
"You need to edit %QTDIR%mkspecscommonmsvc-desktop.conf to use 'QMAKE_LIBS_QT_ENTRY = -lqtmain -lshell32'"
22. Building to PyQt5
• Build to PyQt5 via visual studio command prompt.
• Asking to license about python then just type to “yes”.
1. Compile to sip with PyQt5.
23. Building to PyQt5
• Testing PyQt5 in Maya2018.
1. Compile to sip with PyQt5.
24. • Testing PyQt5 in Maya2018.
1. Compile to sip with PyQt5.
import sys
from PyQt5.QtWidgets import (QWidget, QToolTip, QPushButton)
from PyQt5.QtGui import QFont
class Example(QWidget):
def __init__(self):
super(Example,self).__init__()
self.initUI()
def initUI(self):
QToolTip.setFont(QFont('SansSerif', 10))
self.setToolTip('This is a <b>QWidget</b> widget')
btn = QPushButton('Button', self)
btn.setToolTip('This is a <b>QPushButton</b> widget')
btn.resize(btn.sizeHint())
btn.move(50, 50)
self.setGeometry(300, 300, 300, 200)
self.setWindowTitle('Tooltips')
self.show()
ex = Example()
26. Connecting to port
• import maya.cmds as cmds
• if not cmds.commandPort(':4434', q=True):
• cmds.commandPort(n=':4434')
2. How to setting up When you using pycharm.
27. Installing to MAYA CHARM.
Using Alt+F7 to open properties window then go to Plugins.
Go to Browse repositories.
Searching to MayaCharm then install.
2. How to setting up When you using pycharm.
28. Copy script then using into the Maya.
import maya.cmds as cmds
if not cmds.commandPort(':4434', q=True):
cmds.commandPort(n=':4434')
2. How to setting up When you using pycharm.
29. Select to interpreter from maya bin folder as python.exe
Already We make link via mklink command between python and mayapy
2. How to setting up When you using pycharm.
30. Additional setup your interpreter.
Go to More… then organizing to Interpreter path like below.
2. How to setting up When you using PyCharm.
31. MayaCharm Python Remote debugger setting.
Go to “Run” then open to “Edit Configurations…”
2. How to setting up When you using PyCharm.
32. MayaCharm Python Remote debugger setting.
Adding to new configuration of MayaCharm Debugger
2. How to setting up When you using PyCharm.
33. MayaCharm Python Remote debugger setting.
Execute Debug Maya2018 via Alt + F5
2. How to setting up When you using PyCharm.
37. 1. Click to lower left side small bug icon then enable to Accept debug connections.
2. Execute connection code via simple python code below.
3. WING IDE FOR MAYA.
import wingdbstub
reload(wingdbstub)
try:
wingdbstub.Ensure()
print 'Connected to WingIDE 6.0'
except ValueError:
print 'Could NOT connect to wingIDE'
38. Create server script into your %MAYA_SCRIPT_PATH%
mayaWingServer.py
3. WING IDE FOR MAYA.
import sys
import socket
import threading
import maya.utils as mu
import maya.OpenMaya as om
import executeWingCode
#Global variables
PORT = 6000 # Needs to be the same value as authored in wingHotkeys.py below.
SIZE = 1024
BACKLOG = 5
#Functions
def processDataInMaya(data):
try:
# If we don't evaluate in maya.util.executeInMainThreadWithResult(), Maya can crash, and that's no good.
mu.executeInMainThreadWithResult(executeWingCode.main, data)
except Exception, e:
om.MGlobal.displayError('Encountered exception: %s'%e)
def server(processFunc=processDataInMaya, port=PORT, backlog=BACKLOG, size=SIZE):
host = ''
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.bind((host,port))
except:
print 'Tried to open port %s, but failed: Its probably already openn'%port
return
s.listen(backlog)
print 'Starting Python server, listening on port %s...n'%port
while True:
client, address = s.accept() # client is a socket object
data = client.recv(size)
if data:
processFunc(data)
client.close()
def startServer():
threading.Thread(target=server).start()
39. Start python server via simple python script at below.
3. WING IDE FOR MAYA.
import maya.cmds as cmds
cmds.evalDeferred('import mayaWingServer; mayaWingServer.startServer()', lowestPriority=True)
40. Configuration of User hot key
3. WING IDE FOR MAYA.
Create wingHotkeys.py into ‘C:Users<your_username>AppDataRoamingWing IDE 6scripts‘
import wingapi
import socket
import os
import tempfile
def getWingText():
editor = wingapi.gApplication.GetActiveEditor()
if editor is None:
return
doc = editor.GetDocument()
start, end = editor.GetSelection()
txt = doc.GetCharRange(start, end)
return txt
def send_to_maya(language):
# The port the sever is listening on in mayaWingServer.py :
commandPort = 6000
if language != 'mel' and language != 'python':
raise ValueError('Expecting either 'mel' or 'python'')
txt = getWingText()
if language == 'mel':
if not txt.endswith(';'):
txt += ';'
# Cross-platform way to get a temp dir:
tempDir = tempfile.gettempdir()
tempFile = os.path.join(tempDir, 'wingData.txt')
f = open(tempFile, 'w')
f.write(txt)
f.close()
mSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # works in 2013...
# Now ping Maya over the command-port
try:
mSocket.connect(('localhost', commandPort)) # 2016, mac
# Send our code to Maya:
# It is intercepted via the function processDataInMaya(), created via mayaWingServer.py
mSocket.send(language)
except Exception, e:
print 'Send to Maya fail:', e
mSocket.close()
def python_to_maya():
send_to_maya('python')
def mel_to_maya():
send_to_maya('mel')
41. Configuration of User hot key
3. WING IDE FOR MAYA.
Create executeWingCode.py into %MAYA_SCRIPT_PATH%
import __main__
import os
import tempfile
import maya.OpenMaya as om
def main(codeType):
# Cross-platform way to get a temp dir:
tempDir = tempfile.gettempdir()
tempFile = os.path.join(tempDir, 'wingData.txt').replace('', '/')
if os.access(tempFile , os.F_OK):
# Print the lines from the file in Maya:
with open(tempFile, 'r') as f:
for line in f.readlines():
print line.rstrip()
print 'n',
if codeType == 'python':
# execute the file contents in Maya:
with open(tempFile , 'r') as f:
exec(f, __main__.__dict__, __main__.__dict__)
elif codeType == 'mel':
melCmd = 'source %s'%tempFile
om.MGlobal.executeCommand(melCmd, True, True)
else:
print 'No Wing-generated temp file exists: ' + tempFile
42. Configuration of User hot key
3. WING IDE FOR MAYA.
Go to Keyboard Personality -> Configure Tab Key…
Press to Insert then set up to Key with Command.
Command is ‘python_to_maya’
43. Configuration of User hot key
3. WING IDE FOR MAYA.
Go to Maya command line to type to code at below because When you receive from Wing-Ide that must open port local
host with port of 6000.
cmds.commandPort(name="127.0.0.1:6000", close=True, echoOutput=True)
cmds.commandPort(name="127.0.0.1:6000", close=True, echoOutput=True)
Closing port command at below
44. Configuration of User hot key
3. WING IDE FOR MAYA.
Execution test
import maya.cmds as cmds
cmds.polySphere(r=5)
45. Auto Complete.
3. WING IDE FOR MAYA.
Go to ‘Edit > Preferences > Source Analysis’
In the ‘Interface File Path‘, add the ‘pi‘ folder you find inside the pymel you just extracted. TO be
precise, it can be found in ’devkit/other/pymel/extras/completion/py’. For added measure, I added
both sub-folders inside the pi folder as well.