XM Magdalena 3D print, GGeorgy (3D)
LC #42 Pipers Alley

View Full Version : Creating a floating button inside the viewport

12-07-2010, 03:38 PM

I've seen somewhere someone who customized his own buttons inside a scene. They appear inside the viewport, and rendered orthogonal (2D image) always at the same place - aren't influence by the camera movements.

Is there a quick way to do that, maybe an already made script (everything goes, but preferably in pymel)?

12-07-2010, 04:16 PM
theres hudButton in mel, but its not very versatile, i'd love a better alternative myself

12-08-2010, 12:53 AM
I agree, but it will do.

12-10-2010, 09:53 PM
You can use geometry but there are some issues with triggering commands based on selection and the undo queue. If you want to go that route, I would suggest looking into zooHud and zooTriggers (Part of the zooToolbox)

If you are wanting actual GUI control parented to the viewport, mel only offers hudslider, hudbutton, and headsUpMessage.

You can also use PyQt and parent in your own custom widgets/layouts or whatever you want using something like this:

import maya.OpenMayaUI as apiUI
import sip

from PyQt4 import QtGui

view = apiUI.M3dView()
apiUI.M3dView.getM3dViewFromModelPanel('modelPanel4', view)
viewWidget = sip.wrapinstance(long(view.widget()), QtCore.QObject)

global myBtn
myBtn = QtGui.QPushButton(viewWidget)
myBtn.move(100, 100) #Relative to top-left corner of viewport

You can do anything a full qt widget can do with that, so it's extremely flexible. but it would require having PyQt installed, which can be a barrier depending on your tools distribution.

12-13-2010, 09:08 AM
Interesting. Thanks, I'll check it out.

CGTalk Moderation
12-13-2010, 09:08 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.