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.

Custom opengl drawing using MUIDrawManager

Custom opengl drawing using MUIDrawManager

Anonymous
Not applicable
1,527 Views
5 Replies
Message 1 of 6

Custom opengl drawing using MUIDrawManager

Anonymous
Not applicable

Hi 

I am currently learning the Maya Python API 2.0 and trying to do some custom OPENGL drawing in the viewport 2.0.

I went through the footPrintNode.py sample from the devkit and modified it to create some shapes in the viewport.

 

However that sample and most of the other programs in the devkit, create dependency node plugins using the maya.cmds.createNode() command.

This results in the creation of a node which can be seen in the outliner.

 

My objective is to do my opengl drawing without creating any nodes in Maya, for example, like the knife tool which draws opengl lines between the click points.

 

So, my question is -

Is it possible to do opengl drawing by using a command plugin? If so, how do I access the MUIDrawmanager class in a command plugin.

I have searched a lot but did not find any sample plugins or examples in this regard.

Any help will be highly appreciated.

 

0 Likes
1,528 Views
5 Replies
Replies (5)
Message 2 of 6

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

I am afraid that is not possible. Only dag objects and viewport overrides could draw in Maya viewport. 

 

Yours,

Li

Message 3 of 6

Anonymous
Not applicable

Hi Li

 

I see, thank you for the reply.

 

In such cases, what is the usual strategy for cleaning up DAG nodes after quitting the addon.

Do we need to delete them manually?

 

In case of the pyFootPrintNode example, I have to create a new file (ctrl + N) every time in order to properly unload the addon.

I tried using cmds.flushUndo() command, but it also did not delete the node.

 

 

cmds.flushUndo("footPrint")
cmds.unloadPlugin("pyFootPrintNode.py")
0 Likes
Message 4 of 6

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

I forgot to mention if you want to create a tool, you could draw in that tool.

 

There are several samples in the devkit uses MPxToolCommand. moveTool could be a good starting point.

 

Yours,

Li

0 Likes
Message 5 of 6

Anonymous
Not applicable

Hi

 

Please excuse my ignorance but is the MPxToolCommand available through the Python API?

I am using Maya 2016 but I also checked the documentation for Maya 2018.

I could only find the C++ documentation for it.

0 Likes
Message 6 of 6

cheng_xi_li
Autodesk Support
Autodesk Support

If you are using python, I think it is not there and I remembered I've logged an issue that there are some VP2 context overloads not available in Python right now.

 

Please use C++ instead for now.

 

Yours,

Li

0 Likes