Help with InterpSetting class

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
dstofka
Posts: 12
Joined: Mon Sep 26, 2016 2:38 pm

Help with InterpSetting class

Post by dstofka »

Can anyone offer insight to working with the InterpSetting class? I'm trying to write a tool for myself to be able to apply certain easing settings that I frequently use to selected keyframes with a single tool button click. My stumbling block is in setting Bezier curve parameters ... I know what values the parameters should have but I can't figure out how to apply them to a keyframe using code.

According to the documentation for the AnimChannel class, the SetKeyInterp() method can be called in two ways -- by passing an integer Interpolation Method (like 2 for Ease In/Out) or an instance of the InterpSetting class. The first way works as expected, but in order to set Bezier curve parameters you need to use the second way.

The documentation for the InterpSetting class lists several methods -- SetBezierInAngle(), SetBezierInPercentage(), SetBezierOutAngle(), SetBezierOutPercentage() -- that look to provide the solution but they each require two parameters: component, and angle or percentage. I know what angle and percentage ought to be, but what is the component parameter?
User avatar
hayasidist
Posts: 3525
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Help with InterpSetting class

Post by hayasidist »

it's been a while since I used this, but IIRC, "component" has meaning in an anim channel that has multiple dimensions -- so x, y, z in a Vec3 are the components (and I can't recall if they are referred to as 1,2,3 or 0,1,2)

hope that at least moves you forward.

(oh - and when you find out, please let me know and I'll update the scripting website with "the answer"!)
User avatar
synthsin75
Posts: 9978
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Help with InterpSetting class

Post by synthsin75 »

Yeah, the component is the axis, starting from 0 (I checked some of my previous scripting).
User avatar
hayasidist
Posts: 3525
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Help with InterpSetting class

Post by hayasidist »

oh yeah -- eventually dug out one of my old scripts ... as Wes says - x is 0 etc.

There are constants defined for the axes: LM.X_AXIS, LM.Y_AXIS, LM.Z_AXIS which should "future-proof" your script just in case the axis numbers ever change (it's very rare but not unknown for "constants" to be different in different Moho version)
dstofka
Posts: 12
Joined: Mon Sep 26, 2016 2:38 pm

Re: Help with InterpSetting class

Post by dstofka »

Thanks for the insight! Setting that parameter to 0|1|2 did the trick. (Now I have a new InterpSetting question, somewhat related but different enough to merit a new thread....)
Post Reply