Maya API - Console Output Callback

Recently I needed to retrieve Maya's console output (redirected from our engine) and get its string contents and redirect it to python's stdout.

After a little digging through the Maya API documentation I came up with a simple solution.
http://download.autodesk.com/us/maya/2011help/API/class_m_command_message.html


Setting up an event callback for every time Maya outputs something to it's console is fairly easy, as show below.


from maya import OpenMaya as om

tempmessage = ''
_createCallback()
# -- do something with tempmessage after the next output
_removeCallback(eventid)

def _messageCallback(message, messageType, data):
    tempmessage = message
    
def _createCallback():
    """configure the callback and tie it to our messageCallback func"""
    eventid = om.MCommandMessage.addCommandOutputCallback(_messageCallback, None)
    return eventid

def _removeCallback(eventid):
    """remove the callback associated with eventid"""
    om.MMessage.removeCallback(eventid)

I ended up saving the string (tempmessage) and parsed it as needed for my purposes.


Current Playing: Ty Segall

State of Affairs

I've been working within the very diverse discipline of technical art for most of my career and I've yet to post any of work to my public portfolio, so this is the (long over due) beginning of something I can look back on as I level up my skillset, in the years to come.

To kick things off, I've been working at Ready at Dawn Studios for just over 8 months now and am already able to see the progress we are making as a team since I came on board. The stability and quality of our internal tools have improved as the team has began to naturally distribute responsibility and allowed for our specific skills to dictate domain.

Specifically, I've gravitated toward writing Maya tools and custom internal tools that depend heavily on UI. While working at InContext, I was getting comfortable mostly writing tools that operated as cmd processes, or were handled by a CI build process (Jenkins.) It's been refreshing writing tools that demands design from a code perspective but also tool usability. RAD is a studio full of phenomenal content creators and there is no room for tools that inhibit their iteration.

Enough of my ramblings, here are a few things I'd like to overview regarding what I am looking to do with this blog:

- Implementation details on how I solved specific problems or tasks
- Project announcements and development notes (NDA dependent obviously)
- Career and life updates that hopefully give a little more flavor and diversity to the content posted.
- I'll also post a link to a single song from an artist that played during the post's development. Music has always had an enormous influence on my work and it's important to share that aspect with you! :)

Anyway, that's enough for now. As a closing note, go check out Deformers! We just announced this incredibly fun smash-em-up party game and I've had to solve some pretty interesting problems during it's development.


Currently Playing: The Ramones