1 import maya.api.OpenMaya
as om
2 import maya.api.OpenMayaAnim
as oma
3 import maya.api.OpenMayaUI
as omu
4 import maya.api.OpenMayaRender
as omr
6 import maya.cmds
as cmds
18 cmds.file(force=1,new=1)
19 myCyl = cmds.polyCylinder()
20 cmds.setAttr(
"pCylinder1.s",1, 3.3522764559816802, 1, type=
"double3" )
22 cmds.playbackOptions(min=0, ast=0, max=30, aet=30)
24 cmds.setAttr(
'pCylinder1.tz', 12 )
25 cmds.setAttr(
'pCylinder1.rx', 30 )
26 cmds.setKeyframe( [
'pCylinder1.tz',
'pCylinder1.rx'])
29 cmds.setAttr(
'pCylinder1.tz', 0 )
30 cmds.setAttr(
'pCylinder1.rx', 0 )
31 cmds.setKeyframe( [
'pCylinder1.tz',
'pCylinder1.rx'])
34 cmds.setAttr(
'pCylinder1.tz', -12 )
35 cmds.setAttr(
'pCylinder1.rx', -30 )
36 cmds.setKeyframe( [
'pCylinder1.tz',
'pCylinder1.rx'])
38 def createGraphEditor():
41 geName =
'myGraphEditorGraphEd';
42 if( cmds.scriptedPanel(
'myGraphEditor', exists=1) ):
43 cmds.deleteUI(
'myGraphEditor')
45 geWindow = cmds.window(width=1200,height=800)
46 gePane = cmds.paneLayout(parent=geWindow)
47 cmds.scriptedPanel(
'myGraphEditor',type=
'graphEditor', parent=gePane,tearOff=
False)
49 cmds.showWindow(geWindow)
50 return [geName, geWindow]
55 def initializePlugin( mobject ):
58 this method is called when the plug-in is loaded into Maya. It
59 registers all of the services that this plug-in provides with
63 mobject - a handle to the plug-in object (use MFnPlugin to access it)
66 [geName, geWindow] = createGraphEditor()
67 geCanvasInfo = omu.MPanelCanvasInfo(geName)
69 myCanvasInfo = [geCanvasInfo, geName, geWindow]
73 viewportSize = geCanvasInfo.getViewportSize()
79 viewportBounds = geCanvasInfo.getViewportBounds()
80 print(
'viewportBounds')
85 viewportBounds[0] = viewportBounds[0]*0.9
86 viewportBounds[1] = viewportBounds[1]*0.9
87 viewportBounds[2] = viewportBounds[2]*0.9
88 viewportBounds[3] = viewportBounds[3]*0.9
90 geCanvasInfo.setViewportBounds( viewportBounds )
91 newViewportBounds = geCanvasInfo.getViewportBounds()
93 if( geCanvasInfo.supportsUIDrawing() ):
94 print(
'Editor supports UI Drawing')
96 defaultCanvasInfo = omu.MPanelCanvasInfo(
'graphEditor1GraphEd')
98 if( defaultCanvasInfo.supportsUIDrawing() ):
99 print(
'Default Graph Editor is ready for drawing')
101 print(
'Default Graph Editor is not opened')
103 print(
'newViewportBounds')
104 print(newViewportBounds)
107 def uninitializePlugin( mobject ):
110 this method is called when the plug-in is unloaded from Maya. It
111 deregisters all of the services that it was providing.
114 mobject - a handle to the plug-in object (use MFnPlugin to access it)
117 [geCanvas, geName, geWindow] = myCanvasInfo
118 if cmds.window(geWindow, exists=
True):
119 cmds.deleteUI(geWindow)