<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Rotation keyframe assignment via script is screwy and inconsistent in 3ds Max Programming Forum</title>
    <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/rotation-keyframe-assignment-via-script-is-screwy-and/m-p/8267935#M9759</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Wow thanks&lt;/SPAN&gt;&lt;SPAN&gt;!&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;I didn't know the TCB controller still let you set individual axes like that. It works for me&lt;/SPAN&gt;&lt;SPAN&gt;. Even the obj1.rotation.Y_rotation for setting values still works&lt;/SPAN&gt;&lt;SPAN&gt;. Probably TCB is the better option for programming rotations&lt;/SPAN&gt;&lt;SPAN&gt;, s&lt;/SPAN&gt;&lt;SPAN&gt;o long as you don't need the UI or graph editor.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Sep 2018 08:50:05 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-09-14T08:50:05Z</dc:date>
    <item>
      <title>Rotation keyframe assignment via script is screwy and inconsistent</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/rotation-keyframe-assignment-via-script-is-screwy-and/m-p/8255922#M9754</link>
      <description>&lt;P&gt;This code&amp;nbsp;captures the problem&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;obj1 = Box pos:[100, 100, 100]&lt;BR /&gt;obj2 = Box pos:[200, 100, 100]&lt;BR /&gt;obj3 = Box pos:[300, 100, 100]&lt;BR /&gt;&lt;BR /&gt;set animate on&lt;BR /&gt;for t = 1 to 101 by 10 do (&lt;BR /&gt; &lt;BR /&gt; at time t obj1.rotation.Y_rotation = 5*t&lt;BR /&gt; &lt;BR /&gt; at time t obj2.rotation.Y_rotation = 5*t&lt;BR /&gt; at time t obj2.rotation.Y_rotation = 5*t&lt;BR /&gt; &lt;BR /&gt; at time t obj3.rotation.Y_rotation = 5*t&lt;BR /&gt; at time t obj3.rotation.Y_rotation = 5*t&lt;BR /&gt; at time t obj3.rotation.Y_rotation = 5*t&lt;BR /&gt;)&lt;BR /&gt;animate off&lt;/PRE&gt;&lt;P&gt;I'd expect all three Boxes to have identical animation, and for their y-rotations to increase continuously at a steady rate over 101 frames.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead, all three box rotations reverse&amp;nbsp;rotation direction after frames 21 and 91. Moreover, while obj1 and obj3 behave the same screwy way, obj2&amp;nbsp;differs at frames 21, 41, and 91 because apparently multiple assignments to the same value sometimes has the effect of toggling between two values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For completeness here's a table for the full results I got, weird numbers in &lt;FONT color="#FF0000"&gt;red&lt;/FONT&gt;, and &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;bolded red&lt;/FONT&gt;&lt;/STRONG&gt; where obj2 doesn't match obj1, obj3.&lt;/P&gt;&lt;PRE&gt;Frame               |  1  11  21  31  41  51  61  71  81  91 101&lt;BR /&gt;Expected Y-rotation |  &lt;FONT color="#0000FF"&gt;5  55 105 155 205 255 305 355 405 455 505&lt;/FONT&gt;&lt;BR /&gt;obj1, obj3 actual   |  5  55 105 &lt;FONT color="#FF0000"&gt; 25&lt;/FONT&gt; 205 &lt;FONT color="#FF0000"&gt;285&lt;/FONT&gt; 305 355 405 455 &lt;FONT color="#FF0000"&gt;395&lt;/FONT&gt;&lt;BR /&gt;obj2 actual         |  5  55  &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;75&lt;/STRONG&gt;  25 &lt;STRONG&gt;335&lt;/STRONG&gt; 285&lt;/FONT&gt; 305 355 405 &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;445&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#FF00FF"&gt;&lt;FONT color="#FF0000"&gt;395&lt;/FONT&gt; &lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What's causing this? If it's something weird with the EulerXYZ controller I can't find any mention in the documentation or in the forums.&amp;nbsp;I notice&amp;nbsp;some of the wrong values add with the correct ones in such a way that the sum is a multiple of 180 but I don't know what to make of this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For what I'm doing I only need this one axis of rotation. The other two axes are completely untouched, as in my example code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: I'm using 3ds Max 2017 on Windows 10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 00:31:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/rotation-keyframe-assignment-via-script-is-screwy-and/m-p/8255922#M9754</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-10T00:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Rotation keyframe assignment via script is screwy and inconsistent</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/rotation-keyframe-assignment-via-script-is-screwy-and/m-p/8255984#M9755</link>
      <description>&lt;P&gt;That is a weird result.&lt;BR /&gt;Maybe try "angleaxis" which will rotate the box (t * 5 degrees) each rotation.&lt;/P&gt;&lt;PRE&gt;(
	local obj1 = Box pos:[100, 100, 100]
	local obj2 = Box pos:[200, 100, 100]
	local obj3 = Box pos:[300, 100, 100]

	set animate on
	for t = 1 to 101 by 10 do (
		at time t rotate obj1 (angleaxis (t * 5) [0,1,0])
		at time t rotate obj1 (angleaxis (t * 5) [0,1,0])

		at time t rotate obj2 (angleaxis (t * 5) [0,1,0])
		at time t rotate obj2 (angleaxis (t * 5) [0,1,0])

		at time t rotate obj3 (angleaxis (t * 5) [0,1,0])
		at time t rotate obj3 (angleaxis (t * 5) [0,1,0])
		at time t rotate obj3 (angleaxis (t * 5) [0,1,0])
	)
	set animate off
)&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Sep 2018 01:34:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/rotation-keyframe-assignment-via-script-is-screwy-and/m-p/8255984#M9755</guid>
      <dc:creator>blakestone</dc:creator>
      <dc:date>2018-09-10T01:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: Rotation keyframe assignment via script is screwy and inconsistent</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/rotation-keyframe-assignment-via-script-is-screwy-and/m-p/8256006#M9756</link>
      <description>&lt;P&gt;Using the angleaxis wasn't working for me. To set it to an absolute angle (rather than rotate by an amount) I tried computing the existing angle and rotate by the amount &lt;FONT face="courier new,courier"&gt;desired_angle - current_angle&lt;/FONT&gt;, but this was all over the place too. It seems there are different angle systems used between &lt;FONT face="courier new,courier"&gt;obj.rotation.Y_rotation&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;rotate obj (angleaxis angle [0,1,0])&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But your idea was the jumping off point for looking into directly changing the keyframe values, and&amp;nbsp;it looks like the following works exactly as I want:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;obj1 = Box pos:[100, 100, 100]
obj2 = Box pos:[200, 100, 100]
obj3 = Box pos:[300, 100, 100]

fn aarotate obj tf ang = (
	
	addNewKey obj.rotation.Y_rotation.controller tf
	ki = getKeyIndex obj.rotation.Y_rotation.controller tf
	obj.rotation.Y_rotation.keys[ki].value = ang
)

set animate on
for t = 1 to 101 by 10 do (
	aarotate obj1 t (5*t)
	
	aarotate obj2 t (5*t)
	aarotate obj2 t (5*t)
	
	aarotate obj3 t (5*t)
	aarotate obj3 t (5*t)
	aarotate obj3 t (5*t)
)
animate off&lt;/PRE&gt;&lt;P&gt;I'd still like to know what was going on with the &lt;FONT face="courier new,courier"&gt;obj.rotation.Y_rotation&lt;/FONT&gt; keyframing, if anyone knows.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 02:18:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/rotation-keyframe-assignment-via-script-is-screwy-and/m-p/8256006#M9756</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-10T02:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: Rotation keyframe assignment via script is screwy and inconsistent</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/rotation-keyframe-assignment-via-script-is-screwy-and/m-p/8256012#M9757</link>
      <description>&lt;P&gt;Well done with your solution!&lt;/P&gt;&lt;P&gt;I have run into issues like this not only in 3dsMax but in other applications where a rotational calculation will go past 360 degrees so it resets back to 0 and then it throws out a calculation or animation etc. I think this may be what was happening here. It was setting a rotation to the correct calculation but it doesn't know what direction to turn the object to get there.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 02:27:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/rotation-keyframe-assignment-via-script-is-screwy-and/m-p/8256012#M9757</guid>
      <dc:creator>blakestone</dc:creator>
      <dc:date>2018-09-10T02:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: Rotation keyframe assignment via script is screwy and inconsistent</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/rotation-keyframe-assignment-via-script-is-screwy-and/m-p/8266337#M9758</link>
      <description>&lt;P&gt;The primary problem with your script is that you are trying to input angles greater than 180° to an Euler rotational controller. You must use a TCB controller for angles greater than 180° &lt;U&gt;AND&lt;/U&gt; you must have the Rotation Windup option checked.&amp;nbsp; If an Euler controller is used or if a TCB controller is used without Rotation Windup checked, angles greater than 180 are changed to a value that is the remainder of the value divided by 180.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cn2.JPG" style="width: 282px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/545892i65F2711276AE0305/image-size/large?v=v2&amp;amp;px=999" role="button" title="cn2.JPG" alt="cn2.JPG" /&gt;&lt;/span&gt;&lt;BR /&gt;I think the following code does what you want.&amp;nbsp; You may also want to set the TCB tension to 50 if you want a linear transition between keyframes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;obj1 = Box pos:[100, 100, 100]&lt;BR /&gt;obj1.rotation.controller = tcb_rotation ()&lt;BR /&gt;obj1.rotation.controller.rotWindup = True &lt;BR /&gt;obj2 = Box pos:[200, 100, 100]&lt;BR /&gt;obj2.rotation.controller = tcb_rotation ()&lt;BR /&gt;obj2.rotation.controller.rotWindup = True &lt;BR /&gt;obj3 = Box pos:[300, 100, 100]&lt;BR /&gt;obj3.rotation.controller = tcb_rotation ()&lt;BR /&gt;obj3.rotation.controller.rotWindup = True &lt;BR /&gt;set animate on&lt;BR /&gt;for t = 1 to 101 by 10 do (&lt;BR /&gt; &lt;BR /&gt; at time t rotate obj1 (angleAxis (5*t ) [0, 1, 0] ) &lt;BR /&gt;&lt;BR /&gt; at time t rotate obj2 (angleAxis (5*t ) [0, 1, 0] ) &lt;BR /&gt; at time t rotate obj2 (angleAxis (5*t ) [0, 1, 0] ) &lt;BR /&gt;&lt;BR /&gt; at time t rotate obj3 (angleAxis (5*t ) [0, 1, 0] ) &lt;BR /&gt; at time t rotate obj3 (angleAxis (5*t ) [0, 1, 0] ) &lt;BR /&gt; at time t rotate obj3 (angleAxis (5*t ) [0, 1, 0] ) &lt;BR /&gt; &lt;BR /&gt;)&lt;BR /&gt;animate off&lt;BR /&gt;
&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 16:30:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/rotation-keyframe-assignment-via-script-is-screwy-and/m-p/8266337#M9758</guid>
      <dc:creator>leeminardi</dc:creator>
      <dc:date>2018-09-13T16:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: Rotation keyframe assignment via script is screwy and inconsistent</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/rotation-keyframe-assignment-via-script-is-screwy-and/m-p/8267935#M9759</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Wow thanks&lt;/SPAN&gt;&lt;SPAN&gt;!&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;I didn't know the TCB controller still let you set individual axes like that. It works for me&lt;/SPAN&gt;&lt;SPAN&gt;. Even the obj1.rotation.Y_rotation for setting values still works&lt;/SPAN&gt;&lt;SPAN&gt;. Probably TCB is the better option for programming rotations&lt;/SPAN&gt;&lt;SPAN&gt;, s&lt;/SPAN&gt;&lt;SPAN&gt;o long as you don't need the UI or graph editor.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 08:50:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/rotation-keyframe-assignment-via-script-is-screwy-and/m-p/8267935#M9759</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-09-14T08:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: Rotation keyframe assignment via script is screwy and inconsistent</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/rotation-keyframe-assignment-via-script-is-screwy-and/m-p/8268330#M9760</link>
      <description>&lt;P&gt;An other option, if you'd like to keep Euler rotations, would be to set a value to the key instead of using the Rotate function.&lt;/P&gt;
&lt;P&gt;You could&amp;nbsp;have something like :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;obj_all = #(
obj1 = (Box pos:[100, 100, 100]),
obj2 = (Box pos:[200, 100, 100]),
obj3 = (Box pos:[300, 100, 100])
)

for t = 1 to 101 by 10 do (
	for obj in obj_all do (
	addNewKey obj.rotation.controller.Y_Rotation.controller t
	keyIdx =(getKeyIndex obj.rotation.controller.Y_Rotation.controller t)
	obj.rotation.controller.Y_Rotation.controller.keys[keyIdx].value = 5*t 
	)
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By setting the Key value, you get the highest level of control and consistency on the resulting animation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;(sorry for intrusion or interference)&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 12:08:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/rotation-keyframe-assignment-via-script-is-screwy-and/m-p/8268330#M9760</guid>
      <dc:creator>ads_royje</dc:creator>
      <dc:date>2018-09-14T12:08:54Z</dc:date>
    </item>
  </channel>
</rss>

