Delete Unchanged keys

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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anubis's picture

Well, you have not turned

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.

my recent MAXScripts RSS (archive here)

Anubis's picture

Well, I'll try to explain it

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 ...

my recent MAXScripts RSS (archive here)

craigpmiller's picture

It took me a while to copy

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

craigpmiller's picture

Thanks I was never good at

Thanks
I was never good at learning a new language... :-)

Anubis's picture

I tested your code and it's

I tested your code and it's works.

my recent MAXScripts RSS (archive here)

craigpmiller's picture

Yes. It works on one object

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

AttachmentSize
ReduceKeys-08.ms 2.46 KB
craigpmiller's picture

Anubis, And here's version

Anubis,

And here's version four

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

Cheers

AttachmentSize
ReduceKeys-04.ms 1.09 KB
Anubis's picture

look for reduceKeys() in

look for reduceKeys() in MAXScript Reference

my recent MAXScripts RSS (archive here)

craigpmiller's picture

Anubis, I've made some

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

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

Help would be most appreciated.

:-)

AttachmentSize
ReduceKeys-03.ms 766 bytes
craigpmiller's picture

Thanks for the tip. Cheers

Thanks for the tip.

Cheers

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.