Lock/Unlock Node pose quickchange?

LoonyLoony Posts: 1,817
edited September 2020 in New Users

Hi,

is there a way to make a shrotcut for lock/unlock Node pose?

That is something I use really much, so I don't have to switch the panels, like I can't select that when I am in the surface tab, I have to be in the parameters or pose tab, I can not do that for a Camera even in the camera tab.

In F3:

I can only add hotkeys to the left side (1), but the menue entrys are on the right side (2), on the left side is under pose no lock/unlock.

I have already a script (thanks richard <3 for sharing the info about the script!; did try to find the thread but cant find it in my disscussions maybe someone other made it) to toggle nodes visiblity with V, so can I rewrite that script maybe to do the same with locking/unlocking node pose?

Node visible toggle:

http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/nodes/node_visibility_toggle/start

Should it not be easy to change just this:

			oNode = aNodes[i];			// Toggle visibility of the node			oNode.setVisible( !oNode.isVisible() );		}

to something like lock/unlock? I sadly doesnt know the daz3d scripts and what they wanna get as input.

 

Edit:

I found out, that I can drag them from the left to the right side, now its in my toolbar, well... is it now possible to make it into 1 button? Also as icon instead of thise long text?

Post edited by Loony on

Comments

  • I don't see a simple setLock/isLocked to match the visibility ones. Do you want to lock every proeprty or just the transforms?

  • LoonyLoony Posts: 1,817
    edited September 2020

    uhm... just that what the daz studio does in the first image. that a char/finger/camera can no longer rotate or translate. Stay in position or not.

     

    Post edited by Loony on
  • Well, this will do it - but note that the lock commands in the menu are locking/unlocking explicitly rather than toggling so you may find it doesn't do what you want. You can easily make two copies of the script replace the !oTransformProp.isLocked() bits in the toggling lines with true (lock) or false (unlock) to create a pair of scripts that unlock or lock. You might also want to exclude invisible properties, either from this version or from the lock/unlock versions, which could be done by making the

    if ( oTransformProp ) {

    lines

    if ( oTransformProp && !oTransformProp.isHidden()  ) {

    (that is, do the toggling only if we have the control property and is it is not hidden)

    /********************************************************************** 	Copyright (C) 2002-2020 Daz 3D, Inc. All Rights Reserved. 	This script is provided as part of the Daz Script Documentation. The	contents of this script, and\or any portion thereof, may only be used	in accordance with the following license: 	Creative Commons Attribution 3.0 Unported (CC BY 3.0)	- http://creativecommons.org/licenses/by/3.0 	To contact Daz 3D or for more information about Daz Script visit the	Daz 3D website: 	- http://www.daz3d.com		Modified September 2020 by Richard Haseltine	Changed the main loop to call a special lock function, 	lock function toggles locked on/off for the standard 	node trasnforms (translate, rotate, and scale **********************************************************************/// Source: http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/nodes/node_visibility_toggle/start// Define an anonymous function;// serves as our main loop,// limits the scope of variables(function(){		function toggleTransformLocks( oNode ) {		// change the lock state of all of the node's basic transforms				// a variable to store the transform properties		var oTransformProp;				//////////// TRANSLATE //////////////				// Get the X translation transform property		oTransformProp = oNode.getXPosControl();		// assuming that worked...		if ( oTransformProp ) {			// toggle the lock state to be the opposite of its current value			oTransformProp.lock( !oTransformProp.isLocked() );		}				// Get the Y translation transform property		oTransformProp = oNode.getYPosControl();		// assuming that worked...		if ( oTransformProp ) {			// toggle the lock state to be the opposite of its current value			oTransformProp.lock( !oTransformProp.isLocked() );		}				// Get the Z translation transform property		oTransformProp = oNode.getZPosControl();		// assuming that worked...		if ( oTransformProp ) {			// toggle the lock state to be the opposite of its current value			oTransformProp.lock( !oTransformProp.isLocked() );		}				//////////// ROTATION //////////////				// Get the X rotation transform property		oTransformProp = oNode.getXRotControl();		// assuming that worked...		if ( oTransformProp ) {			// toggle the lock state to be the opposite of its current value			oTransformProp.lock( !oTransformProp.isLocked() );		}				// Get the Y rotation transform property		oTransformProp = oNode.getYRotControl();		// assuming that worked...		if ( oTransformProp ) {			// toggle the lock state to be the opposite of its current value			oTransformProp.lock( !oTransformProp.isLocked() );		}				// Get the Z rotation transform property		oTransformProp = oNode.getZRotControl();		// assuming that worked...		if ( oTransformProp ) {			// toggle the lock state to be the opposite of its current value			oTransformProp.lock( !oTransformProp.isLocked() );		}				//////////// SCALE //////////////				// Get the overall scale transform property		oTransformProp = oNode.getScaleControl();		// assuming that worked...		if ( oTransformProp ) {			// toggle the lock state to be the opposite of its current value			oTransformProp.lock( !oTransformProp.isLocked() );		}				// Get the overall X scale transform property		oTransformProp = oNode.getXScaleControl();		// assuming that worked...		if ( oTransformProp ) {			// toggle the lock state to be the opposite of its current value			oTransformProp.lock( !oTransformProp.isLocked() );		}				// Get the overall Y scale transform property		oTransformProp = oNode.getYScaleControl();		// assuming that worked...		if ( oTransformProp ) {			// toggle the lock state to be the opposite of its current value			oTransformProp.lock( !oTransformProp.isLocked() );		}				// Get the overall Z scale transform property		oTransformProp = oNode.getZScaleControl();		// assuming that worked...		if ( oTransformProp ) {			// toggle the lock state to be the opposite of its current value			oTransformProp.lock( !oTransformProp.isLocked() );		}	}		/*********************************************************************/	// String : A function for retrieving a translation if one exists	function text( sText )	{		// If the version of the application supports qsTr()		if( typeof( qsTr ) != "undefined" ){			// Return the translated (if any) text			return qsTr( sText );		} 				// Return the original text		return sText;	};		/*********************************************************************/	// Declare working variable	var oNode;	// Get the selected nodes	var aNodes = Scene.getSelectedNodeList();	// Capture the number of selected nodes	var nNodes = aNodes.length;	// If we have no selected nodes	if( nNodes &lt; 1 ){		// Inform the user		MessageBox.warning(			text( "You must select one or more nodes to perform this action." ),			text( "Selection Error" ), text( "&amp;OK" ), "" );	// If we have selected nodes	} else {		// Start collecting changes		beginUndo();				// Iterate over the list of selected nodes		for( var i = 0; i &lt; nNodes; i += 1 ){			// Get the 'current' node			oNode = aNodes[i];			// Toggle transforms locking of the node			toggleTransformLocks( oNode );		}				// Finish collecting changes and add the undo to the stack		acceptUndo( text( "Toggle Node Transform Lock" ) );	}	// Finalize the function and invoke})();

     

  • LoonyLoony Posts: 1,817

    Thanks for the script, I will take tomorrow a look on it (was a long day and I am tired... 11pm here now).

    Will answer you tomorrow.

  • macleanmaclean Posts: 2,438

    Hmmm... Excuse me for butting in, but I was going to make a Feature Request on a related topic, except I haven't had time to thoroughly check it doesn't already exist.

    All I want to do is lock any object or node in the sense of it not being able to deselect when I accidentally miss the arrows on the Move Tool gizmo. I work with a lot of small objects, and this business of continually reselecting things is becoming a major pain. Even at full frame, it's so easy to miss the yellow arrow and hit the viewport instead.

    If it doesn't exist, I'll request  it, but I wanted to check. Sorry if I'm hijacking the thread!

  • LoonyLoony Posts: 1,817

    Yeah I know that damn problem xD... did just locked the floor, because I wanted to move the feet char and clicked the floor -_-

    but... locking the full scene hmmm.

     

  • maclean said:

    Hmmm... Excuse me for butting in, but I was going to make a Feature Request on a related topic, except I haven't had time to thoroughly check it doesn't already exist.

    All I want to do is lock any object or node in the sense of it not being able to deselect when I accidentally miss the arrows on the Move Tool gizmo. I work with a lot of small objects, and this business of continually reselecting things is becoming a major pain. Even at full frame, it's so easy to miss the yellow arrow and hit the viewport instead.

    If it doesn't exist, I'll request  it, but I wanted to check. Sorry if I'm hijacking the thread!

    I don't think it's possible to lock the selection, though i certainly know what you mean about accidental deselection.

  • macleanmaclean Posts: 2,438

    Thanks folks. Since it's not already an option, I'll put in a Feature Request for it.

  • LoonyLoony Posts: 1,817
    edited September 2020

    Well, this will do it - but note that the lock commands in the menu are locking/unlocking explicitly rather than toggling so you may find it doesn't do what you want. You can easily make two copies of the script replace the !oTransformProp.isLocked() bits in the toggling lines with true (lock) or false (unlock) to create a pair of scripts that unlock or lock. You might also want to exclude invisible properties, either from this version or from the lock/unlock versions, which could be done by making the

    Just readed that, so... when I understand you with my bad good English skills correct: I have at the end still 2 Scripts?

    So simply just the same like this?

    Maybe, what about, HOW to make buttons for this?

    Like this:

    How can I make the Lock/unlock into buttons instead of the long text? Just a Lock open/close icon.

    Post edited by Loony on
  • Yes, two scripts - one for locking, one for unlocking.

    Once you have the scripts saved, find them in the Content Library pane, right-click, Create Custom Action, and pick the menu you want to add them to. If you create icons you can assign them by going to Window>Workspace>Customise, finding the scripts in the Custom Actions list on the left, and right-clicking>Change Icon. You can put the scripts on a Tool bar by dragging from the left column of Customise to the place you want in the Tool bars tab on the right.

  • LoonyLoony Posts: 1,817
    edited September 2020

    Thanks Richard, I solved it without those scrpting, but I used your guide for icons ;)

    To see the name/function of that thing you can enable it:

    but I think I will remember for what the icons are :)

    I wish I could put it on my sidemousebuttons, but daz3d does not accept the sidebuttons for hotkeys :(

    Icons are from here:

    https://www.pngkey.com/detail/u2q8a9y3w7e6r5r5_locks-lock-unlock-icon-png/

    resized to 35x35px and colored white.

    In case that someone want them too, see attachment.

     

    Lock.png
    35 x 35 - 3K
    Unlock.png
    35 x 35 - 2K
    Post edited by Loony on
Sign In or Register to comment.