Simple lock- / unlock camera

Hi

I really miss two simple buttons, one that lock the current view and one that unlocks the view.

I have found this to do the job:
setTransformLockFlags $ #all
setTransformLockFlags $ #none
but I have to selecet the camera and target manuel to lock the view, before running the script.

I guess that the script should select the active camera and it's target and lock them.

I know how to add a script to a toolbar, but not how to write it properly :-/

Can anyone help?

Thanks

Comments

Comment viewing options

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

Hello

Is it possible to add an indicator or glac to your scenario, which will show whether the camera is locked or not?
Thanks.

Jorgensen's picture

Thanks - works like a charm

Thanks - works like a charm :-)

miauu's picture

.

--	lock active camera and its target
(
	activeCam = getActiveCamera()
	setTransformLockFlags activeCam #all
	setTransformLockFlags activeCam.target #all
)
--	unlock active camera and its target
(
	activeCam = getActiveCamera()
	setTransformLockFlags activeCam #none
	setTransformLockFlags activeCam.target #none
)

The active viewport have to be the "camera" viewport.

ighost01's picture

Add ithe script as button in toolbars

Hello,

I am not a scripter and I don't know how to create scripts. I would like to know how I can add this script as buttons (lock and unlock) in the tool bar because I tried by dragging it to the toolbar which work, but once I restart 3ds max the lock and unlock buttons disappear and 3ds max shows me a runtime error ? :/

miauu's picture

.

Save this as ms file.

macroscript miauuLockCamera
category:"miauu"
tooltip:"Lock Camera"
buttonText:"Lock Camera"
(
	activeCam = getActiveCamera()
	setTransformLockFlags activeCam #all
	setTransformLockFlags activeCam.target #all
)
 
 
macroscript miauuUnlockCamera
category:"miauu"
tooltip:"Unlock Camera"
buttonText:"Unlock Camera"
(
	activeCam = getActiveCamera()
	setTransformLockFlags activeCam #none
	setTransformLockFlags activeCam.target #none
)

Drag and drop it onto your 3ds max viewports and the scripts will be insalled. Then you can find them in Customize-Customize User Interface-"miauu" category, and you can create toolbar buttons.

Comment viewing options

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