Script wanted: Set view to the last camera used

Many times I have my viewport with a certain camera (lets call it Cam01). Then I need to change the viewport to top, left, etc, and I always wish I could go back to the camera I was before, without having to select it first.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
lupaz's picture

I just wanted to thank you

I just wanted to thank you again. I'm using this every day and works really well.

lupaz's picture

It works very nicely. Thanks!

It works very nicely. Thanks!

jahman's picture

.

try this:

callbacks.removeScripts #viewportChange id:#LastCameraUsed
 
global LastCameraUsed = undefined
 
fn OnViewportChange = 
(
	local cam = getActiveCamera()
 
	if cam != undefined do LastCameraUsed = cam	
 
)
 
callbacks.addScript #viewportChange "OnViewportChange()" id:#LastCameraUsed
 
 
-- Customize > Jahman > 'Switch To Last Used Camera'
macroScript SwitchToLastUsedCamera
category:"Jahman"
tooltip:"Switch To Last Used Camera"
(	
	try
	(
		viewport.SetCamera ::LastCameraUsed
	)
	catch()	
)

if it works as expected, save this script in startup scripts folder
C:\Users\User\AppData\Local\Autodesk\3dsmax\<max_version>\ENU\scripts\startup

And bind it to any key combination you like.
Customize > Jahman > 'Switch To Last Used Camera'

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.