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

General Moho topics.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
bbrraayyaann
Posts: 69
Joined: Thu Jan 24, 2019 3:52 am

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

Post 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
User avatar
SimplSam
Posts: 1218
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

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

Post 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
Moho 14.3 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.3 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
bbrraayyaann
Posts: 69
Joined: Thu Jan 24, 2019 3:52 am

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

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