Spliting keyframe dimensions

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
ggoblin
Posts: 266
Joined: Wed Jan 19, 2022 2:09 pm

Spliting keyframe dimensions

Post by ggoblin »

If you want to split keyframe dimensions, what is the correct procedure to do it from script?

For example if you want noisy interpretation in the y dimension and linear interpretation in the other channels I used

Code: Select all

mylayer.fTranslation:SetKeyInterp(myframe,MOHO.INTERP_LINEAR)

mylayer.fTranslation:DimensionChannel(1):SetKeyInterp(myframe,MOHO.INTERP_NOISY,myamp,myscale)
I think it resulted in some wierd side effects like keyframes defined BEFORE the split loosing some of their dimensions, so I changed it to:

Code: Select all

mylayer.fTranslation:SetKeyInterp(myframe,MOHO.INTERP_LINEAR)

my layer.fTranslation:SplitDimensions(true)
mylayer.fTranslation:DimensionChannel(1):SetKeyInterp(myframe,MOHO.INTERP_NOISY,myamp,myscale)
Now I am wondering do i need to add

Code: Select all

my layer.fTranslation:SplitDimensions(false)
at the end to join the dimensions again?

I don't really understand what SplitDimensions does, is it required before DimensionChannel is called?

I couldn't find any examples of SplitDimensions being used with a true value, and the documentation is empty other that saying it takes an argument b of type boolean and returns nothing.

Any insights would be greatly appreciated. Thank you.
User avatar
synthsin75
Posts: 9979
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Spliting keyframe dimensions

Post by synthsin75 »

Just like using split dimensions in the UI, you have to split the dimensions and leave them split for different axes to retain different interpolations.

So your second code block should be all you need.
ggoblin
Posts: 266
Joined: Wed Jan 19, 2022 2:09 pm

Re: Spliting keyframe dimensions

Post by ggoblin »

synthsin75 wrote: Mon Jul 18, 2022 7:25 pm Just like using split dimensions in the UI, you have to split the dimensions and leave them split for different axes to retain different interpolations.

So your second code block should be all you need.
Thank you for confirming this.

What happens is we call DimensionChannel without first calling SplitDimensions? Shouldn't DimensionChannel implicitly call SplitDimensions?
User avatar
synthsin75
Posts: 9979
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Spliting keyframe dimensions

Post by synthsin75 »

ggoblin wrote: Tue Jul 19, 2022 1:46 am What happens is we call DimensionChannel without first calling SplitDimensions? Shouldn't DimensionChannel implicitly call SplitDimensions?
I assume DimensionChannel just fails. I can't think of any API that automatically invoke another. Kind of like how you have to cast layer type, even after explicitly creating a specific layer type.
ggoblin
Posts: 266
Joined: Wed Jan 19, 2022 2:09 pm

Re: Spliting keyframe dimensions

Post by ggoblin »

synthsin75 wrote: Tue Jul 19, 2022 2:48 am
ggoblin wrote: Tue Jul 19, 2022 1:46 am What happens is we call DimensionChannel without first calling SplitDimensions? Shouldn't DimensionChannel implicitly call SplitDimensions?
I assume DimensionChannel just fails. I can't think of any API that automatically invoke another. Kind of like how you have to cast layer type, even after explicitly creating a specific layer type.
Good point.

In that case perhaps it might be worth documenting this in the description of DimensionChannel that you must first call SplitDimensions(true) otherwise it will fail without error message, and as a result you may see unexpected behaviour in other parts of your script.

https://mohoscripting.com/methods/1170
Post Reply