Key frame counnt reset after i programmitically move a light

hi. i have a script which first reads the key frame count of a light movement. i get a positive number including the time index of the last key frame. the script reads the object transformation at that key frame, deletes rotates the object and writes the keyframe. it works, the object rotates and the keyframe appears in the time tracker. so i run the script again, only this time the script finds only one keyfram at 0:0 even though it’s visible in the timeshift. if i save the project and load it again it reads the lights keyframes again. is this a bug or a feature?

Based on your description, I suspect the issue might be a misunderstanding caused by the Timeline UI not updating after the script execution.
Whenever you make any changes to an object’s keys, please add the following line at the end of your script:

RLPy.RGlobal.ObjectModified(light_object, RLPy.EObjectModifiedType_Transform)

This line is used to notify iClone that the transform data of the specified object has changed and to update the related UI state accordingly.
I’m not entirely sure if this is the issue you’re encountering. Could you provide the script or a video so I can confirm the problem?

it seems to update the timeline just fine but it’s as it the system isn’t committing the changes or something. Here’s the code. it was written a long time ago and there are probably better ways to write it but here we are:

def moveObjectTo(**opts):

FPS = RLPy.RGlobal.GetFps().ToInt()
fps=RLPy.RGlobal.GetFps()
lTime = RLPy.RTime()
MagicNumber = 1000 / FPS
newx = None
newy = None
newz = None
newrx = None
newry = None
newrz = None
convert_to_radians = True
lObject = ""
if ('name' in opts):
    lObject = opts['name']
else:
    raise Exception("You forgot the name")
if ('time' in opts):
    lTime = RLPy.RTime.FromValue(opts['time'])
elif ('frame' in opts):
    #lTime = RLPy.RTime.FromValue(int(opts['frame']*MagicNumber))
    lFrame= opts['frame']
    current_time = RLPy.IndexedFrameTime(lFrame, fps)
    lTime = RLPy.RGlobal.GetFps().GetFrameTime(current_time)

else:
    lTime = RLPy.RTime.FromValue(0)


if ('tx' in opts):
    newx = opts['tx']
if ('ty' in opts):
    newy = opts['ty']
if ('tz' in opts):
    newz = opts['tz']

if ('rx' in opts):
    newrx = opts['rx']
if ('ry' in opts):
    newry = opts['ry']
if ('rz' in opts):
    newrz = opts['rz']
if ('convert_to_radians' in opts):
    convert_to_radians=opts['convert_to_radians']

#thisObject = RLPy.RScene.FindObject(RLPy.EObjectType_Light, tObJect)

objType = getType(lObject)
if  objType is None:
    pass
else:
    thisObject = RLPy.RScene.FindObject(getType(lObject), lObject)
    if thisObject is not None:
        ResetPropTransformation(lObject)
        control = thisObject.GetControl("Transform")

        datablock = control.GetDataBlock()


        if newx != None:

            datablock.SetData("Position/PositionX", lTime, RLPy.RVariant(newx))

        if newy != None:
            datablock.SetData("Position/PositionY", lTime, RLPy.RVariant(newy))

        if newz != None:
            datablock.SetData("Position/PositionZ", lTime, RLPy.RVariant(newz))

        if convert_to_radians:
            if newrx != None:
                datablock.SetData("Rotation/RotationX", lTime, RLPy.RVariant(radians(newrx)))
            if newry != None:
                datablock.SetData("Rotation/RotationY", lTime, RLPy.RVariant(radians(newry)))
            if newrz != None:
                datablock.SetData("Rotation/RotationZ", lTime, RLPy.RVariant(radians(newrz)))
        else:
            if newrx != None:
                datablock.SetData("Rotation/RotationX", lTime, RLPy.RVariant(newrx))
            if newry != None:
                datablock.SetData("Rotation/RotationY", lTime, RLPy.RVariant(newry))
            if newrz != None:
                datablock.SetData("Rotation/RotationZ", lTime, RLPy.RVariant(newrz))
        RLPy.RGlobal.ObjectModified(thisObject, RLPy.EObjectModifiedType_Transform)

from the log console. on first run

keys = 2
time=3600.0 keyindex=-1

every time i run the same scrip afterwards

keys = 1
time=0.0 keyindex=-1

until i save and reload. yet the timeline updates properly all the time, but python no longer sees the keys

Hi Frank,
It seems that moveObjectTo() is currently being called using the frame parameter. You might want to check the part of the code where moveObjectTo() is invoked and see how the frame value is determined.

when a parameter frame is passed it’s converted to time anyway, so that wouldn’t make a difference anyway. also if there was a problem there, the script wouldn’t work. it does. the only issue is python no longer sees the keyframes even though the timeline sees them just fine.