Scripting issues

Here everybody can post his problems with PhotoLine
User avatar
Posts: 164
Joined: Sat 26 Jul 2014 10:13

Re: Scripting issues

Post by russellcottrell » Tue 15 Jan 2019 20:02

Hello; sorry to be stubborn, but . . . I just am. I can't help but think that there must be a future for jxa even if it doesn't work perfectly at the moment. So here are some observations in case anyone else has some insights. I found that in the Script Editor, File - Open Dictionary - opens a window that shows all the properties and methods. Notably, activeDocument is missing; this may explain why a lot of things don't work:

Code: Select all

var pl = Application.currentApplication();
pl.includeStandardAdditions = true;
pl.displayAlert("Hello, world!");

var doc = pl.activeDocument;
pl.displayAlert(; // empty string
pl.displayAlert(; // error
pl.displayAlert(doc.resolution.toString()); // error
doc.activeLayer = doc.root.lastChild; // error
Maybe someday . . . .

Martin Huber
Posts: 3593
Joined: Tue 19 Nov 2002 15:49

Re: Scripting issues

Post by Martin Huber » Thu 17 Jan 2019 11:08

You can get the active document with code like:

Code: Select all

if (pl.documents().length > 0)
	doc = pl.documents.first
Then you can get the active layer with

Code: Select all

actLayer = doc.activeLayer()
You can check the layer type with something like

Code: Select all

if ((actLayer != null) && (actLayer.type() === 'LTImage'))
Enumerations in PhotoLine's scripting dictionary seem to be strings in JXA.

But I haven't been able to create new layers at a specific location using JXA. And I haven't been able to set adjustments.