Skip to content

Instantly share code, notes, and snippets.

@sonictk
Created May 25, 2017 06:58
Show Gist options
  • Save sonictk/d92631a2f5aab49aa3859e41e675a487 to your computer and use it in GitHub Desktop.
Save sonictk/d92631a2f5aab49aa3859e41e675a487 to your computer and use it in GitHub Desktop.
Draw text in the Maya VP1 viewport
import maya.OpenMaya as om
import maya.OpenMayaUI as OpenMayaUI
def drawText(*args):
view = OpenMayaUI.M3dView.active3dView()
view.beginGL()
view.drawText('test text 2', om.MPoint(5, 5, 0.0, 1.0))
view.endGL()
panel = cmds.getPanel(withFocus=True)
callBack = OpenMayaUI.MUiMessage.add3dViewPostRenderMsgCallback(panel, drawText)
view = OpenMayaUI.M3dView.active3dView()
view.refresh(True, True)
# Remove
OpenMayaUI.MUiMessage.removeCallback(callBack)
view = OpenMayaUI.M3dView.active3dView()
view.refresh(True, True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment