Created
August 26, 2016 07:33
-
-
Save oglops/03800388f2ece8f8e8efffd3ad43b1e7 to your computer and use it in GitHub Desktop.
embed graph editor test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.cmds as cmds | |
import maya.utils as mutils | |
import maya.OpenMayaUI as apiUI | |
from PyQt4 import QtGui, QtCore | |
import sip | |
from PyQt4.QtCore import * | |
from PyQt4.QtGui import * | |
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) | |
def AEaddGraphEditorModule( plug, uiLabel, annot): | |
paneLayoutName = cmds.paneLayout(h=300) | |
print 'my pane:',paneLayoutName | |
graphEditorPanel = "customGraphEditor" | |
graphEditorPanelWindow = '%sWindow' % graphEditorPanel | |
graphEditorGraphEd = '%sGraphEd' % graphEditorPanel | |
if graphEditorPanel not in cmds.getPanel(scriptType='graphEditor'): | |
cmds.scriptedPanel(graphEditorPanel,l ='custom graph editor',type="graphEditor" ,to=1) | |
# cmds.scriptedPanel( graphEditorPanel, e=True, parent=paneLayoutName) | |
if cmds.window(graphEditorPanelWindow,q=1,ex=1): | |
cmds.deleteUI(graphEditorPanelWindow) | |
mutils.executeDeferred( | |
lambda g=graphEditorPanel,p=paneLayoutName,*x: cmds.scriptedPanel( g, e=True, parent=p)) | |
# configure newly created graph editor | |
# cmds. | |
def configure_ui(graphEditorPanel): | |
qtObj=toQtObject(graphEditorPanel) | |
print 'qtobj:',qtObj | |
m=qtObj.findChild(QtGui.QMenuBar) | |
print 'qtobj:',m | |
m.hide() | |
# mutils.executeDeferred(lambda g=graphEditorPanel,*x: configure_ui(g)) | |
cmds.evalDeferred(lambda g=graphEditorPanel,*x: configure_ui(g)) | |
cmds.setParent(u=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='UTF-8'?> | |
<templates> | |
<template name="AEtransform"> | |
<attribute name="frameExtension" type="maya.long"> | |
<label>Frame Extension</label> | |
</attribute> | |
<attribute name="enumAttr" type="maya.enum"> | |
<label>Enum Attr</label> | |
</attribute> | |
<attribute name="imageName" type="maya.string"> | |
<label>Image Name</label> | |
</attribute> | |
<attribute name="dummy" type="maya.float"> | |
<label>Anything you want</label> | |
<description language="cb">py.AEaddGraphEditor.AEaddGraphEditorModule</description> | |
</attribute> | |
</template> | |
<view name="Custom" template="AEtransform"> | |
<group name="common_properties"> | |
<property name="frameExtension"/> | |
<property name="enumAttr"/> | |
<property name="imageName"/> | |
</group> | |
<group name="my_curve_editor"> | |
<property name="dummy"/> | |
</group> | |
</view> | |
</templates> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment