I had already solved it from 4U2Guess's answer.
I wrote this method: (it is only one line of code, so I could have just wrote this in the other method. Originally this was like Chris's answer, but it messed up the scale, not sure why.
control.SetKeyTransition(RLPy.RTime(currentTime), RLPy.ETransitionType_Linear, 1.0)I just pass in the control for a prop and the time as I apply each position:def RotateSphere(control, dataBlock, lastEndTime, startRotation, endRotation):
# Setup the frame after the last end time
startTime = lastEndTime
# make it faster by lowering this number or slower by increasing it
speed = 540
##-- Set Rotation Z
dataBlock.SetData("Rotation/RotationX", RLPy.RTime(startTime), RLPy.RVariant(startRotation * RLPy.RMath.CONST_DEG_TO_RAD))
# change the TransitionType
ChangeTransitionType(control, startTime)
# now set the endTime
endTime = startTime + speed
##-- Set Rotation Z
dataBlock.SetData("Rotation/RotationX", RLPy.RTime(endTime), RLPy.RVariant(endRotation * RLPy.RMath.CONST_DEG_TO_RAD))
# change the TransitionType
ChangeTransitionType(control, endTime)
# now set the endTime
endTime = endTime + speed
##-- Set Rotation Z
dataBlock.SetData("Rotation/RotationX", RLPy.RTime(endTime), RLPy.RVariant(startRotation * RLPy.RMath.CONST_DEG_TO_RAD))
# change the TransitionType
ChangeTransitionType(control, endTime)
# return value
return endTime
And the RotateSpheres method is called in a while loop when the button is clicked until the end of the scene:
def RotateSpheres():
# Update 3.31.2021: Now the lights are applied at a certain time
frameTime = RLPy.RGlobal.GetTime()
currentTime = frameTime.GetValue()
# currentFrame seems to need the Add 1 to get the current frame value from IClone
currentFrame = round(currentTime * .001 * 60, 0) + 1
framesLength = RLPy.RGlobal.GetProjectLength()
endTime = framesLength.GetValue()
frames = endTime * .001 * 60
text_edit.insertPlainText("Current Frame: " + str(currentFrame) + "\r\n");
text_edit.insertPlainText("Total Frames: " + str(frames) + "\r\n");
# show the user another message
text_edit.insertPlainText("Creating Sphere Animation. Please wait..." + "\r\n");
# Get Cylinder1
sourcePropName = "Cylinder1"
cylinder1 = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, sourcePropName)
# Get Cylinder5
sourcePropName = "Cylinder5"
cylinder5 = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, sourcePropName)
# get access to the control
# Cylinder1
cylinder1Control = cylinder1.GetControl("Transform")
cylinder1DataBlock = cylinder1Control.GetDataBlock()
# Cylinder5
cylinder5Control = cylinder5.GetControl("Transform")
cylinder5DataBlock = cylinder5Control.GetDataBlock()
# values for the rotate
cylinderDefault = 0
cylinder1Open = -42
cylinder5Open = 42
while (currentTime < endTime):
# Rotate Cylinder 5 to open and back to close
currentTime = RotateSphere(cylinder5Control, cylinder5DataBlock, currentTime, cylinderDefault, cylinder5Open)
if (currentTime > endTime):
# exit while loop
break
# Rotate Cylinder 5 to open and back to close
currentTime = RotateSphere(cylinder1Control, cylinder1DataBlock, currentTime, cylinderDefault, cylinder1Open)
# message
message = "Your Newtown's Cradle is ready." + "\r\n"
text_edit.insertPlainText(message);