Switching and triggering FBX animation causes a flicker

I have an imported FBX that is a cardboard box with open and close animations.

I am using a render pick to see which of my boxes is being clicked and playing the animation to open the box if it is closed, or vice versa.

When I click the animation plays, but there is a flicker of the box from the alternate state - if it is closed, it shows it fully open for a frame before playing the animation.

Here’s my code that triggers when the render pick trigger is initiated:

def onOffToOn(channel, sampleIndex, val, prev):

	clicked_box = op('eval1')[0,0]

	box = op('%s' % clicked_box)
	
	anim_open = "BOX|Open"
	anim_close = "BOX|Close"

	if box.par.animation == anim_close:
		box.par.animation = anim_open
		box.par.initialize.pulse()
		box.par.start.pulse()

	elif box.par.animation == anim_open:
		box.par.animation = anim_close
		box.par.initialize.pulse()
		box.par.start.pulse()

	return

and here is what it ends up looking like:
Kapture 2025-05-10 at 15.25.20

Am I not handling the animations correctly?

Hi @nerk,

looking at this, it seems that when switching animations, the animation is not necessarily set to the starting point resulting in the flicker when hitting initialize.
It’s logged and we are having a look.

cheers
Markus

Thanks @snaut .

If it makes any difference I am using POPs 5.4 build 2023.32139, and I confirmed the FBX was imported using POPs:

Maybe it is notable that when I trigger the box animation with a button in the TD UI using the same code, I do not have this issue:

def onOffToOn(channel, sampleIndex, val, prev):

	box = op('Box1')
	anim_open = "BOX|Open"
	anim_close = "BOX|Close"

	if box.par.animation == anim_close:
		box.par.animation = anim_open
		box.par.initialize.pulse()
		box.par.cuepulse.pulse()

	elif box.par.animation == anim_open:
		box.par.animation = anim_close
		box.par.initialize.pulse()
		box.par.cuepulse.pulse()

	return

Kapture 2025-05-12 at 19.43.41

Any additional thoughts?