Notifications
Clear all

[Closed] getKeyIndex returns 0

I have a node that was Frozen, so it has a List controller for position (and rotation, same issue I suspect).

I want to get the index of certain keys, but getKeyIndex (which would be the natural choice for that) seems to return 0 in those cases?

I use this, with the node in question selected:

c = $.position.controller[2].controller
deselectKeys c
for k in c.keys do (
-- 	if (k.time >= startTime) then (
-- 		if (k.time <= endTime OR endTime == -1f) then (
		
			selectKey c (getKeyIndex c (c.keys[2].time))
			
-- 		)
-- 	)
)





But I get the following error:

Runtime error: Key index out of range in selectKey: 0

Which isn’t surprising, since getKeyIndex c (c.keys[2].time) returns 0, where I think it ought to return a positive integer (?).

I want to get at the Zero Pos XYZ controller, hence the [2].

As you can see from the commented lines, I want to perform certain checks on the keys before deciding if they should be selected. The checks I have here are related to time, but it could be anything, so selectKeys <interval> might not cut it.

1 Reply

the Position_XYZ controller itself doesn’t have keys. its X,Y, and Z float controllers have a keys.