Bake Bones Script

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
dkwroot
Posts: 677
Joined: Thu May 02, 2013 6:56 am
Location: USA
Contact:

Bake Bones Script

Post by dkwroot »

WHAT DOES THIS SCRIPT DO?
This script will bake the point motion from a bone layer onto a mesh. This allows the user to create motions and blends of motions using bones and then bake those alterations to keyframes on the vector layer.

HOW DO I USE IT?
Simply activate the script from the script menu and choose the interval you wish to bake to. The script will do the rest. Be aware that the script can take a while if there is a lot of point motion to bake.

DOWNLOAD: n/a

EDIT:
I greatly improved the speed of the script.
Last edited by dkwroot on Sat Oct 02, 2021 1:40 pm, edited 1 time in total.
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Re: Bake Bones Script

Post by funksmaname »

COol! thanks as always :)
I've not tried yet - is there an option to just 'bake current frame'? that could be useful too!
Keep up the good work mate.
dkwroot
Posts: 677
Joined: Thu May 02, 2013 6:56 am
Location: USA
Contact:

Re: Bake Bones Script

Post by dkwroot »

No, it bakes all frames. Keyframes that aren't needed can be deleted manually.
User avatar
funksmaname
Posts: 3174
Joined: Tue May 29, 2007 11:31 am
Location: New Zealand

Re: Bake Bones Script

Post by funksmaname »

very true :)
User avatar
synthsin75
Posts: 9935
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Bake Bones Script

Post by synthsin75 »

Hayasidist has one to bake current frame only.
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Bake Bones Script

Post by hayasidist »

it's here ... http://www.mediafire.com/file/374qob23a ... s_bake.lua It does all (well most!) transforms on vector layers - bone motion / layer motion / shape order ...

It's been around since 11.1 - read about it here: http://www.kelleytown.com/forum/animato ... hichpage=2
and here http://lostmarble.com/forum/viewtopic.p ... 6&p=170901
chucky
Posts: 4650
Joined: Sun Jan 28, 2007 4:24 am

Re: Bake Bones Script

Post by chucky »

Pretty, pretty, pretty cool.
Broughtvulture
Posts: 3
Joined: Wed Jun 14, 2017 6:34 am

Re: Bake Bones Script

Post by Broughtvulture »

hayasidist wrote:it's here ... http://www.mediafire.com/file/374qob23a ... s_bake.lua It does all (well most!) transforms on vector layers - bone motion / layer motion / shape order ...

It's been around since 11.1 - read about it here: http://www.kelleytown.com/forum/animato ... hichpage=2
and here http://lostmarble.com/forum/viewtopic.p ... 6&p=170901
I've tried out and really likef both the dr_bake bones & hs_bake, but it would be better if they had shared one another's features. It would be a real time saver if the dr_bake_bone stored layer translation information, which the hs_bake does; but none the less hs_bake would be better with the option to bake all frames rather than only the one frame.

I'll keep watch if there are any future updates on these scripts. Thanks again for the time saving scripts.
Ahroo
Posts: 41
Joined: Sat Jun 11, 2011 7:53 pm

Re: Bake Bones Script

Post by Ahroo »

OK, at the risk of sounding like a complete idiot....what does "baking" mean? How is that different from freezing? What does it actually do? Thanks!
Broughtvulture
Posts: 3
Joined: Wed Jun 14, 2017 6:34 am

Re: Bake Bones Script

Post by Broughtvulture »

It's all good, I didn't know what the term meant in terms of 2D animation; until I checked out these cool scripts.

In terms of these scripts, baking means to transfer all the position, rotation, and scale points from a parent layer such as a folder or bone and combine the frames into the vector layer itself. Meaning the vector layer can now become independent of the bone or folder layer it was once stored in while still inheriting the properties of movement it had while it was still within the folder or bone layer.

Here is an example, just for further clarification. A vector layer is within a folder, you move the folder layer's position. This automatically moves the vector layer's position. If you bake the vector layer, using the hs_bake script it will store the folder layer's movement info into the vector layer. If you don't bake it, but move the vector layer out of the folder layer; your vector layer would not keep the folder layer's movement changes.

Hope that helps you understand what the scripts do. These scripts have really made Moho 12.2 a better and more reliable program for me to use. It has made me more interested in scripting, so hopefully I can find out how they did this and share it.
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Bake Bones Script

Post by hayasidist »

Ahroo wrote:OK, at the risk of sounding like a complete idiot....what does "baking" mean? How is that different from freezing? What does it actually do? Thanks!
freeze = add keyframes for all the movable things so, when you move them later in the timeline, they start moving from the "freeze" position not some previous key frame.

(e.g. you have a shape with four points -- on frame 5 you move 2 of them; on frame 10 you move the other 2. If you haven't done anything else all the points start moving from frame 1. But if at frame 5 you "freeze" all the points, the second two points start moving at frame 5)


(my) bake = create a copy with no keyframes and with all the motion captured in a "frame 0" design.

The basis of my idea is to create a handoff between "traditional" moho animation (bones etc) and frame by frame -- IOW rig your character - move it using bones etc; then you need some motion where doing it fbf is "easier" (e.g. you need to change the view from face-on to looking down on the top of their head) so bake the vectors at the end of the "traditional" action to create the starting layers for an fbf sequence ...

Broughtvulture wrote:hs_bake would be better with the option to bake all frames rather than only the one frame
... interesting idea -- in effect turn traditional into an fbf sequence?!.. I'll keep it in mind...

But if you're heading into the realms of scripting, you might like to try a script that does something along the lines of:

for frame = 1 to MohoDoc:AnimDuration() do
> set timeline to frame (see http://www.mohoscripting.com/index.php? ... face&id=47)
> call bv_bake_noUI
end

and create bv_bake_noUI from hs_bake taking out the UI and defaulting to (say) current camera...
Broughtvulture
Posts: 3
Joined: Wed Jun 14, 2017 6:34 am

Re: Bake Bones Script

Post by Broughtvulture »

hayasidist wrote: ... interesting idea -- in effect turn traditional into an fbf sequence?!.. I'll keep it in mind...
Fbf sequence, yeah; Also I'm assuming all the frames will be within the same layer.

Although this isn't really an issue for me; I think this would improving Moho. It would make things more organized, since after finishing an animation you can reduce the file size by minimizing the amount of layers within the file down to just vectors. But in all honesty, I'm using it as a method of masking(hiding overlapping layers) so I don't have to trace what I need to not show or duplicate an entire folder with bones and stuff just to hide parts that overlap.
hayasidist wrote:But if you're heading into the realms of scripting, you might like to try a script that does something along the lines of:

for frame = 1 to MohoDoc:AnimDuration() do
> set timeline to frame (see http://www.mohoscripting.com/index.php? ... face&id=47)
> call bv_bake_noUI
end

and create bv_bake_noUI from hs_bake taking out the UI and defaulting to (say) current camera...
This is technically my 3rd day and I'm kind of getting the hang of scripting, but things like UIs, Matrix, Dialog boxes, as well as some other stuff not concerning layers or meshes are still beyond me. I wish I could, but I can't even break down your code and figure out how your able to select the folder/bone layer based on the vector layers position.

I'm kind of nervous about messing with the script, so I decided to create a whole new script. I'm currently trying to find out how to select the vector's parent layer, so far the LayerByAbsoluteID keeps selecting the wrong layer and type. But I'll stop here, since this thread is more about the scripts and not really how to make them.

Either way, it's pretty cool to get your input on it. Should I make a new thread for this type of help?
User avatar
hayasidist
Posts: 3492
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Bake Bones Script

Post by hayasidist »

Broughtvulture wrote:Either way, it's pretty cool to get your input on it. Should I make a new thread for this type of help
yeah! and maybe do a search of scripting and/or the unofficial (but better than the stuff that comes with the s/ware) scripting docs: http://www.mohoscripting.com/index.php to see about parent layers -- e.g. http://www.mohoscripting.com/index.php? ... ent&id=499 -- before you post the next question ! :wink: :)
dkwroot
Posts: 677
Joined: Thu May 02, 2013 6:56 am
Location: USA
Contact:

Re: Bake Bones Script

Post by dkwroot »

If you're new to scripting with Moho, I'd suggest checking out the scripts recipes thread. Users have shared solutions to a lot of redundant tasks that often appear in coding.

viewtopic.php?f=12&t=30605
Post Reply