Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

I want to display text on the model panel without using mel's headsUpDisplay.

I want to display text on the model panel without using mel's headsUpDisplay.

kohaku_nekotarou
Contributor Contributor
873 Views
5 Replies
Message 1 of 6

I want to display text on the model panel without using mel's headsUpDisplay.

kohaku_nekotarou
Contributor
Contributor
try:
    from PySide6.QtWidgets import QLabel, QWidget
    from shiboken6 import wrapInstance
except:
    from PySide2.QtWidgets import QLabel, QWidget
    from shiboken2 import wrapInstance
from maya import OpenMayaUI
ptr = OpenMayaUI.M3dView.active3dView().widget()
view = wrapInstance(int(ptr), QWidget)
label = QLabel("TEST")
label.setParent(view)
label.show()

Text does not update properly. (Press and release the space key to update)
Is there any good way to update the text? Or another way?

 

Resolved.
I forgot the show.

0 Likes
874 Views
5 Replies
Replies (5)
Message 2 of 6

kohaku_nekotarou
Contributor
Contributor

I see in the SDK py2PanelCanvas.py that it draws text and shapes on the graph editor panel, but is it only the graph editor that can do this? Can't you do something similar with the Model panel?

I am passing a name in geCanvas = omui.MPanelCanvas(geName), how do I get this name?

The above name in the basic graph editor is graphEditor1GraphEd (see py2PanelCanvasInfo.py)
Is there a list of these names somewhere?

0 Likes
Message 3 of 6

kohaku_nekotarou
Contributor
Contributor
from maya import OpenMaya
from maya import OpenMayaUI
def kohaku_preRenderCB(panelName, data):
    view = OpenMayaUI.M3dView()
    OpenMayaUI.M3dView.getM3dViewFromModelPanel(panelName, view)
    view.drawText("Test", OpenMaya.MPoint(0, 0, 0))
mPreRenderId = OpenMayaUI.MUiMessage.add3dViewPostRenderMsgCallback("modelPanel4", kohaku_preRenderCB)
view = OpenMayaUI.M3dView.active3dView()
view.refresh(True, True)
if mPreRenderId:
    OpenMaya.MMessage.removeCallback(mPreRenderId)

The above draws the text but does not display well, Is this method not available for ViewPort2?

0 Likes
Message 4 of 6

ZachGray
Enthusiast
Enthusiast

This plugin example will let you use uiDrawables on the viewport. The example has every type of drawable. You can strip out everything you don't need.


Message 5 of 6

kohaku_nekotarou
Contributor
Contributor
I am unfamiliar with Api and will study it.
I don't want to add nodes if possible, but is it possible to draw text on the View without adding nodes in the reference code?
0 Likes
Message 6 of 6

kohaku_nekotarou
Contributor
Contributor

At any rate, I was able to display the text in the view.

https://qiita.com/kohakunekotarou/items/10167432241e77eb7c21