Camera Lock Script?

Once I settle in on a camera angle, I like to lock my rendering camera down by locking the translation and rotation transforms. It's not a huge effort, I'd really love a script to have one-clock lock/unlock of transforms. Unfortunately, when I open up the scripting window, I'm completely lost. I don't know how to target the camera or how to switch between lock and unlocked modes for transforms. Has anybody written such a script? Or, if not, would it be easier to write than I think?

Comments

  • // Camera lock
    // (c) Richard haseltine, Jan 2017
    
    // get list of selected items
    var selectedNodes = Scene.getSelectedNodeList();
    var control;
    // go through list
    for ( var n = 0 ; n < selectedNodes.length ; n++ ) {
    	// is it a camera?
    	if ( selectedNodes[ n ].inherits( "DzCamera" ) ) {
    		// get and lock its transforms
    		control = selectedNodes[ n ].getXPosControl();
    		if ( control ) {
    			control.lock( true );
    		}
    		control = selectedNodes[ n ].getYPosControl();
    		if ( control ) {
    			control.lock( true );
    		}
    		control = selectedNodes[ n ].getZPosControl();
    		if ( control ) {
    			control.lock( true );
    		}
    		control = selectedNodes[ n ].getXRotControl();
    		if ( control ) {
    			control.lock( true );
    		}
    		control = selectedNodes[ n ].getYRotControl();
    		if ( control ) {
    			control.lock( true );
    		}
    		control = selectedNodes[ n ].getZRotControl();
    		if ( control ) {
    			control.lock( true );
    		}
    	}
    }

    change true to false throughout for an unlock script

  • Thanks Richard, that's excellent

  • mjc1016mjc1016 Posts: 15,001

    Here's a couple of icons for this...

    Rename them CameraLock.dsa.png/CameraUnlock.dsa.png (if that's what you named the scripts) and drop them along side the scripts.

    CameraLock.dsa.png
    91 x 91 - 10K
    CameraUnlock.dsa.png
    91 x 91 - 10K
Sign In or Register to comment.