Tag Archives: Adobe

Hard at work on an InDesign plugin! (wait for beta testing release!)

In-Design plugin preview (one of the few dialogs of the UI)
In-Design plugin preview (one of the few dialogs of the UI)

Once I said:

Developing software is like panning for gold, you may find something that shines to you, but before getting it to market you just don’t know if it is real!!

I’m hard at work on my first InDesign plugin! and that’s why I’m not that active for the moment here! It’s been more than two weeks already that I started working on it and it’s going very well so far!

So I think I’ll be able to announce a pre-release beta testing call for it in few days (or weeks perhaps!), I worked really hard on it and the plugin with all its options won’t be available for free ( will be free during beta testing) but I will release a free version as well for folks just like myself who can’t afford paying for these kind of stuff! After all I hope to be able to sell a few of it after all these nights staying awake and writing codes till morning!

Please let me know if you are interested in the beta release.
Also I have to pick a name for my plugin! so please let me know if you have an idea about it! :))

Ok, back to work! 😉 have a good day!

working with measurement units in adobe extendScript

measurement_units (img from internet)
measurement_units (img from internet)

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 of different units (Points, Picas, Inches, Inches Decimal, Millimeters, Centimeters, Ciceros, Agates, Pixels, etc.) and it’s gonna be the same when you set a number as well.
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.

Here I’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- ):

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’t defined already, doing this we can be sure that even if we forgot to remove the vars later on, we don’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.
I found this technique to be the easiest, cleanest, fastest and the most performant way to handle the units issue in extend-script.

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:

Note: here I use the very front document but you can easily pass desired document to the function through an argument as well.

Setinterval for Adobe ExtendScript

If you start working on an extension for one of Adobe CS products it can be really annoying or even disappointing once you find out that there is not any of java-script timing events available!
No setInterval, no timeout! no nothing! which means you don’t even have a choice, all the code you write, HAS TO be blocking!
That was (and probably is still kind of!) my situation! in fact, I’m working on my memoir, and both in my university and our lab place I have access to the whole set of Adobe products, (Oh, forgot to say: I’ll use Indesign to publish/design (page-making) my memoir), and since it have never been convenient for me to do things the easy way, I decided to write a plugin for In-Design so it will do for me what I wanted to do! Yeah, pretty much my first essay on creating an extension for an Adobe product…

Let’s make it short for you (I’ll probably talk more about that plugin, once it was ready!), I did a lot of research and read almost 500 pages of (really bad documented) adobe documents! to find out that there is no way to write a non-blocking check-loop; BUT…

But after I gave up, I thought it will bother me if I don’t try the last, and least probable idea! and that was the answer! (kind of) in fact I read almost all the possible event objects in Adobe ID and none of them were useful, but one of them raised my curiosity at-least and I thought give it a try! It is onIdle event and obviously it trigers on software IDLE time but it is more than that! in-fact you can check for system state in really short amounts of time (or long!) and it will return it to you, and that’s called an interval!! I would guess probably it won’t be precise but it would be enough good most certainly to help one to write a non-blocking UI or atleast give the option to user to choose the way s/he prefer (having the entire software freezes for the duration of the process or do it in the backrgund!)

Voila quoi!

Sample code:

Please let me know if you need more info / samples on it! my problem is solved now but I couldn’t find any helpful information online AT ALL, so I though I’d share it, 😉


there is an $.sleep() method available which that too, of course, is blocking!