Search code examples
svgadobe-illustratorextendscript

SVG Path Bounding Box in ExtendScript


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?


Solution

  • 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();