<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>mim.Armand &#187; Millimeters</title>
	<atom:link href="http://armand.eu/blog/tag/millimeters/feed/" rel="self" type="application/rss+xml" />
	<link>http://armand.eu/blog</link>
	<description>Artist, inventor and developer!</description>
	<lastBuildDate>Wed, 24 Jun 2015 12:02:08 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.2.2</generator>
	<item>
		<title>working with measurement units in adobe extendScript</title>
		<link>http://armand.eu/blog/working-with-measurement-units-in-adobe-extendscript/</link>
		<comments>http://armand.eu/blog/working-with-measurement-units-in-adobe-extendscript/#comments</comments>
		<pubDate>Tue, 24 Jun 2014 19:47:25 +0000</pubDate>
		<dc:creator><![CDATA[mim]]></dc:creator>
				<category><![CDATA[Adobe ExtendScript]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Agates]]></category>
		<category><![CDATA[Centimeters]]></category>
		<category><![CDATA[change units in extendScript]]></category>
		<category><![CDATA[Ciceros]]></category>
		<category><![CDATA[Extend-Script]]></category>
		<category><![CDATA[ExtendScript]]></category>
		<category><![CDATA[in-design]]></category>
		<category><![CDATA[Inches]]></category>
		<category><![CDATA[Inches Decimal]]></category>
		<category><![CDATA[indesign scripts]]></category>
		<category><![CDATA[measurement]]></category>
		<category><![CDATA[Millimeters]]></category>
		<category><![CDATA[Picas]]></category>
		<category><![CDATA[Pixels]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[Points]]></category>
		<category><![CDATA[units]]></category>

		<guid isPermaLink="false">http://armand.eu/blog/?p=58</guid>
		<description><![CDATA[While working with Adobe ExtendScript to extend Adobe CS features (through scripts and/or plugins), there is a good chance you need to get or set an elements dimensions (document dimensions for instance). When you ask the Software about the dimensions, it will give you back a number, but this number could be in a lot &#8230; <a href="http://armand.eu/blog/working-with-measurement-units-in-adobe-extendscript/" class="more-link">Continue reading <span class="screen-reader-text">working with measurement units in adobe extendScript</span> <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<figure id="attachment_60" style="width: 466px;" class="wp-caption alignnone"><a href="http://armand.eu/blog/wp-content/uploads/2014/06/1368370718153279968windows_8_icons_measurement_units1.png"><img class=" wp-image-60" src="http://armand.eu/blog/wp-content/uploads/2014/06/1368370718153279968windows_8_icons_measurement_units1.png" alt="measurement_units (img from internet)" width="466" height="118" /></a><figcaption class="wp-caption-text">measurement_units (img from internet)</figcaption></figure>
<p style="text-align: justify;">While working with <a title="Adobe extend script" href="http://www.adobe.com/devnet/scripting.html" target="_blank">Adobe ExtendScript</a> to extend <a title="Adobe dot com!" href="https://www.adobe.com" target="_blank">Adobe CS</a> features (through scripts and/or plugins), there is a good chance you need to get or set an elements dimensions (document dimensions for instance).<br />
When you ask the Software about the dimensions, it will give you back a number, but this number could be in a lot of different units (Points, <a title="Pica in Wikipedia" href="http://en.wikipedia.org/wiki/Pica_%28typography%29" target="_blank">Picas</a>, Inches, Inches <a title="Decimal" href="http://en.wikipedia.org/wiki/Decimal" target="_blank">Decimal</a>, Millimeters, Centimeters, <a title="Cisero" href="http://en.wikipedia.org/wiki/Cicero_%28typography%29" target="_blank">Ciceros</a>, <a title="Agate (unit)" href="http://en.wikipedia.org/wiki/Agate_%28typography%29" target="_blank">Agates</a>, Pixels, etc.) and it&#8217;s gonna be the same when you set a number as well.<br />
There is a lot of different ways to handle this issue, like getting the unit as well and trying to convert them etc. but it may add a huge overload on your code, your time and a lot of unnecessary complexity which can make your code harder to debug as-well.</p>
<p style="text-align: justify;">Here I&#8217;ll put a simple solution I use in my own codes which may come helpful to you too (This code is written for In-design but should work less or more for the whole CS collection -maybe with a bit of tweaking- ):</p>
<p style="text-align: justify;">I just get the current document units (for both Vertical and Horizontal measurement units in In-Design), keep them in a (pair of) variable(s) (I check to see if the variable is defined before and set it if it isn&#8217;t defined already, doing this we can be sure that even if we forgot to remove the vars later on, we don&#8217;t set them to our newly defined units again), change the units (for the whole document) and run my code and then when I was done with it change it back to original units and remove the created variables.<br />
I found this technique to be the easiest, cleanest, fastest and the most performant way to handle the units issue in extend-script.</p>
<p style="text-align: justify;">Here is the simple code I use; two functions, one to run before the main script and one when the script was done to set everything back to what they were before we run the script:<br />
<script src="https://gist.github.com/mim-Armand/53f825c889995b4a65e0.js"></script></p>
<p style="text-align: justify;">Note: here I use the very front document but you can easily pass desired document to the function through an argument as well.</p>
<p style="text-align: justify;">
]]></content:encoded>
			<wfw:commentRss>http://armand.eu/blog/working-with-measurement-units-in-adobe-extendscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
