How to get an annotation's position ?
I would like to find the position of an annotation among multi-annotations.
Does someone know if it's possible ?
I would like to find the position of an annotation among multi-annotations.
Does someone know if it's possible ?
"I don't get what you want to say by beeing enable to separate x from y?"
At the moment alert (N
If I want to use the annot's position values, I need to have something like : alert (the X) + alert (theY).
Maybe the solution is simple, but until now I have failed at trying to solve this.
Okey so this is first script on this forum that does such thing! Regarding reverted coordinates they were displayed right way, so like written in binary's. I said that I changed their order but true is I had but forgot, and to your post I was sure I did so
Now it works as it should. That's not only problem with annotations, the other order of coordinates, I noticed it also in other parts like in path(Item)s. But that's other story.
In current 13th line I changed 28 value to 12. That caused (re)moved notes positions could still be read, but that happened in some not specified cases like only 1 note or some custom. Originally I used 28 value as it seemed range of binary characters can't be match of regular expresion's.
I put resultant coordinates into array. They are alerted the sama way, but with chance to match one of them by N
I tested it again. Now it works a little slower (I checked old & new script for the same document). Then it was about 225 ms, now 250). For 1*1*1 document it was 130 ms with one note, but with 100 of them it was not slower for any kind of document, however when I tried it with written annotations, many layer(Sets), channels, paths and big dimmension & resolution it was slower of course, but not much for some reason, just 350 ms ?!
Putting note vertically/horizontally under 0, that is on top/left side of document will give 4294967278, so Math.pow(256, 4)!
function bin(v) {function anno(v) {
var wh = v.match(/(.{4})(.{4})$/)
for(pos = '', i = wh.length - 1; i > 0; i--) {
for(var h = '', b = wh, j = 0; j < b.length; j++) {
if (b
) h += b .charCodeAt().toString(16) }
pos += eval('0x' + h) + ', '
}
return pos.slice(0, -2)
}
notes = [], v.open('r'), v.encoding = 'binary'
var arr = v.read().match(/txtA.{12}/g); v.close()
for(k = 0; k < arr.length; k++) notes.push(anno(arr
)) return notes
}
function sTT(v) {return stringIDToTypeID(v)} function uN() {executeAction(sTT('undoEvent'))}
function dN() {
(ref1 = new ActionReference()).putEnumerated(sTT('annotation'),
sTT('ordinal'), sTT('targetEnum')); (dsc1 = new ActionDescriptor())
.putReference(sTT('null'), ref1), executeAction(sTT('delete'), dsc1, DialogModes.NO)
}
function pHS(v) {
(ref1 = new ActionReference()).putEnumerated(sTT('historyState'),
sTT('ordinal'), sTT('previous')); (dsc1 = new ActionDescriptor()).putReference
(sTT('null'), ref1), executeAction(sTT('select'), dsc1, DialogModes.NO)
}
function dHS() {
(ref1 = new ActionReference()).putProperty(sTT('historyState'),
sTT('currentHistoryState')); (dsc1 = new ActionDescriptor())
.putReference(sTT('null'), ref1), executeAction(sTT('delete'), dsc1, DialogModes.NO)
}
with(psd = new PhotoshopSaveOptions()) {
annotations = !(alphaChannels = embedColorProfile = layers = spotColors = false)
}
if ($.level = 0, documents.length) {try{
(aD = activeDocument).suspendHistory('Notes', '')
for(dN(), pHS(), m = l = 0; l < (Nn = ['N', 'n']).length; l++) {
aD.saveAs(fle = File('~/desktop/.psd'), psd, true)
if (!l || N.length > 1) eval(Nn
+ ' = bin(fle)') !l ? dN() : fle.remove()
}
dHS(); while(typeof n != 'undefined' && N
== n ) m++; alert(N .split(',')) }
catch(err) {uN(), alert('No selected annotation!')}
}
A regex I thought to use for over 8 bits depth documents wouldn't be probably different than I used. I found problem is with sole writing/reading 16 and 32 bits deepth documents with .txt file I had to use to study binary record. With annotations that would not be problem to change deepth to 8 bits for time of script work, but if we had to read binary for other goals for not only 8 bits document then I have no idea how we could do it. I wonder why for so many years noone met this problem on Adobe forums? Once Michael L Hale mentioned "out of memory" issue. I tried to do the same with .tif which can store annotations information but some lines covering bitmap data were too long comparing with psd to be read. Any ideas?
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.