Animate Shape Stack Order
Moderators: Víctor Paredes, Belgarath, slowtiger
-
- Posts: 11
- Joined: Sun Dec 03, 2006 2:15 am
Animate Shape Stack Order
The script:
http://www.poetbeware.org/stack.lua
An example file:
http://www.poetbeware.org/000.anme
How to use it:
You must set up a switch layer with the same name as your vector layer and a " Stack" suffix. So, in the example file, I have a "Humanoid" layer whose shape order I want to animate, so I created a "Humanoid Stack" switch layer for the script to find.
The sublayers in the switch layer have names that are actually list of shape names. So if you select the "Humanoid" layer and pull down its Shapes button, you'll see: L_Arm, R_Arm, Body, L_Leg and R_Leg.
Note that the switch sublayers are named:
L_Arm,R_Leg,Body,R_Arm,L_Leg,
R_Arm,L_Leg,Body,L_Arm,R_Leg,
Those names indicate the order you want the shapes to go in, from bottom to top. You don't have to list every shape; shapes that are not listed will not have their ordering changed.
Then, to animate the order, just set keyframes on the switch layer to set the order you want. Next, attach the stack.lua script to the original layer (the Humanoid layer in the example).
And done!
How it works:
It parses the currently open .anme file to find the names of the shapes. It then associates those names with the actual Shape objects in memory. From there it's easy: The script just finds the currently active switch sublayer, parses that sublayer's name, and moves those shapes into the correct order.
IMPORTANT CAVEATS:
This will only work if you do not rename your original layer, the switch Stack layer, or any of the shapes!
If you add or delete a shape, that should be fine, but you will have to save, close and re-open your file so that my script can re-load the shape names.
The switch sublayer names must not contain any spaces in them; each shape name must be separated by a comma; and there MUST be a comma at the very end of the name.
I only tested with Anime Studio Pro 5.5 on OS X. Please let me know if it works for you...
http://www.poetbeware.org/stack.lua
An example file:
http://www.poetbeware.org/000.anme
How to use it:
You must set up a switch layer with the same name as your vector layer and a " Stack" suffix. So, in the example file, I have a "Humanoid" layer whose shape order I want to animate, so I created a "Humanoid Stack" switch layer for the script to find.
The sublayers in the switch layer have names that are actually list of shape names. So if you select the "Humanoid" layer and pull down its Shapes button, you'll see: L_Arm, R_Arm, Body, L_Leg and R_Leg.
Note that the switch sublayers are named:
L_Arm,R_Leg,Body,R_Arm,L_Leg,
R_Arm,L_Leg,Body,L_Arm,R_Leg,
Those names indicate the order you want the shapes to go in, from bottom to top. You don't have to list every shape; shapes that are not listed will not have their ordering changed.
Then, to animate the order, just set keyframes on the switch layer to set the order you want. Next, attach the stack.lua script to the original layer (the Humanoid layer in the example).
And done!
How it works:
It parses the currently open .anme file to find the names of the shapes. It then associates those names with the actual Shape objects in memory. From there it's easy: The script just finds the currently active switch sublayer, parses that sublayer's name, and moves those shapes into the correct order.
IMPORTANT CAVEATS:
This will only work if you do not rename your original layer, the switch Stack layer, or any of the shapes!
If you add or delete a shape, that should be fine, but you will have to save, close and re-open your file so that my script can re-load the shape names.
The switch sublayer names must not contain any spaces in them; each shape name must be separated by a comma; and there MUST be a comma at the very end of the name.
I only tested with Anime Studio Pro 5.5 on OS X. Please let me know if it works for you...
Hey, it works for me. I'm on Mac OS X 10.3.9.
That is some nice piece of code hacking, poetbeware! And I like the idea of storing data in layer names within a switch.
Another way to store data would be with notes (layer_type 7). At the end of the note layer is this piece of code:
Of course, the text between quotation marks was written by me. It code have been written by a script as well. A nice way to store your permanent script data for a document as string data. You simply store the document, read the document in, change the note_text and write the document back.
That is some nice piece of code hacking, poetbeware! And I like the idea of storing data in layer names within a switch.
Another way to store data would be with notes (layer_type 7). At the end of the note layer is this piece of code:
Code: Select all
### note layer values
note_text "This is a nice piece of code!"
-
- Posts: 11
- Joined: Sun Dec 03, 2006 2:15 am
Thanks!That is some nice piece of code hacking, poetbeware!
I thought it wasn't possible to write note text via script. See this thread. Do you know what the API for notes is?And I like the idea of storing data in layer names within a switch.
Another way to store data would be with notes (layer_type 7). At the end of the note layer is this piece of code:
Of course, the text between quotation marks was written by me. It code have been written by a script as well.Code: Select all
### note layer values note_text "This is a nice piece of code!"




PS: Ah, and I think Rasheed could be refering to store some data on Note Layers "by hand" that can be searched and extracted/read directly from de *.anme file by a Layer Script as you did with the Shape names instead use for it some (cause it doesn't exist yet) Moho function, anyway Switch Layers always can bring us much more possibilities as we can see...
EDIT: ...EY! For some reason it works now!!! And now I'm EVEN more excited than before!



Great script! everything works except the ordering, in my test the ordering is not working, I have three shapes named: "red", "yellow" and "blue", I have 3 vector layers inside the switch layer each with different ordering like you said, for instance: layer 1 named: red,blue,yellow, layer 2 named:yellow,red,blue etc. the ordering changes but it doesn't have the right order, have I missed something, maybe I'm doing something wrong?
I'm using ASPro v.5.5 on a mac osx 10.4.8
I'm using ASPro v.5.5 on a mac osx 10.4.8
-
- Posts: 11
- Joined: Sun Dec 03, 2006 2:15 am
Here's the .anme file I'm using, thanks for checking this out very kind of you!
http://www.musikboden.se/animestudio/fo ... cking.anme
http://www.musikboden.se/animestudio/fo ... cking.anme
-
- Posts: 11
- Joined: Sun Dec 03, 2006 2:15 am
Yeah, that is very weird. Definitely not working as advertised. I'll take a longer look at it tomorrow.
Also, anyone who's using the script: I notice that if I load my example and just leave it playing in a loop for a while, for some reason it eventually stops working. So I'll look into that too. May be related...
Also, anyone who's using the script: I notice that if I load my example and just leave it playing in a loop for a while, for some reason it eventually stops working. So I'll look into that too. May be related...
No, and I thought there were functions to save and load the current document, but there aren't. If there were, you could save the document, read it as a text file, add the note text, save the text file back to disk, and reload that file as an AS document. Alas, this doesn't work.poetbeware wrote:I thought it wasn't possible to write note text via script. See this thread. Do you know what the API for notes is?Another way to store data would be with notes (layer_type 7). At the end of the note layer is this piece of code:Of course, the text between quotation marks was written by me. It code have been written by a script as well.Code: Select all
### note layer values note_text "This is a nice piece of code!"
I wonder if the menu functions are accessible through scripting, IOW if these are stored somewhere in the _G environment table. This would open a whole new world of opportunities and workarounds, even if those menu functions aren't accessible through an API, because you could simply hack your own API.
-
- Posts: 11
- Joined: Sun Dec 03, 2006 2:15 am
Hi magicwand,magicwand wrote:Hi poetbeware,
Would it be possible to add the layer whose shape order have to animated be stored under a bone layer.
As in the current set-up one can only do point animation.
The script should work regardless what the parent layer is. You just have to make sure the " Stack" layer appears under the same parent. Eg:
Code: Select all
+ Skeleton
---+ Humanoid
---+ Humanoid Stack
------+ L_Arm,Body,L_Leg
------+ R_Arm,Body,R_Leg
poetbeware wrote: Hi magicwand,
The script should work regardless what the parent layer is. You just have to make sure the " Stack" layer appears under the same parent. Eg:
...though I haven't actually tested this, it should work. Give it a shot and let me know...Code: Select all
+ Skeleton ---+ Humanoid ---+ Humanoid Stack ------+ L_Arm,Body,L_Leg ------+ R_Arm,Body,R_Leg
Thanks you poetbeware,
I works perfect, This is a really cool script
