Sort layers?
Moderators: Víctor Paredes, Belgarath, slowtiger
Sort layers?
Can I sort layers in order based on layer names?
Can I change layer orders at all using lua?
I had Janimatics "import directory"-script sort the layers pretty good, only thing was that it changed place of the first and middle-layers, but something strange must have happened. Now when I use the script all layers gets all jumbled up with no order what so ever...
Also I can't get his image-sequence-script to work at all...
The only way I can import the layers in order is by drag and drop, but then I get that f***ing stupid "Tracing image/New Image Layer"-dialog for each and every one of the layers. (LM -why have you put that dialog there, what purpose does it fill?)
Can I change layer orders at all using lua?
I had Janimatics "import directory"-script sort the layers pretty good, only thing was that it changed place of the first and middle-layers, but something strange must have happened. Now when I use the script all layers gets all jumbled up with no order what so ever...
Also I can't get his image-sequence-script to work at all...
The only way I can import the layers in order is by drag and drop, but then I get that f***ing stupid "Tracing image/New Image Layer"-dialog for each and every one of the layers. (LM -why have you put that dialog there, what purpose does it fill?)
Currently the animated layer ordering has no script interface. Until script access is added there really isn't a way to script this feature.
Are you saying animatic's "import directory" script use to work properly but now it doesn't? It could be the new layer ordering feature is effecting it. Where is that script? I could take a look at it. Also the image sequence script. If there is a dialog/alert popping up then that can be commented out if it isn't needed. Is this the same script as the one that brings in image sequences into switch layers included with AS? I don't get that error.
Additionally changing layer order on frame 0 AFTER you have animated the layer order on other frames may or may not cause reordering problems. The animated layer ordering is based I believe on frame 0. So changing frame 0 layer order would potentially effect the animated ordering on later frames. I have figured this out 100% yet.
-vern
Are you saying animatic's "import directory" script use to work properly but now it doesn't? It could be the new layer ordering feature is effecting it. Where is that script? I could take a look at it. Also the image sequence script. If there is a dialog/alert popping up then that can be commented out if it isn't needed. Is this the same script as the one that brings in image sequences into switch layers included with AS? I don't get that error.
Additionally changing layer order on frame 0 AFTER you have animated the layer order on other frames may or may not cause reordering problems. The animated layer ordering is based I believe on frame 0. So changing frame 0 layer order would potentially effect the animated ordering on later frames. I have figured this out 100% yet.
-vern
I'll get you the scripts tomorrow.
It's not the animatable layer order I'm after, it's just the possibility to arrange the layers (in frame 0).
The animatable layer order thing is very unstable in my opinion, it leads to all kinds of trouble. Serious trouble as well, the ones which makes you having to reload the scene or even restart AS. Suddenly inability to move layers outside groups, timeline freezes up (I'm pretty sure it's related) and so forth.
I think it's way to unstable to have been included in the first place. If I would have backward compatibility with 5.5 I would have gone back to that one.
It's not the animatable layer order I'm after, it's just the possibility to arrange the layers (in frame 0).
The animatable layer order thing is very unstable in my opinion, it leads to all kinds of trouble. Serious trouble as well, the ones which makes you having to reload the scene or even restart AS. Suddenly inability to move layers outside groups, timeline freezes up (I'm pretty sure it's related) and so forth.
I think it's way to unstable to have been included in the first place. If I would have backward compatibility with 5.5 I would have gone back to that one.
Here's janimatics scripts if you want to have a look.
Are there any access to layer ordering through lua at all (not specifically animatable)?
http://www.rylanderanimation.se/temp/JS ... cripts.zip
Are there any access to layer ordering through lua at all (not specifically animatable)?
http://www.rylanderanimation.se/temp/JS ... cripts.zip
Animated layer order works correctly. You can only move layers outside of groups on any frame other than 0 because that can't be animated. If you want to move a layer outside of a bone or group layer you must be on frame 0.
As for the other problems you mentioned... I just did about 4 minutes of animation using animated layer ordering extensively without one single problem or crash. It worked PERFECTLY and saved me hours of work. It was great. It does require a bit of getting use to and understanding of how it works but after a while it makes sense.
The key is to remember that it isn't based on the name of the layer. The layer order is based on layer ID. If you move layers around on frame 0 or add new layers or delete layers it could mess up your layer ordering keys.
What I did was to do the layer ordering ONLY at the very end when everything else was correct and I knew I would not be adding or deleting layers.
When doing animated layer ordering always put a key on frame 1 or the start of the animation. If you don't, any changes to layer order on frame 0 will change the layer order up to the first layer order key. If that isn't frame 1 then the order will change from there till the next key.
------
I'll take a look at those scripts when I get a chance. The problem with sorting layers by name is that there is no script interface for that. There is no "layer order" member function. You have to parse all the layers individually creating a table indexed by the "old" order and then sort the names then change the order... <sigh>. I've never encountered a situation where I needed to do that. I am going to be blunt here and say it just isn't worth the effort for me. Layer order for me is based on WHAT the layer is not the name.
-vern
As for the other problems you mentioned... I just did about 4 minutes of animation using animated layer ordering extensively without one single problem or crash. It worked PERFECTLY and saved me hours of work. It was great. It does require a bit of getting use to and understanding of how it works but after a while it makes sense.
The key is to remember that it isn't based on the name of the layer. The layer order is based on layer ID. If you move layers around on frame 0 or add new layers or delete layers it could mess up your layer ordering keys.
What I did was to do the layer ordering ONLY at the very end when everything else was correct and I knew I would not be adding or deleting layers.
When doing animated layer ordering always put a key on frame 1 or the start of the animation. If you don't, any changes to layer order on frame 0 will change the layer order up to the first layer order key. If that isn't frame 1 then the order will change from there till the next key.
------
I'll take a look at those scripts when I get a chance. The problem with sorting layers by name is that there is no script interface for that. There is no "layer order" member function. You have to parse all the layers individually creating a table indexed by the "old" order and then sort the names then change the order... <sigh>. I've never encountered a situation where I needed to do that. I am going to be blunt here and say it just isn't worth the effort for me. Layer order for me is based on WHAT the layer is not the name.
-vern
Yes, but layer order can be quite synonymous with what it's name is. Say a sequence of layers; image01, image02, image03 etc to a couple of hundred. If they are supposed to be in sequence and are imported in a great jumble I at least are not pleased with all the extra work of getting them in order.heyvern wrote:...You have to parse all the layers individually creating a table indexed by the "old" order and then sort the names then change the order... <sigh>. I've never encountered a situation where I needed to do that. I am going to be blunt here and say it just isn't worth the effort for me. Layer order for me is based on WHAT the layer is not the name.
So or me the work of writing such a script would be valuable, I just need some tips on where to start. I've figured that I need to parse the layers and order them based on that. But how do I order them based on the list? That is what I'm asking about.
If you use the image sequence script that comes with AS it brings in those layers in order into a switch layer. I've used that before and if I don't want them in a switch I change the switch layer to a bone or group layer using a text editor.
I agree... no way I would reorder layers by hand if I had like a hundred of them. Yikes. I would use the image sequence import script.
Like I said... it just hasn't come up as a need for me yet. That is usually what motivates me to work on a script. A desperate need for it. I don't really use images that way.
-vern
I agree... no way I would reorder layers by hand if I had like a hundred of them. Yikes. I would use the image sequence import script.
Like I said... it just hasn't come up as a need for me yet. That is usually what motivates me to work on a script. A desperate need for it. I don't really use images that way.
-vern
No, but is it possible? I'm not asking you to write the script, I'm asking for a tip in the right direction so I can write the script.heyvern wrote:..
Like I said... it just hasn't come up as a need for me yet. That is usually what motivates me to work on a script. A desperate need for it. I don't really use images that way.
My first tip would be to read the Moho Scripting Reference from top to bottom. Look at any script that works with layers. It might be possible. I haven't played with layer ordering in scripting since the new animated layer ordering feature was added.No, but is it possible? I'm not asking you to write the script, I'm asking for a tip in the right direction so I can write the script.
Do you want to "reorder" the layers on the time line? Other than frame 0? I'm not sure how that would work with this new feature. I think you might have to parse the file format to find the new "layer order" key frames.
If all you want to do is reorder the layers on frame 0 and you don't care about the "old order" or animated layer order key frames, then you could probably start here in the Moho Scripting reference under Reference|MOHO|Classes|MohoLayer
That section has all the member functions and properties for layers. Unfortunately there is nothing in there about layer order.
So then look under: Reference|MOHO|Classes|ScriptInterface
This section has the script interface access for doing things to the file like changing layer order.
There is a member function:
Code: Select all
PlaceLayerBehindAnother(moveLayer, behindThis)
Moves one layer behind (or below) another in the layer ordering.
Return value: none
moveLayer (MohoLayer): layer to move
behindThis (MohoLayer): layer to place it behind
If you plan to only change the order and not worry about the original order or animated ordering you should be ok just parsing the layer list:
Code: Select all
local layerCount = moho.document:CountLayers()
for i=0, layerCount - 1 do
.... do stuff here
end
To count layers inside a group or bone layer you would have to use:
moho.layer:CountLayers()
I'm writing this by the seat of my pants. I know I've probably oversimplified and made some mistakes. I am skipping over bits. Basically use the script reference. I don't know how much knowledge you already have with lua and AS but that is my only resource for all of this stuff. Study that script reference. And study lua.
Basically I stopped doing anything with scripting and layer ordering. It was such a pain. You can't keep track of layer order very easily. Once it changes there is no reference to the old order. You can't change a layer directly by using its name and if you change the order of layers the ID changes.
-vern