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.

Is there an api way to access maya modeling toolkit component pre selection?

Is there an api way to access maya modeling toolkit component pre selection?

dragoavdalovic
Participant Participant
1,361 Views
7 Replies
Message 1 of 8

Is there an api way to access maya modeling toolkit component pre selection?

dragoavdalovic
Participant
Participant

When mouse hover the mesh face I would like it to get highlighted. Is there any way to acheive that with maya api?

I looked online but could not find anything useful.

Any help is highly appreciated.

Thanks, 

Drago

~Drago
0 Likes
1,362 Views
7 Replies
Replies (7)
Message 2 of 8

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

I think you can try to install QTEvent filters in the viewport panels to implement a hover event. After that you can try to use MGlobal::getHiliteList get a highlist in viewport and do intersect with the objects in the list.

 

Yours,

Li

0 Likes
Message 3 of 8

dragoavdalovic
Participant
Participant

Thanks Li for your reply!

I already installed eventFilter mouseMove and I am able to get face id when my mouse hovers it. That part is working. 

At the same time I am looking for the way to hilite that hovered face(NOT to select it). Idealy the behaviour would be the same as when you use modeling toolkit face component and move mouse over mesh(face). If you cursor is over the face than you see that face highlithed with red edges. I would like to be able to have a same behaviour if it is possible.

Working with MGlobal.getHiliteList andf MGlobal.setHiliteList seem not to work on component level. I was only able to get or set hilite for the whole mesh.

Any ideas?

Please see attached image.

Thanks,

Drago

 

 

~Drago
0 Likes
Message 4 of 8

cheng_xi_li
Autodesk Support
Autodesk Support

Hi drago,

 

I think you have to draw it yourself. Maya toolkit component uses OpenMaya and OpenMayaUI API to draw highlight, there isn't an interface related to this I am afraid.

 

Yours,

Li

0 Likes
Message 5 of 8

dragoavdalovic
Participant
Participant

Thanks Li for your help, could you point me to some examples? Would be highly appreciated! 🙂

Drago

~Drago
0 Likes
Message 6 of 8

dragoavdalovic
Participant
Participant

Hi Li;

I am having issues with viewport 2.0. The code below works in any legacy viewport but not in viewport 2.0. 

It is just a simple script that draws a red quad at the origin. Running in viewport 2.0 creates nothing. My maya version is 2015.

Any idea why is not working in viewport 2.0?

Thanks,

Drago

 

# ------------------------------------------------------

 

from maya import OpenMayaUI
import maya.OpenMayaRender as OpenMayaRender

 

view = OpenMayaUI.M3dView.active3dView()
glFT = OpenMayaRender.MHardwareRenderer.theRenderer().glFunctionTable()
view.beginXorDrawing(False, False, 2, OpenMayaUI.M3dView.kStippleNone, OpenMaya.MColor(1,1,1))
glFT.glBegin(OpenMayaRender.MGL_QUADS)
glFT.glColor3f(1.0, 0.0, 0.0)
glFT.glVertex3f(0,0,0)
glFT.glVertex3f(1,0,0)
glFT.glVertex3f(1,1,0)
glFT.glVertex3f(0,1,0)
glFT.glEnd()
glFT.glPopAttrib()
view.endXorDrawing()
glFT.glClear(OpenMayaRender.MGL_QUADS)

 

# ----------------------------------------------------

~Drago
0 Likes
Message 7 of 8

cheng_xi_li
Autodesk Support
Autodesk Support

Hi Drago,

 

You can attach a MPxSelectionContext with MPxManipContainer. 

 

When mouse is moving in the Viewport, you should be able to receive a draw event in the manipulator or you can try to call M3dView::active3dView().refresh() to enforce a draw. You can draw highlight in the event. 

 


Yours,

Li

0 Likes
Message 8 of 8

cheng_xi_li
Autodesk Support
Autodesk Support

Hi drago,

 

If you don't want to use the MPxManipContainer, you can also try with drawFeedBack in MPxContext.

 

There is a sample(grabUVMain.cpp) which use MPxContext::drawFeedback, although it is designed for uv editor(MPxTexContext). I think it could be a reference.

 

Yours,

Li

0 Likes