Hello,
a friend of mine is on his way coding a PS filter with XCode, I guess sooner or later he'll add scripting support.
At this time, the ScriptingListener output is kind of weird, but I'm confident that in a later development stage it'll be usable.
(if you're curious, weird means that the SL's first line looks like that:
var iddninefivefourthreebzerocthreecnineoneoneonedfourninesevenbczerozerobzerodzerotwozerofourninethreesix = stringIDToTypeID( "d9543b0c-3c91-11d5-97bc-00b0d1214936" );
Anyway, one of the ideas around this project is to build an extension to collect presets (the filter has up to 10 parameters), store them in a ComboBox and launch the filter via scripting from within the extension in order to speed up things, avoid the time/resource consuming preview, etc.
To hardcode the presets this way is doable, but it'll be nice to make the extension to save as a new preset the last set of parameters used.
So the scene would possibly be:
1) you launch the filter, tweak the parameter until they're fine, click the filter's apply button;
2) when it's finished you're so happy for the result that you decide to store the parameter's set as a new preset,
3) in the extension I'll try to make, you click a "Add as preset" button, and a script will retrieve the last parameter used... I'm not sure if this is doable!
For instance, when you run a, say, GaussianBlur radius 100px, then Command (or CTRL) F, the last filter value is presented back to you. So it is stored, somehow, somewhere. Is it possible to grab the parameter, via script?
If the answer is yes, *maybe* it'll be possible to do the same thing for a set of parameters from a filter that's not in the DOM...
Any suggestion is welcome and appreciated,
regards
Davide
Retrieving last filter parameters
Retrieving last filter parameters
Can't give any advice on retrieving the filter parameters specifically, but generally when I want to save settings for re-use I just grab them from my UI and write them to an xml style file. If I don't want the users to go in an tinker with the file I'll scramble just it before I save it to disk and unscramble when I read it in. (I figure anyone smart enough to unscramble the file is smart enough not to break the file structure I set out in the first place)
Retrieving last filter parameters
Hi Anna,
that's precisely what I do with my extensions.
But here the problem is that (probably - it's still an early development stage) mine it'll be a companion extension. I don't know yet if the filter itself in its gui will contain a preset management, we're thinking to use the extension just to run the filter straight without launching the preview(I agree XML is the most flexible solution for storing presets, BTW).
I'm out of luck for the parameters, since they're in the filter gui, not in my extension...!
Thanks anyway for your answer and best regards,
Davide
that's precisely what I do with my extensions.
But here the problem is that (probably - it's still an early development stage) mine it'll be a companion extension. I don't know yet if the filter itself in its gui will contain a preset management, we're thinking to use the extension just to run the filter straight without launching the preview(I agree XML is the most flexible solution for storing presets, BTW).
I'm out of luck for the parameters, since they're in the filter gui, not in my extension...!
Thanks anyway for your answer and best regards,
Davide
Retrieving last filter parameters
Well, if I run the Gausian blur filter just as an example I can see the parameters in the script listener log. I would presume this means if you know the charid for the filter event you're after you could listen for it being run and grab the filter parameters from the action desriptor then. You can always write them out to disk from there until you're ready to use them.
I've only listened for open, place, merge etc but I presume a filter would work the same.
I've only listened for open, place, merge etc but I presume a filter would work the same.
Retrieving last filter parameters
myranalis wrote:I would presume this means if you know the charid for the filter event you're after you could listen for it being run and grab the filter parameters from the action desriptor then. You can always write them out to disk from there until you're ready to use them.
I can, manually, check the SL and grab the parameters for future use. The problem is that I'd like to code an extension that does this automatically, on the fly, without SL, installed on a machine run by a unknown user (blindfolded with an arm tied behind his back )
No really: imagine you have an extension that, based on the *last* filter used is able to retrieve its last used parameter. It has to be stored somewhere in the memory, since if you launch the filter again, it keeps the last used parameter as the default choice.
Then, but this will be the easy part, there'll be code in the extension based on SL output, that put the parameter in the proper action descriptor lines and run it. My problem is that I'm stuck at the previous step... is it possible to retrieve automatically, via scripting, the last used parameter (or set of parameters) of the last used filter?
Thanks again,
Davide
I can, manually, check the SL and grab the parameters for future use. The problem is that I'd like to code an extension that does this automatically, on the fly, without SL, installed on a machine run by a unknown user (blindfolded with an arm tied behind his back )
No really: imagine you have an extension that, based on the *last* filter used is able to retrieve its last used parameter. It has to be stored somewhere in the memory, since if you launch the filter again, it keeps the last used parameter as the default choice.
Then, but this will be the easy part, there'll be code in the extension based on SL output, that put the parameter in the proper action descriptor lines and run it. My problem is that I'm stuck at the previous step... is it possible to retrieve automatically, via scripting, the last used parameter (or set of parameters) of the last used filter?
Thanks again,
Davide
Retrieving last filter parameters
Sorry, I guess I wasn't clear enough. Below is my code to listen for a document opening... These lines are part of the 'install' script I give the users. Then when they actually open a document I can inspect the action descriptor to find out the path of the file that was opened... In your case, substitute the "Opn " charID for the charID of the filter and grab the parameters storing them in a place of your choice for when they run your extension...
Code: Select all//on open event
var eventFile = new File(basePath + "AFD_CreditTracker_OnOpen.jsxbin")
app.notifiers.add("Opn ", eventFile)
Code: Select all//on open event
var eventFile = new File(basePath + "AFD_CreditTracker_OnOpen.jsxbin")
app.notifiers.add("Opn ", eventFile)
Retrieving last filter parameters
That's really interesting, thanks!
I know nothing about notifiers, so I'll happily plunge in the documentation. Thanks again for your suggestion!
Davide
----
UPDATE
Ok I think I've got them: notifiers are like EventListeners in AS3. They trigger the execution of a script when something happens.
So, using event and class identifiers, I'll be able to track, say, the opening of a document or a filter run. Am I right?
Now, so sorry to take advantage of your patience... but I still miss the second step, namely: what should the triggered script contain in order to steal the parameters?
Let's say I'd like to listen for a Gaussian Blur filter ("GsnB"):
app.notifiersEnabled = true
var eventFile = new File(app.path + "/Presets/Scripts/myScripts/ParamLurker.jsx")
app.notifiers.add("GsnB", eventFile) // it seems to me that I can avoid specifying the class here
What trick should the ParamLurker.jsx perform to watch the GaussianBlur filter and grab its parameters?
Thanks SO much,
Davide
I know nothing about notifiers, so I'll happily plunge in the documentation. Thanks again for your suggestion!
Davide
----
UPDATE
Ok I think I've got them: notifiers are like EventListeners in AS3. They trigger the execution of a script when something happens.
So, using event and class identifiers, I'll be able to track, say, the opening of a document or a filter run. Am I right?
Now, so sorry to take advantage of your patience... but I still miss the second step, namely: what should the triggered script contain in order to steal the parameters?
Let's say I'd like to listen for a Gaussian Blur filter ("GsnB"):
app.notifiersEnabled = true
var eventFile = new File(app.path + "/Presets/Scripts/myScripts/ParamLurker.jsx")
app.notifiers.add("GsnB", eventFile) // it seems to me that I can avoid specifying the class here
What trick should the ParamLurker.jsx perform to watch the GaussianBlur filter and grab its parameters?
Thanks SO much,
Davide
Retrieving last filter parameters
That is the tricky bit. I mostly figured it out by trial and error - It made enough sense at the time but I don't think I can give you much more info without re-trying myself. X has a little utility in his xtools lib that helped examine the descriptor too I think. ActionDescriptorToXML.jsx maybe?
But basically you'll want something like this which checks for the right event and then use the appropriate 'get' method for the parameter's data type and the string or charid of the parameter...
Code: Select all
try {
if (arguments.length >= 2) {
var desc = arguments[0];
var event = arguments[1];
if (event == charIDToTypeID('Plc ') && pConfig.enabled()) {
var pFile = new File(desc.getPath( stringIDToTypeID( 'null' )));
//now do something with the file!
}
}
} catch (e) {
alert("AFDCreditTracker_OnPlace: There was an unexpected error. Please see the log file for more details");
pConfig.logError(e);
}
But basically you'll want something like this which checks for the right event and then use the appropriate 'get' method for the parameter's data type and the string or charid of the parameter...
Code: Select all
try {
if (arguments.length >= 2) {
var desc = arguments[0];
var event = arguments[1];
if (event == charIDToTypeID('Plc ') && pConfig.enabled()) {
var pFile = new File(desc.getPath( stringIDToTypeID( 'null' )));
//now do something with the file!
}
}
} catch (e) {
alert("AFDCreditTracker_OnPlace: There was an unexpected error. Please see the log file for more details");
pConfig.logError(e);
}
Retrieving last filter parameters
Got it!!
your suggestions have helped a lot. Also, a good friend of mine pointed me to this post in PS-Script, and to another in the Adobe Scripting Forum here.
After setting the notifier, I've to trigger a script that contains these lines:
Code: Select allvar desc = arguments[0];
var key = desc.getKey(0)
alert (desc.getUnitDoubleValue(key))
(this is for the GaussianBlur filter - I'll work with my friend's script when it'll be the time).
Thanks again and kind regards,
Davide
your suggestions have helped a lot. Also, a good friend of mine pointed me to this post in PS-Script, and to another in the Adobe Scripting Forum here.
After setting the notifier, I've to trigger a script that contains these lines:
Code: Select allvar desc = arguments[0];
var key = desc.getKey(0)
alert (desc.getUnitDoubleValue(key))
(this is for the GaussianBlur filter - I'll work with my friend's script when it'll be the time).
Thanks again and kind regards,
Davide