ScriptSpot

Forum topic · Scripts Wanted

Simple lock- / unlock camera

By Jorgensen · 2013-11-14

Description

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 (5)

Hello

Igryl9l · 2020-04-16

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

Jorgensen · 2013-11-14

Thanks - works like a charm :-)

.

miauu · 2013-11-14


--	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.

Add ithe script as button in toolbars

ighost01 · 2020-04-29

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 · 2020-04-29

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.