Skip to main content
Inspiring
March 4, 2019
Answered

Detect dupplicates

  • March 4, 2019
  • 1 reply
  • 2364 views

Is it possible to know if a light/layer is a duplicate of another one?

My plugin creates some connections to lights, and I want to replicate this connections if a light is duplicated. However, I can't find a way to distinguish between a new light and a duplicate.

This topic has been closed for replies.
Correct answer octaviosa

Thanks for the answer Shachar.

So, I narrowed my issue to lights only. I only need to detect if a light is a duplicate.

I cannot rely on the naming because if I have 2 lights with their default name, and try to duplicate the first one, I'll get a numerical increment on the second, not the first. Also, duplicated or not, the naming number increments sequentially.

I've been thinking about this for a while, and I think I have a solution. Lights have a unique ID, and if I manage to save this ID into some property of the light, once the light is duplicated, this property will also be duplicated and I can look into in on the new light and figure out the original ID of the original light!!

This is all good, except for the fact that lights can't hold any user property. At least I don't know how. So my idea is to store this ID in the alpha channel of the color (since it's not actually used). I need to check it periodically though since I suspect changing the color of the light also resets the alpha channel.

I'm going to try this now and see how it goes.

1 reply

Community Expert
March 5, 2019

meh. kind of.

1. you can parse the liyer name immediately after duplication. it should be

a numerical increment over the original name.

2. if an effect of yours is applied to that layer you can store some GUID

in sequence data during SEQUENCE_SETUP. that call only happens one per

instance, so if 2 instances carry the same GUID one must be a duplicate.

the you can deduce the original from the duplicate by tracking the "last

known location" of each instance during most calls. (i.e. effect index,

layer ID, comp item ID)

that's all i got...

octaviosaAuthorCorrect answer
Inspiring
March 6, 2019

Thanks for the answer Shachar.

So, I narrowed my issue to lights only. I only need to detect if a light is a duplicate.

I cannot rely on the naming because if I have 2 lights with their default name, and try to duplicate the first one, I'll get a numerical increment on the second, not the first. Also, duplicated or not, the naming number increments sequentially.

I've been thinking about this for a while, and I think I have a solution. Lights have a unique ID, and if I manage to save this ID into some property of the light, once the light is duplicated, this property will also be duplicated and I can look into in on the new light and figure out the original ID of the original light!!

This is all good, except for the fact that lights can't hold any user property. At least I don't know how. So my idea is to store this ID in the alpha channel of the color (since it's not actually used). I need to check it periodically though since I suspect changing the color of the light also resets the alpha channel.

I'm going to try this now and see how it goes.

octaviosaAuthor
Inspiring
March 6, 2019

holy c7ap! nice thinking!

i'm not familiar with the unique light id. how can it be acquired? in your

solution, i dear the case where the user changes the color value of the

light and the stored id in the alpha channel is lost.


You can get the ID with the function AEGP_GetLayerID.

And you are right about the change of the color, however, since my plugin is forcibly asynchronous, and I use the IdleHook to sync everything, I'm safe on the color change. This is because once I read the lights to update them in my plugin, I can check if the alpha is less or equal to 1.0, meaning it was reset or it's a new light. In this case I update the alpha with the light ID.

This is a major workaround, but if it works, I'm fine with it