ScriptSpot home

Forum topic · Scripts Wanted

Delete Unchanged keys

By craigpmiller · 2009-06-24

Description

Hi
I'm a newbee script writer

I'm trying to get my head around writing a script that would select all the unchanged keys in an object's animation and delete them. A little like Biped can thin out the every-key-on-every-frame when it imports motion capture data.

Cheers all

Craig

Comments (10)
Panayot Karabakalov

Well, you have not turned attention to the syntax of my example. If use count-loop "for i in 1 to $.count" (ie loop by index) then "$[i].controller" is correct, but in other loop is "i.controller". See the difference, right?

P.S. - Opss... just me ahead. I see that you did.

Panayot Karabakalov

Well, I'll try to explain it briefly. Then loop in selection by index selection[1] is the 1st node in selection, but if there only one node selected, those loop run inside object subAnimLevels instead of returning baseObject, so speaking briefly:

-- replace:
for i in 1 to $.count do ( reduceKeys $[i].controller ...
-- with:
for i in selection do ( reduceKeys i.controller ...
Reply to Panayot Karabakalov
craigpmiller

It took me a while to copy your line correctly - can your believe it took me three goes to type it in correctly?

All working smoothly without the added point

Thanks

Panayot Karabakalov

I tested your code and it's works.

Reply to Panayot Karabakalov
craigpmiller

Yes.
It works on one object but fails if there is more than one object selected.

If I modify my code like this ...

for i in 1 to $.count do
(
reduceKeys $[i].controller SP_Threshold.value SP_Duration.value animationrange
)

it works for multiple selections but fails for a single object.

Any clues so it will handle both?

Addendum :-)

I had another thought and it's probably a bit of a cludge but I had the script add a tiny point helper and add that to the selection so there is always more than one object in the selection - loop does not fail - then delete it afterward.

The screen redraw is a little disconcerting but with multiple objects you get a screen redaw after every loop.

Any clues?

Cheers

Attachments
craigpmiller

Anubis,

And here's version four

Much more success but it is still reducing key outside the range I'm setting ... hopefully.

Cheers

Attachments
Panayot Karabakalov

look for reduceKeys() in MAXScript Reference

Reply to Panayot Karabakalov
craigpmiller

Anubis,
I've made some progress but ...

I'm having some difficulty inserting some values into the expressions.

Help would be most appreciated.

:-)

Attachments