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

[Javasscript] Find the visible bounds of a layer in Illustrator

New Here ,
Jul 02, 2012 Jul 02, 2012

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

TOPICS
Scripting
3.2K
Translate
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

Community Expert , Jul 02, 2012 Jul 02, 2012

"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);

Translate
Adobe
Community Expert ,
Jul 02, 2012 Jul 02, 2012

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.

Translate
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
New Here ,
Jul 02, 2012 Jul 02, 2012

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.

Translate
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
Community Expert ,
Jul 02, 2012 Jul 02, 2012

There's the super group PageItems which includes all of the above.

Translate
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
New Here ,
Jul 02, 2012 Jul 02, 2012
LATEST

Nice, I'll give that a shot.

Translate
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
Community Expert ,
Jul 02, 2012 Jul 02, 2012

"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);

Translate
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
New Here ,
Jul 02, 2012 Jul 02, 2012

Oh, perfect, this is exactly what I was looking for, thank you!

Translate
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