Play Minecraft in Maya! Just kidding. I’ve been playing Minecraft again lately and it inspired me to whip up a Maya script. It is a custom tool context using Maya Python API. With OpenMayaUI I grab the active view port using M3dView.active3dView(). I wrap the pointer to the active view port in a sip instance. With these two objects I can get the mouse pixel position with Qt and event filters, and then cast out a ray from that position into 3d space using M3dView .viewToWorld(). I use that ray in MFnMesh.closestIntersection() to get the point on the mesh and create a cube on the mesh surface. The result is an entirely scripted context that uses shift+click to place cubes on a mesh surface. There’s lots you can do with this if you edit the “create_block()” definition in my script to do whatever you want.
download the script here