Getting Bezier Handle Values from Keys

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
GaryC
Posts: 53
Joined: Tue Feb 03, 2015 1:02 pm

Getting Bezier Handle Values from Keys

Post by GaryC »

We have a script for nudging keys that was originally written by Rudiger (rt_). It was written before Anime Studio 10, and when it's used on keys with bezier curves it doesn't retain the position of the bezier handles, they revert to defaults. I assume this is because the command used for getting bezier information doesn't actually get all the information necessary when setting a new key.

This is currently what it uses:

Code: Select all

channel:GetKeyInterp(frame, interp_mode, val1, val2)
Is there a similar command available to get all the bezier data from a key in the newer versions?
User avatar
hayasidist
Posts: 3528
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Getting Bezier Handle Values from Keys

Post by hayasidist »

check the pkg_moho file that's in the "extra files/Lua Scripting" zip.. I think you'll need the InterpSetting class.
GaryC
Posts: 53
Joined: Tue Feb 03, 2015 1:02 pm

Re: Getting Bezier Handle Values from Keys

Post by GaryC »

Aha, I did indeed find it

Code: Select all

class InterpSetting {

        ...

	real BezierOutAngle(int32 component);
	void SetBezierOutAngle(int32 component, real angle);
	real BezierInAngle(int32 component);
	void SetBezierInAngle(int32 component, real angle);
	
	real BezierOutPercentage(int32 component);
	void SetBezierOutPercentage(int32 component, real percent);
	real BezierInPercentage(int32 component);
	void SetBezierInPercentage(int32 component, real percent);
But I'm a little unclear with how I'd get access to an instance of the class to actually use those methods? As far as I can see there isn't a method to use on the animation channel to get it to provide me with each InterpSetting object. The settings being accessed so far were with a method built into the animation channel itself.

Is this something I'd need to edit into the actual moho_pkg to make it work?
User avatar
hayasidist
Posts: 3528
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Getting Bezier Handle Values from Keys

Post by hayasidist »

I'm in the realms of guesswork here, but I think you'll need to

get the animation channel

then

local interp = MOHO.InterpSetting:new_local()

channel:GetKeyInterp(moho.frame, interp) will populate interp

and

angle = interp:BezierOutAngle()

etc should give you access to the data you need...

BUT, I am guessing, so please let me know how you get on!
GaryC
Posts: 53
Joined: Tue Feb 03, 2015 1:02 pm

Re: Getting Bezier Handle Values from Keys

Post by GaryC »

Ah, you were right! That has given me access to the InterpSetting object. Now I just need to make sense of the BezierInAngle parameter and return value. Thanks!
Post Reply