0

I am truly stumped at this point. I need to get the bounding box of a path string. I cannot use RaphaelJS because it's integrated too deeply with the browser, and naturally the Illustrator Type Library doesn't include anything to help me.

Where can I go from here? Should I just spend the time implementing my own algorithm?

Jongware
  • 22,200
  • 8
  • 54
  • 100
  • Do I have access to that in ExtendScript? – William Thomas Waller Aug 07 '14 at 15:28
  • can you please make a fiddle... – RashFlash Aug 07 '14 at 16:38
  • 1
    What needs a fiddle? I'm not asking about an issue with my code, I just need a means of computing an Svg paths bounding box. There is nothing to make a fiddle of, because there is not yet any relevant code. – William Thomas Waller Aug 07 '14 at 16:42
  • @RashFlash: it can't be fiddled. Adobe's "ExtendScript" is a scripting language *based on* ECMAScript E4X ECMA-357 ([Wikipedia](http://en.wikipedia.org/wiki/ExtendScript) calls it "a dialect" and "similar to Javascript"). It would also need the Illustrator DOM, not the HTML DOM & extensions currently available in jsFiddle. – Jongware Aug 08 '14 at 12:15

1 Answers1

2

check out:
http://www.jongware.com/idjshelp.html
or:
http://yearbookmachine.github.io/esdocs/#/Illustrator/PageItem

Rect geometricBounds Read only Property
The bounds of the artwork excluding stroke width.

There is not a lot of info on the Object Model Viewer about it. If it behaves like in InDesign the coordiantes depend on:

  • The page origin
  • The used unit
  • The page size

I hope that helps. You need to have a document open and have some PageItem selected. Should work with mostly everything you can put on a page in Illustrator.

var main = function(){
    if(app.activeDocument.selection.length > 0){
            var path = app.activeDocument.selection[0];
                    alert(path.geometricBounds);        
                }
        }
    }
main();
fabianmoronzirfas
  • 4,091
  • 4
  • 24
  • 41
  • "The used unit" -- up until CS4 [\*], Illustrator *insists* on always using points inside scripts. The pro is that it's just a number (as opposed to InDesign's "string"), con is that you have to do all unit conversions yourself. [*] I haven't kept up but I'm pretty sure Adobe did not change it for more recent versions. – Jongware Aug 08 '14 at 12:07
  • This is definitely helpful. At the point in my script, I have already exported to SVG and am trying to get the bounds from there. But I can find a way to step back and get the info another way using this. – William Thomas Waller Aug 12 '14 at 15:36
  • Funny enough, in trying to solve this I coincedentally happened upon your "select_all_textframes_on_page.jsx" on GitHub lol – William Thomas Waller Aug 12 '14 at 17:04
  • Yes it should work with minor changes in Illustrator too. Here the link for reference [https://gist.github.com/fabiantheblind/6725903](https://gist.github.com/fabiantheblind/6725903) – fabianmoronzirfas Aug 13 '14 at 09:45