• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Is there any way to find out if the contents of a layer have been edited?

Engaged ,
Oct 11, 2011 Oct 11, 2011

Copy link to clipboard

Copied

Hii..

I wanted to find out whether the contents of a layer have been edited or not since its creation.. I am not looking for a solution where checks are made after the last modified document.. Lets look at a scenario where a document is not saved.. Then, in that case how can we find that a layer has been altered since it has been opened..?? Please guide me..

Thanks..

P.S: I need to compare between two states of a layer. For eg, when I trigger my plugin to create a document, it opens a document from a specified path. It contains a  layer whose editability is to be traced. Now, the scope of my plugin ends... The user is free to do any editing on the document, but is forbidden to edit that specific layer, but nobody can stop the user..!!

Now, I trigger my plugin again, and I check whether that layer has been edited or not... Now, can anyone guide me..?? Since, the scope of my plugin ends after document creation, so I am unable to retain any values for post-check..

TOPICS
SDK

Views

854

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Oct 11, 2011 Oct 11, 2011

There's no way to tell after the fact if a layer has been altered. Even noticing when a user does it at the moment they do it is tricky; you'd have to rely on something like the kArtPropertiesChangedNotifier, and that's a little dicey. You could check when that notifier comes in to see what art is selected and see if any of it is on your layer, but there'd be some holes in it. A delete, for example, would probably happen before that notifier so you'd never see that art on your layer is deleted (

...

Votes

Translate

Translate
Adobe
Guide ,
Oct 11, 2011 Oct 11, 2011

Copy link to clipboard

Copied

There's no way to tell after the fact if a layer has been altered. Even noticing when a user does it at the moment they do it is tricky; you'd have to rely on something like the kArtPropertiesChangedNotifier, and that's a little dicey. You could check when that notifier comes in to see what art is selected and see if any of it is on your layer, but there'd be some holes in it. A delete, for example, would probably happen before that notifier so you'd never see that art on your layer is deleted (since its no longer selected, because its gone).

In general, tracking changes to art is pretty much impossible I'm afraid

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 11, 2011 Oct 11, 2011

Copy link to clipboard

Copied

If you don't want them to alter art on your layer, you could lock it and then catch the kLayerPropertiesChangedNotifier. When that's triggered, you could see if your layer is unlocked and if so, lock it again. That should make it permanently locked. It won't prevent them from deleting it of course, but it might prevent them from altering it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 20, 2011 Oct 20, 2011

Copy link to clipboard

Copied

Hii..

I followed your advice and used the notifier to detect whether my layer is being un-locked or not, and if it is then lock it again.. But, there is a serious loophole in this too.. If I open another document and copy an art, and paste it to the previous document, which contains my locked layer (and my layer is selected), then Illustrator shows a prompt "You are attempting to post or drag into one or more layers that are locked or hidden. Do you want to unlock and show all layers?" If the user clicks "Yes", then the layer is unlocked & the art is pasted successfully. How do I go about preventing this? Here are some screenshots.

1.JPG

2.JPG

Please guide me..

Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 20, 2011 Oct 20, 2011

Copy link to clipboard

Copied

LATEST

Yikes. Well, the only thing I can think of would be to keep a list of the art you know is on your layer and anytime you get the kArtPropertiesChangedNotifier, check to see if the count of art on your locked layer is the number you think it should be. If not, then iterate over it and kill anything not in your list of 'known' art. Combine this maybe with a check that looks to see if your layer has become somehow unlocked when it shouldn't be to speed things up. You could also use the opportunity to relock the layer.

If not that, I'm not sure. Perma-locking a layer isn't exactly something the Illustrator was looking to let people do frankly.

Hmmm. As an alternate possibility -- and this may not work for you -- if you just need to keep some collection of art untouched by the user and it doesn't absolutely have to be a layer that contains them, you could look at kPluginArt (AIPluginArt.h). That's basically custom art in which you can put pretty much whatever you want. So you'd be in complete control of what goes in there, and how it gets edited. Just a stray thought if the layer stuff doesn't work out though.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines