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)
-
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:
So each one’s default script looked like this:
-
Part 3 - In the frame’s load tab, I ran this code:
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
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. Feel free to experiment with this yourself, if you feel you can find a use for it.