[Closed] Viewport drawing methods
Greetings. i wrote a small script that displays the object name, above the object in the viewport, its executed by a button i scripted in a masxscript utility. The problem is, every time the viewport is redrawn (ie, when i do anything!), i lose my text. How can i, or is it even possible, to have the text consistently redrawn, without having to press the button again?
This is the code im using at the moment:
fn drawtext =
(
for obj in $ do
(
objname = obj.name
objpos = obj.pos
gw.setTransform(Matrix3 1)
newpos = gw.htranspoint objpos
gw.hText newpos objname color:red
--update the viewport
gw.enlargeUpdateRect #whole
gw.updatescreen()
)
)
The script itself i’m doing just for fun, but it is handy to know which objects are which, without having to select them
Take a look at registerRedrawViewsCallback()
Also check out the Polygon counter shipping with max (select geometry object and press key 7 to display as overlay in the viewport – it uses the same technique)
This has been discussed before in here. Check this thread: http://forums.cgsociety.org/showthread.php?t=285095
Thanks.