PDA

View Full Version : key selected in the track bar


Rindolfo
03-22-2008, 02:12 PM
I need a script that gives me the value of the frame of the key selected in the track bar.
http://img89.imageshack.us/img89/373/tcb2sb3.jpg
Thank.

ZeBoxx2
03-22-2008, 04:46 PM
hm... you'd think that'd be built into the trackBar interface. Not spotting anything, though.

Quick and dirty code that traverses over the selected objects, their properties including base properties, recursively, and collects all the selected keys:


global traversePropsForAnimatedKeys
fn traversePropsForAnimatedKeys obj base:true str:"" selectedKeys:#() = (
local props
try (
props = getPropNames obj
)
catch ( return false )

if (base) then ( props += getPropnames node )
for prop in props do (
propController = getPropertyController obj prop
if (propController != undefined) then (
for k in propController.keys where (k.selected) do (
format "element: %.%\n\tkey: %\n" str (prop as string) k
append selectedKeys k
)
)
else (
propValue = getProperty obj prop
if (classOf propValue == arrayParameter) then (
for i = 1 to propValue.count do (
el = propValue[i]
traversePropsForAnimatedKeys el base:false str:(str + "." + prop as string + "[" + i as string + "]") selectedKeys:selectedKeys
)
)
else (
traversePropsForAnimatedKeys propValue base:false str:(str + "." + prop as string) selectedKeys:selectedKeys
)
)
)
)

selectedKeys = #()
for o in (getCurrentSelection()) do (
traversePropsForAnimatedKeys o str:(append "$" o.name) selectedKeys:selectedKeys
)
uniqueKeyTimes = #()
for k in selectedKeys do (
appendIfUnique uniqueKeyTimes k.time
)
format "Currently selected key times: \n"
for kTime in uniqueKeyTimes do ( format "\t%\n" kTime )

You can remove the format statement from within 'traversePropsForAnimatedKeys' and such to remove the printed output - it's just there so I could see where it's grabbing keys from.

Sample output (Listener):

OK
traversePropsForAnimatedKeys()
#()
element: $GeoSphere01.radius
key: #Bezier Float key(1 @ 0f)
element: $GeoSphere01.radius
key: #Bezier Float key(2 @ 59f)
element: $GeoSphere01.material.maps[2].size
key: #Bezier Float key(1 @ 0f)
element: $GeoSphere01.material.maps[2].size
key: #Bezier Float key(2 @ 74f)
element: $GeoSphere01.baseObject.radius
key: #Bezier Float key(1 @ 0f)
element: $GeoSphere01.baseObject.radius
key: #Bezier Float key(2 @ 59f)
OK
#()
OK
Currently selected key times:
OK
0f
59f
74f
OK


Note that you can have more than one key selected, at different times, in the trackbar.

Rindolfo
03-22-2008, 09:05 PM
Hello, thank you very much for your interest.
I am searching only the frame of an alone selected key, with TCB controller and for position, rotation or scale.
Thank.

CGTalk Moderation
03-22-2008, 09:05 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.