On 5 Sep 2014, at 6:55 pm, Dave <email@hidden> wrote:
Well, you got lucky or you version of PS is different. I’m seeing -1’s, -2’s etc and one case where everything seemed to be based around 31!
No, I get the same with CS6.
(Dave sent me the document off-list.)
The problem is that you failed to mention that there are several other layers in that document, and it looks like you're getting the bounds of the wrong ones (the ones in the ViewConfig layer set).
If I change my code to allow for the fact that you have all layers enclosed in layer sets:
tell application id "com.adobe.Photoshop" set theBounds to bounds of art layers of layers of document 1 set x to art layers of layers of document 1 end tell log theBounds repeat with i from 1 to count of theBounds set item i of theBounds to my cocoafy(get item i of theBounds) end repeat return theBounds
on cocoafy({x1, y1, x2, y2}) return {x1, y1, x2 - x1, y2 - y1} end cocoafy
I get:
{{0.0, 0.0, 20.0, 20.0}, {20.0, 0.0, 20.0, 20.0}, {0.0, 20.0, 20.0, 20.0}, {20.0, 20.0, 20.0, 20.0}, {4.0, -5.0, 299.0, 58.0}, {4.0, -5.0, 299.0, 58.0}, {4.0, -5.0, 299.0, 58.0}, {4.0, -5.0, 299.0, 58.0}, {4.0, -5.0, 365.0, 118.0}, {0.0, 0.0, 40.0, 40.0}}
The first four are the squares; the rest are other art layers in your document.
|