How do I clear a channel of a bone?

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
Lukas
Posts: 1294
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

How do I clear a channel of a bone?

Post by Lukas »

How do I clear a specific channel of a bone?

I've specified a bone, and now I want to clear the Scale-channel of just that bone (in a lua function). But...how?
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: How do I clear a channel of a bone?

Post by hayasidist »

from what you say, you have the relevant M_Bone class?

this should do it -- or at least get you in the right direction..

get M_Bone:fAnimScale which is the AnimChannel for scale.

get MohoDoc:EndFrame()

then iterate for when = endFrame until 0
AnimChannel:DeleteKeyByID(AnimChannel:GetClosestKeyID(when)); when = when - 1


hth
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: How do I clear a channel of a bone?

Post by synthsin75 »

User avatar
Lukas
Posts: 1294
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: How do I clear a channel of a bone?

Post by Lukas »

Thanks for the help guys.
synthsin75 wrote:http://mohoscripting.com/index.php?show ... ear&id=419

bone.fAnimScale:Clear(0)
Man, I was staring at that page for an hour, completely clueless on how to do it... Thanks for the example!

The whole time I was looking for something like:

Code: Select all

local channel = bone:getscalechannelsomehow() -- obviously not
channel:Clear(0)
Because here it says Name: "fAnimScale" = Type: "AnimVal" and I didn't realise I could use those AnimChannel methods on it. (:
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: How do I clear a channel of a bone?

Post by hayasidist »

:oops: yeah - totally forgot about clear :oops:
Post Reply