Page 1 of 1

Scripting : How to get the interpolation values for a cycle?

Posted: Mon Aug 01, 2022 5:54 am
by bbrraayyaann
Hello, I have a question about the class:

AnimChannel:GetKeyInterp(when, interp).

I want to get the val1 and val2
of a loop and store it
the absolute value and relative value
Is it possible to get those values?

I was trying something like this :

Code: Select all

local layer = moho.layer
local interp = MOHO.InterpSetting:new_local()
layer.fTranslation:GetKeyInterpMode(moho.layerFrame,interp)
interp.interpMode = MOHO.INTERP_CYCLE
print("Relative value: " ..interp.val1)
print("Absolute value: " ..interp.val2)

But it does not work
Does not print the correct values
If someone could tell me how to do that ? Thanks

Re: Scripting : How to get the interpolation values for a cycle?

Posted: Mon Aug 01, 2022 10:54 am
by SimplSam
GetKeyInterpMode returns the Interpolation Mode only, and allows you to determine if it is Smooth, Linear, Cycle etc.

You will then need to use GetKeyInterp to get the interp object.

Code: Select all

local keyInterp = layer.fTranslation:GetKeyInterpMode(moho.frame)
if (keyInterp == MOHO.INTERP_CYCLE) then
  layer.fTranslation:GetKeyInterp(moho.frame, interp)
  print("Relative value: " ..interp.val1)
  print("Absolute value: " ..interp.val2)  
end

Re: Scripting : How to get the interpolation values for a cycle?

Posted: Mon Aug 01, 2022 1:00 pm
by bbrraayyaann
SimplSam wrote: Mon Aug 01, 2022 10:54 am GetKeyInterpMode returns the Interpolation Mode only, and allows you to determine if it is Smooth, Linear, Cycle etc.

You will then need to use GetKeyInterp to get the interp object.

Code: Select all

local keyInterp = layer.fTranslation:GetKeyInterpMode(moho.frame)
if (keyInterp == MOHO.INTERP_CYCLE) then
  layer.fTranslation:GetKeyInterp(moho.frame, interp)
  print("Relative value: " ..interp.val1)
  print("Absolute value: " ..interp.val2)  
end
Hi, Thank you very much Sam
I found your answer helpful, I already got the correct values.