Python API - Draw text with opengl into the viewport

1,150 views
Skip to first unread message

andrearastelli

unread,
Aug 1, 2011, 8:41:32 AM8/1/11
to python_inside_maya
Hi everyone,
I need some help with python api.

how this guy can write text into the viewport?
Where i can find some help (or a bounch of code?)

http://vimeo.com/24052855

damon shelton

unread,
Aug 1, 2011, 12:24:02 PM8/1/11
to python_in...@googlegroups.com
that is just using an expression to set the text of an annotation node - no python/python API needed

select an object and choose create>annotation...
your expression should get the value you want to display and then write out the text attribute of the annotation node(don't forget to use the -type "string" on the setAttr call)


damon shelton

unread,
Aug 1, 2011, 12:59:32 PM8/1/11
to python_in...@googlegroups.com
sorry, misinterpreted what was going on in the video.
he is using OpenGL to draw the text in his custom plugin.
Look into the M3DView documentation in the API docs. you have to do the conversion form C++ to python coding.
and i am sure if you dig through some of the sample scripted plugins in the devkit in your maya install you will find some examples.

http://forums.cgsociety.org/archive/index.php/t-136112.html
here is a link to a simple example of getting some data drawing to the viewport, the given code is only the draw part of a custom plugin node.

but if all you need is a simple text display for an object i would suggest using the annotation node route.
Reply all
Reply to author
Forward
0 new messages