Skip to main content
FLEB9612440
Participant
January 4, 2013
Question

Uniquely identifying layers, even with the same name, or after changing names

  • January 4, 2013
  • 1 reply
  • 1170 views

I'm sure many have tried it, but I'm taking a crack at the ol' "Get Layer Comps working in Illustrator (CS5.5)" script. The one thing that I'm currently unsure of, though, is how to uniquely identify each layer in a way that I can serialize. Currently, I'm writing an XML sidecar file, though I'll probably add an option for XMP tags once I know it works.

Anyhow my problem: As far as I can tell, there's no sort of internal identifier that I can access, short of the name-- which has the problem that it's not unique, and it doesn't stick if you change the name.

Barring an actual unique-ID, I did have one tricky idea up my sleeve-- I could use the layer selection color as a fallback. Before generating a snapshot for the first time, I could subtly tweak the RGB values for all the layer selection colors-- just one or two degrees, so they're all unique, and not the presets. Then, when I load in snapshots, I can use those RGB values as a secondary verifier, if there are unknown layers, or if there are two layers with the same name.

EDIT:

Actually, I just realized that wouldn't work. If you copy the layer, it retains the unique color. So, I think that barring an actual unique-ID tag I don't know about, I might just offer the option of either requiring uniqueness and never changing, or tagging layer names with an ID.

This topic has been closed for replies.

1 reply

CarlosCanto
Community Expert
Community Expert
January 4, 2013

no unique ID's for anything including layers, what are we talking about? what are all possible scenarios in your project? do layers need to get randomly rearranged? deleted? added? if yes to any of those we out of luck, unless there's "something" in the art itself that can get married to a specific layer

Inspiring
January 4, 2013

For everything except containers ( layers & groups ) you can store your inique IDs in the tags array… If you need to track containers place a non-printing/visible object inside and track that… getting it's parent object should be easy enought… As far as I can recall tags is a script thing so it should be safe to use. Your tag can have both name to find and a value… This is how I track stuff if needed…

Edit. That was off the top of my head… and of cause probably incorrect… groupItem should inherit the tags property from pageItems like the other objects…

CarlosCanto
Community Expert
Community Expert
January 4, 2013

I thought if you copy objects via UI, its tags get copied too, that's from the top of my head too, I can't test it right now.