Scripting issues

Here everybody can post his problems with PhotoLine
Benutzeravatar
russellcottrell
Mitglied
Beiträge: 251
Registriert: Sa 26 Jul 2014 10:13
Wohnort: California

Re: Scripting issues

Beitrag von russellcottrell »

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 - PhotoLine.app 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: Alles auswählen

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

var doc = pl.activeDocument;
pl.displayAlert(doc.name); // empty string
pl.displayAlert(doc.activeLayer.name); // error
pl.displayAlert(doc.resolution.toString()); // error
doc.activeLayer = doc.root.lastChild; // error
Maybe someday . . . .
Martin Huber
Entwickler
Entwickler
Beiträge: 4176
Registriert: Di 19 Nov 2002 15:49

Re: Scripting issues

Beitrag von Martin Huber »

You can get the active document with code like:

Code: Alles auswählen

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

Code: Alles auswählen

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

Code: Alles auswählen

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.

Martin