{"id":636,"date":"2014-12-03T22:57:25","date_gmt":"2014-12-03T22:57:25","guid":{"rendered":"https:\/\/greladesign.co\/blog\/?p=636"},"modified":"2014-12-03T22:57:25","modified_gmt":"2014-12-03T22:57:25","slug":"get-bounds-of-all-artboards-in-illustrator-cs5-1-with-javascript","status":"publish","type":"post","link":"https:\/\/greladesign.co\/blog\/2014\/12\/03\/get-bounds-of-all-artboards-in-illustrator-cs5-1-with-javascript\/","title":{"rendered":"Get bounds of all artboards in Illustrator CS5.1 with JavaScript"},"content":{"rendered":"<p>When you need to create new artboard you will, most certainly, would like to know where to place it safely. One of the options could be to place it next to the &#8220;edges&#8221; of the &#8220;bounding box&#8221; created by all artboards.<br \/>\n<!--more--><\/p>\n<p>To find this &#8220;bounding box&#8221; we need to know bounding box of each artboard. The bounds of the artboard are returned by <code>artboardRect<\/code> property.<br \/>\nAll we have to do is to go through all of the artboards, take maximum\/minimum of each of the properties (left, top, right, bottom) and use it.<\/p>\n<p>Script below will create new artboard matching those extremes.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar artboards = app.activeDocument.artboards;\r\nvar extreme = [0,0,0,0];\r\nfor (var i = 0; i &lt; artboards.length; i++) {\r\n    \/\/[0 left, 1 top, 2 right, 3 bottom]\r\n    var rect = artboards[i].artboardRect;\r\n    \/\/\r\n    if(rect[0] &lt; extreme[0]){\r\n        extreme[0] = rect[0];\r\n    }\r\n    if(rect[1] &gt; extreme[1]){\r\n        extreme[1] = rect[1];\r\n    }\r\n    if(rect[2] &gt; extreme[2])\r\n    {\r\n        extreme[2] = rect[2];\r\n    }\r\n    if(rect[3] &lt; extreme[3])\r\n    {\r\n        extreme[3] = rect[3];\r\n    }\r\n}\r\nalert(extreme);\r\nvar a = artboards.add(extreme);\r\na.name = &quot;Extreme&quot;;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>When you need to create new artboard you will, most certainly, would like to know where to place it safely. One of the options could be to place it next to the &#8220;edges&#8221; of the &#8220;bounding box&#8221; created by all &hellip; <a href=\"https:\/\/greladesign.co\/blog\/2014\/12\/03\/get-bounds-of-all-artboards-in-illustrator-cs5-1-with-javascript\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":""},"categories":[222,141],"tags":[226,224,225],"_links":{"self":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts\/636"}],"collection":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/comments?post=636"}],"version-history":[{"count":2,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts\/636\/revisions"}],"predecessor-version":[{"id":638,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/posts\/636\/revisions\/638"}],"wp:attachment":[{"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/media?parent=636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/categories?post=636"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/greladesign.co\/blog\/wp-json\/wp\/v2\/tags?post=636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}