How to check if there is animation on an object?


#1

Hi gays!
Is there an easy way to check if there is any animation on the object (scale, position, rotation)?


#2

here also

and this


#3

I saw it, but for some reason it doesn’t work for me.
Of course I will try again, maybe I missed something


#4

because there was some typo

this should be ok for your needs

clearlistener()
 
(
 local aCurrentSelection = getCurrentSelection()
 for itemNode in aCurrentSelection do
 (
  local aControllers = #(itemNode.position.controller,itemNode.rotation.controller,itemNode.scale.controller)
  for itemController in aControllers do
  (
	  
   for itemKey in itemController.keys do
   (
	
	format "Name: % Key : % Time : % \n" itemNode.name itemKey itemKey.Time
	
   )
  )
 )
)

i just fixed and added name property in the format so credits to Nysuatro in the previous post


#5
Yes, it works now, thanks a lot!
One more question, along the way,
how can i remove all animation from an object?
I tried using

for o in selection do deletekeys o #allkeys

But when keys are removed,somtimes  objects move (rotate)

#6

if you don’t care about modifiers, names or handles you can use this

    for o in selection  do snapshot o ; delete selection

this will copy the objects without keyframes in the current state


#7

not an option,
i do care


#8

macros.run “Animation Tools” “DeleteSelectedAnimation”

Select object/s -> Alt + RMB click -> Delete Selected Animation


#9

the question is not precisely posed, and therefore it is difficult to answer it …
The point is, what counts as an animated controller … for example, is the script controller animated?

or for example an orientation constraint … it may not have keys, but is driven by an animated target


#10

Second question: what do we want to do with this “possibly animated object”?


#11

I tried this
Sometimes everything is ok
Sometimes objects change position when deleted.
it looks like the objects are in the middle of the animation,
which was deleted


#12

I tried this
Sometimes everything is ok
Sometimes objects change position when deleted.
it looks like the objects are in the middle of the animation,
which was deleted


#13

remove all animation keys
this is where the problem is,
have to be removed manually


#14

it sounds like you already know what nodes need to be cleaned from animation. In this case it’s easier to replace transform controller with a new default instance of PRS controller:

-- let's do it for one selected node
animate off, redraw off, at time 0 
(
	tm = $.transform
	$.transform.controller = createinstance prs
	$.transform = tm
)

don’t specify the time if you want to clear the animation at the current time.