Page 1 of 1

How to Get SmartObject info?

Posted: Wed Aug 17, 2016 7:55 pm
by Dimatokis
..
For example a list of attached smart filters (with indexes), and values?

Re: How to Get SmartObject info?

Posted: Wed Aug 17, 2016 8:28 pm
by Kukurykus
Looping through smart layers with filters in smart object and getting laeyrs and filters names should't be problem, but all those values inside filter had to be long way throughtout Action Manager objects and then what even harder great number of properties.

I hope this time excellent coders like xbytor or Paul Riggott finally come and show us the magic!

Re: How to Get SmartObject info?

Posted: Thu Aug 18, 2016 11:02 pm
by DavideBarranca
As an example, I've created a flatten file with a single Background layer; converted to Smart Object, and applied Gaussian Blur and Solarize Smart Filters.
The following code:

Code: Select all

var ref = new ActionReference ();
ref.putProperty (stringIDToTypeID ("property"), stringIDToTypeID ("smartObject"));
ref.putEnumerated (stringIDToTypeID ("layer"), stringIDToTypeID ("ordinal"), stringIDToTypeID ("targetEnum"));
var smartObjectDesc = executeActionGet (ref).getObjectValue (stringIDToTypeID ("smartObject"));
var filtersList = smartObjectDesc.getList(stringIDToTypeID ("filterFX"))

for (var i = 0, _len = filtersList.count; i < _len; i++) {
var smartFilter = filtersList.getObjectValue(i)
var filterName = smartFilter.getString(stringIDToTypeID ("name"));
$.writeln("Filter: " + filterName)
try {
var filterDesc = smartFilter.getObjectValue (stringIDToTypeID("filter"));
// E.g. for Gaussian Blur:
var radius = filterDesc.getUnitDoubleValue(stringIDToTypeID("radius"))
$.writeln("Radius: " + radius)
} catch(e) {}
}
Outputs in the console:

Code: Select all

Filter [0]: Gaussian Blur...
Radius: 5
Filter [1]: Solarize
It might not work under all circumstances but should give you a head start.

Regards,
Davide Barranca

Re: How to Get SmartObject info?

Posted: Fri Aug 19, 2016 1:42 pm
by Dimatokis
Great! Thank you!
Say plz, can I find some property for identification smart-effects (like "id")? Becouse "name" is depends on the localization.

Re: How to Get SmartObject info?

Posted: Fri Feb 10, 2017 7:23 am
by Dimatokis
Another question
Now I can get the value of the radius (thanks Davide), and how to get the opacity and blending mode in a Smart-Filter?
Please, help :roll: