View Full Version : Drawing a render region/rectangle to viewport

01 January 2008, 09:38 AM
Hi guys,

I ran into an issue I can't find an answer from the forums neither from the help file.
Is there a way to draw a custom render region via maxscript so that the visual feedback for the user looks the same or similar as the standard region rendering? You know..this resizable rectangle for defining a region to render before you hit the actual render button.

Imagine, that there is a rollout with a button named "Define region" and when you press the button it allows you to draw a custom rectangle over a view using a mouse.

So far i've found a command viewport.setRegionrect, but it doesn't give me visual feedback.
I think even drawing a simple rectangle over an active viewport would do what i want. Is there such way? Drawing a rectangle on to a viewport?
Maybe someone knows something..or some spot in the help file i could check out.

Thanks in advance!

01 January 2008, 10:00 AM
You would have to use the gw functions.

From the manual:

rect = (box2 13 47 96 97)
gw.wrect rect red
gw.wmarker [rect.left,,0] #point color:green
gw.wmarker [rect.left,rect.bottom,0] #point color:green
gw.wmarker [rect.right,,0] #point color:green
gw.wmarker [rect.right,rect.bottom,0] #point color:green
eRect = rect -- enlargeUpdateRect 1 pixel too small in either direction?
eRect.right += 1
eRect.bottom += 1
gw.enlargeUpdateRect eRect

You'll need to figure out the start and enpoint of the drag and draw with gw over the viewport.

I hope this gets you on your way.

01 January 2008, 10:25 AM
I still can't find this example from the help file though.
When I try to run it I get:
Unknown property: "wrect" in #Struct:gw

Should it work in Max 9?

01 January 2008, 10:42 AM
Ah, it's in 2008 included. It's AVG included in max2008, so that means in max9 you should run the AVG plugin form

But i don't know if rectangle is specificly what you're after.... I think you want to draw polylines... these are available in max9.


01 January 2008, 10:55 AM
Thanks, I'll look into it.

CGTalk Moderation
01 January 2008, 10:55 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.