Can I make a Pose-preset / script to increment x/y-translate rather than absolute?

Can I make a Pose-preset / script to increment x/y-translate rather than one that sets the x/y position as an absolute?

In other words, I'd select (say) G8M's root node, apply this pose/script, and he'd move (say) 100 units in the x direction (and others to move him negative-x, positive-y, and negative-y).

If so, how might I do this?

 

Thanks in advance for any help,

SW :)

Comments

  • macleanmaclean Posts: 2,438

    I can give you this script in .dsa format (originally made for DS3). These are the scripts I used in my Room Creator series of products and they work just fine in DS 4.12, but I'd recommend looking for a way to update them.

    // DAZ Studio version 3.1  filetype DAZ Scriptvar xPos = 170;var yPos = NaN;var zPos = NaN;function moveObject( object ){	if( object == undefined )		return;	if( !isNaN( xPos ) )		object.getXPosControl().setValue( object.getXPosControl().getValue() + xPos );	if( !isNaN( yPos ) )		object.getYPosControl().setValue( object.getYPosControl().getValue() + yPos );	if( !isNaN( zPos ) )		object.getZPosControl().setValue( object.getZPosControl().getValue() + zPos );}beginUndo();for( var i = 0; i < Scene.getNumSelectedNodes(); i++ )moveObject( Scene.getSelectedNode( i ) );acceptUndo( "Move selected object(s)" );
    // DAZ Studio version 3.1  filetype DAZ Scriptvar xRot = NaN;var yRot = 90;var zRot = NaN;function moveObject( object ){	if( object == undefined )		return;	if( !isNaN( xRot ) )		object.getXRotControl().setValue( object.getXRotControl().getValue() + xRot );	if( !isNaN( yRot ) )		object.getYRotControl().setValue( object.getYRotControl().getValue() + yRot );	if( !isNaN( zRot ) )		object.getZRotControl().setValue( object.getZRotControl().getValue() + zRot );}beginUndo();for( var i = 0; i < Scene.getNumSelectedNodes(); i++ )moveObject( Scene.getSelectedNode( i ) );acceptUndo( "Move selected object(s)" );

    The first script is for translation (an Xtrans of 170cm) and the 2nd for rotation (Yrot of 90 degrees). NaN = Not a Number - ie. no change. Add a minus to any value to make it negative. Undo function is also included.

    Hope this helps.

  • L'AdairL'Adair Posts: 9,479

    Can I make a Pose-preset / script to increment x/y-translate rather than one that sets the x/y position as an absolute?

    In other words, I'd select (say) G8M's root node, apply this pose/script, and he'd move (say) 100 units in the x direction (and others to move him negative-x, positive-y, and negative-y).

    If so, how might I do this?

     

    Thanks in advance for any help,

    SW :)

    Just for future reference, the numeric value fields of any parameter will calculate the math for you. For example, the value is 52.3183 and you need the object to move 72 units in the negative direction. Just add "-72" to the value, so it looks like 52.3183-72 and hit enter. DS will do the math.

    DS recognizes signs for subtraction (-), addition (+), multiplication (*) and division (/).

    This will also work for percentage values, but you must remove the % sign. For example, to add 25 to 88.5% you'd write 88.5+25.

    Using the % sign in any equation confuses DS, and the result will always be 0.00. If you need a percent of something, multiply the value by decimal equivalent of the percent. (27% = 0.27; 115% = 1.15; etc.)

    Mac's script looks really useful for translating objects, though; a real timesaver for moving a lot of objects the same distance!

  • macleanmaclean Posts: 2,438

    Thanks L'Adair. I was going to mention that function because it's one I use a lot, but I figured SW was more interested in a set of fixed increments. But the numeric field method is really handy too. Or both.

    Btw, I've always wanted to thank whoever added that function to DS. If the Dev Team see this........THANKS A LOT!!

  • GordigGordig Posts: 10,331
    L'Adair said:

    Using the % sign in any equation confuses DS, and the result will always be 0.00. If you need a percent of something, multiply the value by decimal equivalent of the percent. (27% = 0.27; 115% = 1.15; etc.)

    I have nothing to contribute to the actual topic, but this may because % is the operator for modulo, which calculates the remainder of a division. 

  • Thanks all :)
    L'Adair - that's great to know - in this case I'm needing a distributable script that end-users can use to move an object on a grid (so fixed movements as Maclean said).

    Maclean - that's wonderful, I'll try it out later. Is this something I could distribute with a product (obviously with the specific numbers I need) or is this your script, only given here for personal use?

     

    To avoid confusion - I'm moving pieces on a chess board so it'd be easy if people could click 'move forward one space' rather than having to manually gauge it each time.

  • You could also make a position pose preset for all 64 spaces on the chess board and just name them for example A1 to A8 and then obviously all the other spots. That way once the customer selects the piece they want to move, all they have to do is find and click the position pose preset of the grid space they want to move to. If its a king the increment might be easier but having the absolute positions could be easier moving a knight rather than 2 clicks one way and then 1 click another way or a castle the whole way across the board. Either option would work well :)

    Anyway, sounds like a really cool concept :) Good luck with it! 

  • And to think I've been doing math all this time to calculate translation values and the resulting position I wanted something...

  • ChoholeChohole Posts: 33,604
    Gordig said:
    L'Adair said:

    Using the % sign in any equation confuses DS, and the result will always be 0.00. If you need a percent of something, multiply the value by decimal equivalent of the percent. (27% = 0.27; 115% = 1.15; etc.)

    I have nothing to contribute to the actual topic, but this may because % is the operator for modulo, which calculates the remainder of a division. 

    Aye     Rob further advises

    '%' does not "confuse DS"... rather, you are unclear about what Daz Studio is actually doing, and what '%' actually means in the context in which it is used. The fields you are referring to are not "numeric fields"... rather, they are Daz Script evaluation fields and they can do a whole lot more than just simple math operations. As an extremely simple example, type "Joe User".length (exactly, with the quotation marks - which obviously contains no numbers) and press [Enter]. The value will be set to 8, because the length of the string is 8 characters in length. In ECMAScript, the '%' character is the "modulo" operator. 5 % 2 will return 1... because there is a remainder of 1 when 5 is divided by 2. Similarly, 15 % 3 would return 0... as 3 divides into 15, 5 times with no remainder.
     
  • macleanmaclean Posts: 2,438

    Maclean - that's wonderful, I'll try it out later. Is this something I could distribute with a product (obviously with the specific numbers I need) or is this your script, only given here for personal use?

    The script was given to me about 10 yrs ago by Guandalug (who hasn't been around for many years and is uncontactable) as part of a set I paid him for. He encrypted the main toolbar script so it couldn't be used by anyone else, but he gave me the scripts in clear as they were fairly basic.

    As far as I'm concerned, you could use them, but out of respect to Guandalug, I think you should only take them as a starting point, then have them updated to 4.12 standard.

  • Zeddicuss said:

    You could also make a position pose preset for all 64 spaces on the chess board and just name them for example A1 to A8 and then obviously all the other spots. That way once the customer selects the piece they want to move, all they have to do is find and click the position pose preset of the grid space they want to move to. If its a king the increment might be easier but having the absolute positions could be easier moving a knight rather than 2 clicks one way and then 1 click another way or a castle the whole way across the board. Either option would work well :)

    Anyway, sounds like a really cool concept :) Good luck with it!

    Yeah - but making 64 pose presets plus thumbnails is a lot of work. With the +/- script, even moving a piece across the board would only be 8 clicks for the customer (16 if it's a bishop/queen going corner to corner) and usually far less than that.

    maclean said:

    Maclean - that's wonderful, I'll try it out later. Is this something I could distribute with a product (obviously with the specific numbers I need) or is this your script, only given here for personal use?

    The script was given to me about 10 yrs ago by Guandalug (who hasn't been around for many years and is uncontactable) as part of a set I paid him for. He encrypted the main toolbar script so it couldn't be used by anyone else, but he gave me the scripts in clear as they were fairly basic.

    As far as I'm concerned, you could use them, but out of respect to Guandalug, I think you should only take them as a starting point, then have them updated to 4.12 standard.

    Fair enough - I'll consider it learning the language and try to find what 4.12 would do differently.
    Thanks :)

  • nonesuch00nonesuch00 Posts: 18,441

    Why not create 64 individual DAZ primitive square planes and create a chess board with them properly modeled and parented to the backer-board using the same labeling scheme as a real chess game. Then you should be able to move the pieces much easier in script I think. You may be even able to write an entire chess game in javascript (there is probably an open source javascript chess engine already if javascript can actually handle it.

Sign In or Register to comment.