Copy link to clipboard
Copied
Hi folks,
A similar question has been asked before, but I'm asking a much simplified version of it:
"Is there a way to determine the visible bounds of a layer in Illustrator CS5+?"
I ask because I'm trying to export layers with their upper-left coordinates in an XML file. I've got the XML export working for objects, but would like to extend the funtionality to layers as well.
Many thanks in advance!
macdonaldshall
"Is there a way to determine the visible bounds of a layer in Illustrator CS5+?"
the Document.visibleBounds property returns the bounds of whatever is visible in the document...so, hide all layers, except one, and run the code
var idoc = app.activeDocument;
var bounds = idoc.visibleBounds;
$.writeln("visible layer bounds = " + bounds);
Copy link to clipboard
Copied
Layers don't have bounds. Objects in the layers do. You would probably have to group all the objects in the layer and then get the visible bounds for the group.
Copy link to clipboard
Copied
Yeah, I figured as much...I was basically just wondering as to the easiest way to get-and-group all the child objects. From what I can see, I'd have to look for all "groupItems", then all "compoundPathItems", etc... but there *must* be an easier way than that.
Copy link to clipboard
Copied
There's the super group PageItems which includes all of the above.
Copy link to clipboard
Copied
Nice, I'll give that a shot.
Copy link to clipboard
Copied
"Is there a way to determine the visible bounds of a layer in Illustrator CS5+?"
the Document.visibleBounds property returns the bounds of whatever is visible in the document...so, hide all layers, except one, and run the code
var idoc = app.activeDocument;
var bounds = idoc.visibleBounds;
$.writeln("visible layer bounds = " + bounds);
Copy link to clipboard
Copied
Oh, perfect, this is exactly what I was looking for, thank you!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now