PDA

View Full Version : can Render command do viewports?


soulburn3d
03-04-2009, 12:53 AM
The render command takes a camera parameter, so for example you can say...

render camera:$cam01

And that will render from the camera cam01's perspective. Is it possible to render from one of the viewports? something like

render camera:#view_top

- Neil

ZeBoxx2
03-04-2009, 03:07 AM
doesn't look like it... you'd have to either...
A. switch the active viewport to the viewport of interested, then call render without any camera parameter
B. create a camera to match the viewport of desire, then call render with that camera as its camera parameter, delete when done
C. ?? I had a thought there for a moment but it seems to have been rather ephemeral

soulburn3d
03-04-2009, 09:23 PM
A is close to what I'd like, but unfortunately, if you say switch a top view into a perspective view, it won't just grab the perspective view that may be elsewhere in your 4 viewports, it will make a new perspective view from the position of your top view. At least it does when using viewport.setType.

- Neil

soulburn3d
03-04-2009, 09:28 PM
Never mind, I can use the viewport.activeViewport to set the view to be the one that I want. Doesn't change the active view into a new view, it just changes which view is active, which probably isn't that annoying for the viewer. That's what I need. Thanks Ze!

- Neil

soulburn3d
03-04-2009, 09:30 PM
Shoot. That doesn't work if your have only a single view maximized. Back to the drawing board.

- Neil

ZeBoxx2
03-04-2009, 09:44 PM
this all sounds familiar somehow...

didn't we (not sure if it was you) conclude that you'd have to switch layouts, change view, switch back.. and that if none of the views was a/the 'Perspective' view, you'd be quite stuck?

Perhaps we should ask what you're trying to achieve? %)

soulburn3d
03-05-2009, 01:10 AM
Don't think we discussed this before. I'm now having trouble using the max tool maximize command, it seems that when you use it repeatedly, max gets confused. Try this if you may...

myindex = rendViewIndex
if myindex !=0 then
(
if viewport.numViews == 1 and myindex != 1 then
(
max tool maximize
oldview = viewport.activeViewport
viewport.activeViewport = myindex
max tool maximize
)
else viewport.activeViewport = myindex
render vfb:on
if viewport.numViews == 1 then
(
max tool maximize
)
)

Make a rectangular box in your scene. Then open the render dialog, and Lock the view to the perspective view. Then maximize the front viewport. If this code worked correctly, it should render the perspective view, and then return to 4 viewports. But it doesn't it stays at a single viewport, even though I call the maximize command 3 times. Is the same happening for you?

- Neil

ZeBoxx2
03-05-2009, 01:50 AM
(Hi Dubbie!)

Can't say that it does... have you tried putting messageboxes just after the maximize commands to see what the state is at that point, and see if something else might be resetting it afterwards?


myindex = rendViewIndex
if (myindex !=0) do (
if viewport.numViews == 1 and myindex != 1 then (
max tool maximize
messagebox "A"
oldview = viewport.activeViewport
viewport.activeViewport = myindex
max tool maximize
messagebox "B"
)
else ( viewport.activeViewport = myindex )
render vfb:on
if viewport.numViews == 1 then (
max tool maximize
messagebox "C"
)
)

soulburn3d
03-06-2009, 05:35 PM
That is really weird. So this code does what I expect it to, I start and end on the front viewport...

myindex = rendViewIndex
if (myindex !=0) do (
if viewport.numViews == 1 and myindex != 1 then (
max tool maximize
messagebox "A"
oldview = viewport.activeViewport
viewport.activeViewport = myindex
max tool maximize
messagebox "B"
)
else ( viewport.activeViewport = myindex )
render vfb:on
if viewport.numViews == 1 then (
messagebox "C"
max tool maximize
viewport.activeViewport = oldview
messagebox "D"
max tool maximize
)
)

But if I comment out the message boxes, then I start at the front view and end at the persp view.

myindex = rendViewIndex
if (myindex !=0) do (
if viewport.numViews == 1 and myindex != 1 then (
max tool maximize
--messagebox "A"
oldview = viewport.activeViewport
viewport.activeViewport = myindex
max tool maximize
--messagebox "B"
)
else ( viewport.activeViewport = myindex )
render vfb:on
if viewport.numViews == 1 then (
--messagebox "C"
max tool maximize
viewport.activeViewport = oldview
--messagebox "D"
max tool maximize
)
)

Could it be some sort of timing issue, where it maximizes too quickly and so max gets confused, but if you put some nice stops in there using a messagebox, it doesn't get confused. I tried sleeps instead of messageboxes and I still got the wrong results.

- Neil

ZeBoxx2
03-06-2009, 05:53 PM
could be.. I do have a pretty slow machine ;) - have you tried inserting a 'sleep 0.1' or so ?

soulburn3d
03-06-2009, 09:29 PM
Wow, so looks like it is a refresh problem of some sort. First off, if your render is something more complex than a box, it works fine without the message boxes. If you place sleeps of 0.1 (which I had already done), it still fails on a fast scene. But sleeps of 0.2 works. Looks like if the render isn't slowed down using a sleep or by it being a slow render, then max gets confused.

This looks like pretty nasty code, I hate stuff where I just hope it will work in many cases, rather than being assured it will work. But I may have to use it.

- Neil

losbellos
03-06-2009, 11:07 PM
try to put disableSceneRedraw() , might help and then switch

soulburn3d
03-07-2009, 01:45 AM
Thanks, but it didn't help any. Sounds like it should :)

Ok, I've simplified my script...

max tool maximize
viewport.activeViewport = 1
max tool maximize
viewport.activeViewport = 1
render vfb:on
max tool maximize
viewport.activeViewport = 1
max tool maximize
viewport.activeViewport = 1

Start with a scene with 4 views and a simple object, If you evaluate the script several times, sometimes it will return you to the 4 viewports, sometimes it'll return you to a single maximized viewport. Can someone try this say 20 times and see if it's just my computer? If someone else can confirm it I'll post it as a bug to adesk.

- Neil

ZeBoxx2
03-07-2009, 03:11 AM
confirmed - took a good couple of runs, but indeed it sometimes fails to get back to the state it was in before

maybe changing the viewport layout directly works better? (though I think it resets any custom viewport size adjustments)

SyncViewS
03-07-2009, 09:42 AM
Hi Neil,
I tried your latest script version and can confirm the unpredictable results on 3ds Max 9 x64. I also noticed an odd behaviour: the code runs well almost always if evaluated as is written, but fails always if enclosed in parenthesis, defined as a code block. For the same reason I guess it fails every time is evaluated from an external editor (PsPad in my case) through com.

- Enrico

soulburn3d
03-07-2009, 04:53 PM
Thanks Ze for confirming. And thanks for the extra info SyncViewS, I'll post this all to an official bug to autodesk.

- Neil

CGTalk Moderation
03-07-2009, 04:53 PM
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.