Auto-sort clips by attributes (weird experimental thing)

This was sort of inspired by 509robotic’s thread about tags for objects, but I wanted to make this a separate thread as it sort of evolved into something else. So you can assign variables to objects to identify them like this:
id="";
object.id=“correct”;

And I was wondering if there’d be a way to check all the clips on a frame, and see which clips had a certain identifier. And then I thought if you could do that, you could automatically sort them into arrays that way. And it turns out you can do that - I wouldn’t describe this as a timesaver because you still have to individually assign attributes to each object but uh, feel free to try it if you’re interested?

Quick project link here, explanation below
auto-array-experiment.wick (2.6 KB)

  • Part 1 - in my frame’s default/load script, I assigned the variables globally as empty strings (you will get an undefined error if you only assign them to objects locally)
    autoarray1

  • Part 2 - For each object, I went to its default script and assigned variables. My file had two clips which were squares and two clips which were circles:
    shapes
    So each one’s default script looked like this:
    autoarray2

  • Part 3 - In the frame’s load tab, I ran this code:
    autoarray3
    This runs through all of the clips on the current frame, checks for what string variables are assigned, and adds clips with those variables assigned to them to arrays accordingly.

I also put two alerts below this to verify the contents of the arrays
autoarray4alerts
alert1 alert2

In this case, it would be way faster to just do this:
allShapes = [red, yellow, green, blue]
circlesArray = [yellow, green]
squaresArray = [red, blue]
…but I can maybe see this being an appealing option if you’re say, assigning a bunch of values to an object? Like maybe you have a character, and you’re assigning attributes based on all kinds of qualities, like height, eye color, hair color, gender, age, occupation etc…maybe in that case, defining those attributes per object and then auto-sorting them into arrays might be easier than doing the sorting yourself?

I dunno, I was just experimenting here. :sweat_smile: Feel free to experiment with this yourself, if you feel you can find a use for it.

1 Like

I read the whole thing, and I think ur experiment was a bit interesting. I never really thought of adding things to an array this way, though it could be useful in helping organize your work, where if u click an object, u can find what u defined it as inside of the object itself! In other words, the object defines itself, which sounds kinda creepy when u put it that way 0_0 …

Thanks for sharing your results : D

1 Like

In hindsight, I guess I should’ve mentioned you can use this code

project.activeFrame.clips.forEach(clip => {
};

to do all kinds of things really. Like, let’s say you have 20 clips in your project, and you want to quickly set the opacity for all of them to 0 to make them not visible. Rather than set the opacity for each of them individually in the inspector, you could do this:

project.activeFrame.clips.forEach(clip => {
clip.opacity=0;
});

And then all of them are instantly not visible. I was just thinking of the tag thing from the other thread, but this is actually kind of useful for lots of other stuff. Might revise the thread title based on that…

1 Like

This makes life way easier :relieved:

1 Like