Notifications
Clear all

[Closed] how to create a custom 'reset viewport' script

Hello and thank you for your time. I have almost no experience writing max script and so I am bumping my head against something that seems like it should be easy. I would like to have a max script that automatically sets the viewport layout to a different one than the viewport.ResetAllViews() action. I am trying to create a 4 up layout that is like:
F | L
T | P
The trouble is, I can’t figure out how to get the script to choose the correct viewport. Ideally it would choose one, set it to the correct view, choose another set it to the correct view, etc… Instead it just works off the active viewport.

Thanks for reading and thanks in advance for any advice offered.

2 Replies

This should do it:

-- set layout to 4 viewports of same size
viewport.setLayout #layout_4

-- activate and set first viewport (top-left)
viewport.activeViewport = 1
viewport.setType #view_front

-- activate and set second viewport (top-right)
viewport.activeViewport = 2
viewport.setType #view_left

-- activate and set third viewport (bottom-left)
viewport.activeViewport = 3
viewport.setType #view_top

-- activate and set forth viewport (bottom-right)
viewport.activeViewport = 4
viewport.setType #view_persp_user

Check out the “Accessing Active Viewport Info, Type, and Transforms” topic in the online reference for more viewport specific methods.

Cheers,
Martijn

Magicm – Thanks very much for your help. This was exactly what I needed. I had used the page you mentioned, but still couldn’t figure out how to select viewport. Anyway, thanks very much!