Script to reset XYZ rotate

Hello,

 

I am looking for any script to reset rotation in one click. Maybe someone have and could share?

Comments

  • You could use Window>Workspace>Customise to drag Parameters>Zero Selected Item(s) Pose on the left to a menu or tool bar on the right (probably adding an icon - right-click on the command in the left-hand list).

  • martin36martin36 Posts: 178

    Yes, I have this as button but I want just reset xyz not the selected figure (zero figure is even worse as take roughly 2 mins to do this) and this is taking ages. Resrt xyz will be much faster. Now I  manually set all axis to 0 and this works fine but looking for script to do that.

  • Victor_BVictor_B Posts: 392
    edited December 2020

    Save this script as, for example, "Rotate_to_zero.dsa" and make a custom action. Enjoy. ;)


    // This script sets the rotation to [0,0,0] of selected node.// Author Victor_B// 06.12.2020(function(){var oNode = Scene.getPrimarySelection();if (oNode) {	oNode.findPropertyByLabel("X Rotate", true).setValue(0);	oNode.findPropertyByLabel("Y Rotate", true).setValue(0);	oNode.findPropertyByLabel("Z Rotate", true).setValue(0);}else {	var sMessage = qsTr("Select node for rotation, please.");    MessageBox.critical( sMessage, qsTr("Something went wrong..."), qsTr("&OK") );    return;	}})();
    Post edited by Victor_B on
  • martin36 said:

    Yes, I have this as button but I want just reset xyz not the selected figure (zero figure is even worse as take roughly 2 mins to do this) and this is taking ages. Resrt xyz will be much faster. Now I  manually set all axis to 0 and this works fine but looking for script to do that.

    The command I gave will zero only what you have selected, not the whole figure.

  • martin36martin36 Posts: 178

    Victor_B said:

    Save this script as, for example, "Rotate_to_zero.dsa" and make a custom action. Enjoy. ;)

     
    // This script sets the rotation to [0,0,0] of selected node.// Author Victor_B// 06.12.2020(function(){var oNode = Scene.getPrimarySelection();if (oNode) {	oNode.findPropertyByLabel("X Rotate", true).setValue(0);	oNode.findPropertyByLabel("Y Rotate", true).setValue(0);	oNode.findPropertyByLabel("Z Rotate", true).setValue(0);}else {	var sMessage = qsTr("Select node for rotation, please.");    MessageBox.critical( sMessage, qsTr("Something went wrong..."), qsTr("&OK") );    return;	}})();

    Thank you very much. I think this will be most frequent used script by me. Thank you again Victor_B

  • martin36martin36 Posts: 178

    Richard Haseltine said:

    martin36 said:

    Yes, I have this as button but I want just reset xyz not the selected figure (zero figure is even worse as take roughly 2 mins to do this) and this is taking ages. Resrt xyz will be much faster. Now I  manually set all axis to 0 and this works fine but looking for script to do that.

    The command I gave will zero only what you have selected, not the whole figure.

    Yes I know but you still have to select three items and with the script this will work for multiple characters selcted in scene 

  • martin36 said:

    Richard Haseltine said:

    martin36 said:

    Yes, I have this as button but I want just reset xyz not the selected figure (zero figure is even worse as take roughly 2 mins to do this) and this is taking ages. Resrt xyz will be much faster. Now I  manually set all axis to 0 and this works fine but looking for script to do that.

    The command I gave will zero only what you have selected, not the whole figure.

    Yes I know but you still have to select three items and with the script this will work for multiple characters selcted in scene 

    I'm not trying to tlak you out of using the script, but for the record  it will work (as written) on only one item (the Primary Selection). The command I gave works on multiple selected items, should that be what you want.

  • Victor_BVictor_B Posts: 392
    edited December 2020

    It looks like you're provoking me to upgrade the script, Richard. What you'll say now? cheeky

     

    // This script sets the rotation to [0,0,0] of selected nodes.// Author: Victor_B// Date: 06.12.2020(function(){var aNodeList = Scene.getSelectedNodeList();if (aNodeList.length == 0){	var sMessage = qsTr("Select nodes for rotation, please.");    MessageBox.critical( sMessage, qsTr("Something went wrong..."), qsTr("&OK") );    return;	}for (i=0; i < aNodeList.length; i++){	var oNode = aNodeList[i];		if (oNode) {		oNode.findPropertyByLabel("X Rotate", true).setValue(0);		oNode.findPropertyByLabel("Y Rotate", true).setValue(0);		oNode.findPropertyByLabel("Z Rotate", true).setValue(0);	}}})();
    Post edited by Victor_B on
  • Victor_B said:

    It looks like you're provoking me to upgrade the script, Richard. What you'll say now? cheeky

     

    // This script sets the rotation to [0,0,0] of selected nodes.// Author: Victor_B// Date: 06.12.2020(function(){var aNodeList = Scene.getSelectedNodeList();if (aNodeList.length == 0){	var sMessage = qsTr("Select nodes for rotation, please.");    MessageBox.critical( sMessage, qsTr("Something went wrong..."), qsTr("&OK") );    return;	}for (i=0; i < aNodeList.length; i++){	var oNode = aNodeList[i];		if (oNode) {		oNode.findPropertyByLabel("X Rotate", true).setValue(0);		oNode.findPropertyByLabel("Y Rotate", true).setValue(0);		oNode.findPropertyByLabel("Z Rotate", true).setValue(0);	}}})();

    I did say "as written" (or perhaps that should have been "as posted").

  • Victor_BVictor_B Posts: 392
    edited December 2020

    So, is that means everything is posted good now? wink

    (I just provoking you to say this ;)

    Of course I see the difference. My script works with rotations only. Not with Bend or Twist. But that is how I understood the "script to reset rotation in one click".

    Post edited by Victor_B on
  • Bend and twist are rotations - and it's true that the command I gave affects all trasnforms, not just the rotations, but for most bones it's not going to make much difference. However, a script certainly allows greater flexibility (it could, for example, restrict tiself to actual bones if that was desired - which it wasn't here).

  • Victor_BVictor_B Posts: 392
    edited December 2020

    Don't provoke me, Richard. :)))


    // DAZ Studio version 4.12.0.86 filetype DAZ Script// Author: Victor_B// Date: 07.12.2020// This script sets parameters to 0 of selected nodes.// You can add/remove any parameter you need and change it's value (function(){var aParameters = [		["X Rotate", 0], // parameter's name and value		["Y Rotate", 0],		["Z Rotate", 0],		["Bend", 0],		["Twist", 0],		["Side-Side", 0],		["Up-Down", 0],		["Front-Back", 0]	];function getPropertyNames(oNode) {		var aPropList = oNode.getPropertyList();	var aNames = [];			for (var i=0; i < aPropList.length; i++){		aNames[i] = aPropList[i].getLabel();	}		return aNames;}var aNodeList = Scene.getSelectedNodeList();if (aNodeList.length == 0){	var sMessage = qsTr("Select node for rotation, please.");    MessageBox.critical( sMessage, qsTr("Something went wrong..."), qsTr("&OK") );    return;	}for (i=0; i < aNodeList.length; i++){	var oNode = aNodeList[i];		if (oNode) {		var aPropNames = getPropertyNames(oNode);		for (a=0; a < aParameters.length; a++){						if (aPropNames.indexOf(aParameters[a][0]) > -1){				oNode.findPropertyByLabel(aParameters[a][0], true).setValue(aParameters[a][1]);				//print(aParameters[a][0]);			}		}	}}})();
    Post edited by Victor_B on
  • Victor_BVictor_B Posts: 392
    edited December 2020

    I hope that is good enough...

    Post edited by Victor_B on
  • I shall refrain from saying anything for fear of driving you to yet more coding :)

  • You guys had me laughing out loud!  Thanks!!!!

  • martin36martin36 Posts: 178

    Victor_B said:

    I hope that is good enough...

    This is perfect. Thank you Victor_B 

  • Damn. That "fight" could have resulted in a really cool tool laughlaugh

Sign In or Register to comment.