一半君的总结纸

听话只听一半君

Monthly Archives: 十一月 2012

Master Miki Hoshii指点的Linux下编译Maya 2013 可用的 PyQt的步骤( CentOS 6.3 x64)

首先必须声明的是,我不是一个程序员,其实我是一个果粉,所以如果下面写错了的地方敬请指正。

阅读余下文章

Advertisements

Making Eclipse Soar

http://christianakesson.com

Here is a guide to set up and get Eclipse, PyMel, PyQt4 & Python to work together. When complete, you will have a sweet IDE setup, switch between running everything 32bit and 64bit native AND the ability to compile your own 64 and 32 bit native applications. I am writing this assuming Windows 7 64 bit. I would recommend sorting all the downloads into a 32 and a 64 folder to easier keep track of everything.

阅读余下文章

Using Eclipse as a Maya IDE

www.creativecrash.com

This is an updated tutorial – December 2011.

阅读余下文章

How can I have Wing send Python or mel code to Maya?

http://mayamel.tiddlyspot.com

Note: Wing can interact with Maya in three different ways. This is one of the three. See an overview here on the whole system: Interaction between Wing and Maya

阅读余下文章

Interaction between Wing and Maya

 http://mayamel.tiddlyspot.com

Wing has the ability to interact with Maya in four different ways. Each has it’s own setup, independent from another. For clarity, here they are listed below:

阅读余下文章

Remote Python debugging in Wing

Note: Wing can interact with Maya in three different ways. This is one of the three. See an overview here on the whole system: Interaction between Wing and Maya

阅读余下文章

Wing/Maya Remote Debug Setup

There are some great posts and pages explaining how to setup Wing IDE to remotely debug a Maya session. Eric Pavey first posted how to do this at his WarpCat Blog along with how to send commands back and forth to Maya from Wing.

阅读余下文章

yum rpm tips

yum 备忘录

# 在已安装的packages里找某个package,通常是想知道自己装了什么版本或是 装没装 或是想知道是不是yum装的
yum list installed | grep xxx

# 缺少某个文件,但是又不知道是哪个package里面的
yum whatprovides */xxx

# 从文件名得到此文件在哪个package里面
rpm -qf /path/to/file

# 显示已安装的某个package里面有哪些文件
rpm -ql package-name

# 显示某个package的所有能装的版本
<code class="bash plain">yum list package-name</code>

各处找来的常用python code snippet ( for maya )

各种print的用法

import maya.OpenMaya as om
om.MGlobal.displayInfo("my grey info message")
om.MGlobal.displayWarning("my pink warning")
om.MGlobal.displayError("my red error message")

# sys.stdout = sys.__stdout__
sys.stdout.write('script editor\n')
sys.__stdout__ .write('output window\n')
print 'xxx'

python_inside_maya

nathan网站大合集
Guide to PyQt/PySide in Maya (Pt. 1)
PyQt and Maya 2011

#Source code for some common Maya/PyQt functions we will be using
import os
import sip
from PyQt4 import QtGui, QtCore, uic
import maya.OpenMayaUI as apiUI
import maya.cmds as cmds

def getMayaWindow():
	"""
	Get the main Maya window as a QtGui.QMainWindow instance
	@return: QtGui.QMainWindow instance of the top level Maya windows
	"""
	ptr = apiUI.MQtUtil.mainWindow()
	if ptr is not None:
		return sip.wrapinstance(long(ptr), QtCore.QObject)

def toQtObject(mayaName):
	"""
	Convert a Maya ui path to a Qt object
	@param mayaName: Maya UI Path to convert (Ex: "scriptEditorPanel1Window|TearOffPane|scriptEditorPanel1|testButton" )
	@return: PyQt representation of that object
	"""
	ptr = apiUI.MQtUtil.findControl(mayaName)
	if ptr is None:
		ptr = apiUI.MQtUtil.findLayout(mayaName)
	if ptr is None:
		ptr = apiUI.MQtUtil.findMenuItem(mayaName)
	if ptr is not None:
		return sip.wrapinstance(long(ptr), QtCore.QObject)

#Get the absolute path to my ui file
uiFile = os.path.join(cmds.internalVar(upd=True), 'ui', 'demo.ui') # maya2011\prefs\ui\demo.ui
print 'Loading ui file:', os.path.normpath(uiFile)

#Load the ui file, and create my class
form_class, base_class = uic.loadUiType(uiFile)
class Window(base_class, form_class):
	def __init__(self, parent=getMayaWindow()):
		'''A custom window with a demo set of ui widgets'''
		#init our ui using the MayaWindow as parent
		super(base_class, self).__init__(parent)
		#uic adds a function to our class called setupUi, calling this creates all the widgets from the .ui file
		self.setupUi(self)
		self.setObjectName('myWindow')
		self.setWindowTitle("My Qt Demo Window")

def main():
	global myWindow
	myWindow = Window()
	myWindow.show()

Some PyQt for the day
Here’s a way to add popup tool tips to the 3d view ports in Maya (Based on inspiration from this post)

import sip
import maya.cmds as cmds
import maya.OpenMayaUI as apiUI
from PyQt4 import QtGui, QtCore

class ToolTipFilter(QtCore.QObject):
	'''A simple event filter to catch tooltip events'''
	def eventFilter(self, obj, event):
		if event.type() == QtCore.QEvent.ToolTip:
			QtGui.QToolTip.hideText() #Hide the old tooltip, so that it can move
			QtGui.QToolTip.showText(event.globalPos(), '%04f, %04f'%(event.globalX(), event.globalY()), obj)
			return False
		return True

#Install the event filter into all the model panels
global filter #Have to make the filter object global so it doesnt get garbage collected
filter = ToolTipFilter()

for editor in cmds.lsUI(panels=True): #For soem reason type='modelEditor' won't work...
	if cmds.objectTypeUI(editor)=='modelEditor':
		ptr = apiUI.MQtUtil.findControl(editor)
		viewWidget = sip.wrapinstance(long(ptr), QtCore.QObject)
		viewWidget.installEventFilter(filter)

Here’s some simple code to get the widget with focus, under the cursor, and the main Maya window:

import sip
import maya.cmds as cmds
import maya.OpenMayaUI as apiUI
from PyQt4 import QtGui, QtCore

def getMayaWindow():
	'Get the maya main window as a QMainWindow instance'
	ptr = apiUI.MQtUtil.mainWindow()
	return sip.wrapinstance(long(ptr), QtCore.QObject)

def getFocusWidget():
	'Get the currently focused widget'
	return QtGui.qApp.focusWidget()

def getWidgetAtMouse():
	'Get the widget under the mouse'
	currentPos = QtGui.QCursor().pos()
	widget = QtGui.qApp.widgetAt(currentPos)
	return widget

Here’s some handy debug code, this changes the tooltips for all the QWidgets in Maya to display their path, and QObject instance:

import sip
import maya.cmds as cmds
import maya.OpenMayaUI as apiUI
from PyQt4 import QtGui, QtCore

def toQtObject(mayaName):
	'''
    Given the name of a Maya UI element of any type, return the corresponding QWidget or QAction.
    If the object does not exist, returns None
    '''
	ptr = apiUI.MQtUtil.findControl(mayaName)
	if ptr is None:
		ptr = apiUI.MQtUtil.findLayout(mayaName)
		if ptr is None:
			ptr = apiUI.MQtUtil.findMenuItem(mayaName)
	if ptr is not None:
		return sip.wrapinstance(long(ptr), QtCore.QObject)

#Set the tooltip for all widgets (This takes a little bit)
for widget in cmds.lsUI(dumpWidgets=True):
	try:
		qWidget = toQtObject(widget)
		qWidget.setToolTip('(%s) %s'%(widget, qWidget))
	except:
		pass

Convert a wrapped pyqt object back to a Maya UI path:

import sip
import maya.cmds as cmds
import maya.OpenMayaUI as apiUI
from PyQt4 import QtGui, QtCore

def toQtObject(mayaName):
	'''
    Given the name of a Maya UI element of any type, return the corresponding QWidget or QAction.
    If the object does not exist, returns None
    '''
	ptr = apiUI.MQtUtil.findControl(mayaName)
	if ptr is None:
		ptr = apiUI.MQtUtil.findLayout(mayaName)
		if ptr is None:
			ptr = apiUI.MQtUtil.findMenuItem(mayaName)
	if ptr is not None:
		return sip.wrapinstance(long(ptr), QtCore.QObject)

#Set the tooltip for all widgets (This takes a little bit)
for widget in cmds.lsUI(dumpWidgets=True):
	try:
		qWidget = toQtObject(widget)
		qWidget.setToolTip('(%s) %s'%(widget, qWidget))
	except:
		pass

Maya 2011-2017的PyQt Windows Linux Mac OSX 国外大神编译版大合集

maya 版本号 和 python 版本号对应如下表所示

Maya Python Qt pymel Windows OSX Linux
2017 2.7.11 5.6.1 1.0.9 Visual Studio 2012 Update 4 Mavericks 10.9.5, Xcode 6.1.1 with SDK 10.9, clang with libc++ built on RHEL 6.5 with Red Hat Developer Toolset 2.1 which has a system default gcc 4.8.2 compiler. If additional C++11 features are required, use Red Hat’s Developer Toolset 2.1
2016 2.7.6 4.8.6 1.0.7 Visual Studio 2012 Update 4 Mavericks 10.9.5, Xcode 6.1.1 with SDK 10.9, clang with libstdc++ gcc 4.4.7
2015 2.7.3 4.8.5 1.0.6 Visual Studio 2012 Update 4 Mountain Lion 10.8.5, Xcode 5.0.2 with SDK 10.8 (Mountain Lion), clang with libstdc++ gcc 4.1.2
2014 2.7.3 4.8.2 1.0.5 Visual Studio 2010 SP1 Snow Leopard 10.6.8, Xcode 3.2.1, gcc 4.2.1 gcc 4.1.2
2013 2.6.4 4.7.1 1.0.4 Visual Studio 2010 SP1 Snow Leopard 10.6.8, Xcode 3.2.1, gcc 4.2.1 gcc 4.1.2
2012 2.6.4 4.7.1 1.0.3 Visual Studio 2008 SP1 Leopard 10.5.6+, Xcode 3.1.2 gcc 4.1.2
2011 2.6.4 4.5.3 1.0.0 Visual Studio 2008 SP1 Leopard 10.5.6+, Xcode 3.1.2 gcc 4.1.2
2010 2.6.1 VC8 with SP1 and Template Hot fix Mac OS X PPC|Intel: Xcode 2.4.1 gcc 4.1.2
2009 2.5.1 VC8 with SP1 and Template Hot fix Mac OS X PPC|Intel: Xcode 2.4.1 gcc 4.1.2
2008 2.5.1 VC8 with SP1 and Template Hot fix Mac OS X PPC|Intel: Xcode 2.4.1 gcc 4.1.2
8.5 2.4.3 Microsoft Visual Studio 2005 gcc 4.0.1(build 5341) or Xcode 2.3 (using the same gcc) gcc 4.0.2 on RHEL 4 WS U4

阅读余下文章