Skip navigation
Currently Being Moderated

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

Jul 2, 2012 2:56 PM

Tags: #illustrator #javascript #layer #bounds #illustrator_cs5

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

 
Replies
  • Currently Being Moderated
    Jul 2, 2012 3:01 PM   in reply to macdonaldshall

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 2, 2012 4:19 PM   in reply to macdonaldshall

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

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 2, 2012 6:15 PM   in reply to 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);
    
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points