Profile Picture

How come I cannot apply two rotations in one script?

Posted By Data Juggler 2 Months Ago
You don't have permission to rate!
Author
Message
Data Juggler
Data Juggler
Posted 2 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)

Group: Forum Members
Last Active: 2 days ago
Posts: 550, Visits: 928
This morning I completed Hello World, and my first prop rotation so the old resume almost has a new entry.

Here is the script, as I am trying to rotate these drone blades to look faster by using some prime number like 137 seems to make the blade jump around better and look faster than letting IClone divide out the rotation at each frame, which did not work very well as it started very slow and sped up at the end., and then stopped spinning in mid air.

One thing I figured out through trial and error is I had to put 1.2 to get approximately 137.5 or so; and my project appears scaled at 100%, so I am not sure why this is needed.

My plan was I going to write out all the numbers in a python script using C# (which I think in). I can't get two settings to work so 3,600 frames is less likely to work.

I guess I will start with the first question, is it possible to apply to rotations in a single file like I did. 
Any thoughts on why this doesn't work if it does.

I tried setting them in reverse order also, just to see if applying a later rotation overwrote an earlier rotation. Regardless of the order, it only applies the first time.

Thanks 

--
import os, RLPy, math
#-- Get Prop --#
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Drone - Blade FL")
#-- Get Transform Control and Data --#
ts_control = prop.GetControl("Transform")
ts_data_block = ts_control.GetDataBlock()
#-- Set Frame 3 to 137
ts_data_block.SetData("Rotation/RotationZ", RLPy.RTime(1), RLPy.RVariant(1.20))
#-- Set Frame 5 to 274 (No Effect)
ts_data_block.SetData("Rotation/RotationZ", RLPy.RTime(2), RLPy.RVariant(2.40))
--

https://forum.reallusion.com/uploads/images/9a2d6d4f-2cfe-4a70-ad3c-e897.png
Edited
2 Months Ago by Data Juggler
videodv
videodv
Posted 2 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)Distinguished Member (1.2K reputation)

Group: Forum Members
Last Active: 3 minutes ago
Posts: 211, Visits: 4.9K
Data Juggler (4/13/2019)
This morning I completed Hello World, and my first prop rotation so the old resume almost has a new entry.

Here is the script, as I am trying to rotate these drone blades to look faster by using some prime number like 137 seems to make the blade jump around better and look faster than letting IClone divide out the rotation at each frame, which did not work very well as it started very slow and sped up at the end., and then stopped spinning in mid air.

One thing I figured out through trial and error is I had to put 1.2 to get approximately 137.5 or so; and my project appears scaled at 100%, so I am not sure why this is needed.

My plan was I going to write out all the numbers in a python script using C# (which I think in). I can't get two settings to work so 3,600 frames is less likely to work.

I guess I will start with the first question, is it possible to apply to rotations in a single file like I did. 
Any thoughts on why this doesn't work if it does.

I tried setting them in reverse order also, just to see if applying a later rotation overwrote an earlier rotation. Regardless of the order, it only applies the first time.

Thanks 

--
import os, RLPy, math
#-- Get Prop --#
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Drone - Blade FL")
#-- Get Transform Control and Data --#
ts_control = prop.GetControl("Transform")
ts_data_block = ts_control.GetDataBlock()
#-- Set Frame 3 to 137
ts_data_block.SetData("Rotation/RotationZ", RLPy.RTime(1), RLPy.RVariant(1.20))
#-- Set Frame 5 to 274 (No Effect)
ts_data_block.SetData("Rotation/RotationZ", RLPy.RTime(2), RLPy.RVariant(2.40))


Hi Data Juggler

I have a script that uses a slider to change the ZRotation and this is the line I use.

ts_data_block.SetData("Rotation/RotationZ", RLPy.RTime(time_line), RLPy.RVariant(math.radians(slider_value)))

time_line = RLPy.RGlobal_GetTime() # gets the current position on the time line. 0 to length of project
slider_value = some value between 0 to 360

Dont forget one second on the time line is 1000 so

ts_data_block.SetData("Rotation/RotationZ", RLPy.RTime(2), RLPy.RVariant(2.40)) is one thousanth of a second after
ts_data_block.SetData("Rotation/RotationZ", RLPy.RTime(1), RLPy.RVariant(1.20))

You can only set one setting on each channel if you set ZRotation values from 3 to 137 then 5 to 274  one is over writing the other.

Hope this helps in some way
Chris.

Data Juggler
Data Juggler
Posted 2 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)

Group: Forum Members
Last Active: 2 days ago
Posts: 550, Visits: 928
Thanks for the tip about time is in milliseconds; should have known that as C# / Dot Net is also.

I did try to see if there was RFrame instead of RTime, and this threw an error.

This changes my whole plan finding out that I can't set the rotation at each frame like I wanted.

I wrote a hack Windows app that clicks the mouse and types in the value for each frame, but it would take 43,200 seconds to complete if it even works so I was hoping to use Python would let me explicitly set each frame. I may try the Windows thing when I go to bed tonight.

I don't see as much value in rotating with Python if you can only set one frame in a script, as I could do that in IClone.

My one suggestion is the Python menu option would be streamlined if replaced with a Toolbar button, so instead of:
Script > Load Python
Load Python button is just visible. 
One click instead of two.

I have now Pythoned, or slithered, and I don't really like it. Probably a little early for me to throw in the towel, but it looks a language of all variants, where I prefer OOP

Also comes down to I don't feel comfortable going from expert level in one to absolute newbie in another. I adopted to change better when I knew less.

Thanks for your reply,











4u2ges
4u2ges
Posted 2 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (5.3K reputation)Distinguished Member (5.3K reputation)Distinguished Member (5.3K reputation)Distinguished Member (5.3K reputation)Distinguished Member (5.3K reputation)Distinguished Member (5.3K reputation)Distinguished Member (5.3K reputation)Distinguished Member (5.3K reputation)Distinguished Member (5.3K reputation)

Group: Forum Members
Last Active: Yesterday
Posts: 1.7K, Visits: 7.0K
Not sure why you need to rotate on multiple frames. You probably need to set rotation at the very last frame.
Rotating 120 degrees per frame is pretty much satisfactory for high speed rotation. That is 216000 degrees on frame 1800, or 3769.91118 radians

So:

import RLPy, math
Blade_prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Cross")
LastFrame = RLPy.RTime.IndexedFrameTime(1799, RLPy.RGlobal.GetFps()) 
Blade_prop_control = Blade_prop.GetControl("Transform")
Blade_prop_data = Blade_prop_control.GetDataBlock()
Blade_prop_data.SetData("Rotation/RotationZ", LastFrame, RLPy.RVariant(3769.91118))
Blade_prop_control.SetKeyTransition(LastFrame, RLPy.ETransitionType_Linear, 1.0)



But frankly even if you set a 30 degrees per frame (that is 54000 at frame 1800, which can be set in iClone), you would not see any difference.





Edited
2 Months Ago by 4u2ges
Data Juggler
Data Juggler
Posted 2 Months Ago
View Quick Profile
Distinguished Member

Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)Distinguished Member (3.4K reputation)

Group: Forum Members
Last Active: 2 days ago
Posts: 550, Visits: 928
Once I set the Transition Curve Editor to linear, it now works fine when I set the distance between start 0 and end key frame at 720, and set the rotation at 78480 = 720 * 109. Using a prime number (109) seems to keep the blades from repeating.

Thanks



Reading This Topic