How to Get SmartObject info?

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: xbytor, DavideBarranca, Paul MR

Dimatokis
Posts: 11
Joined: Wed Aug 17, 2016 7:50 pm

How to Get SmartObject info?

Postby Dimatokis » Wed Aug 17, 2016 7:55 pm

..
For example a list of attached smart filters (with indexes), and values?



User avatar
Kukurykus
Posts: 114
Joined: Mon Jul 25, 2016 12:36 pm

Re: How to Get SmartObject info?

Postby Kukurykus » Wed Aug 17, 2016 8:28 pm

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!

User avatar
DavideBarranca
Posts: 15
Joined: Tue Jul 26, 2016 2:12 pm
Contact:

Re: How to Get SmartObject info?

Postby DavideBarranca » Thu Aug 18, 2016 11:02 pm

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

Dimatokis
Posts: 11
Joined: Wed Aug 17, 2016 7:50 pm

Re: How to Get SmartObject info?

Postby Dimatokis » Fri Aug 19, 2016 1:42 pm

Great! Thank you!
Say plz, can I find some property for identification smart-effects (like "id")? Becouse "name" is depends on the localization.

Dimatokis
Posts: 11
Joined: Wed Aug 17, 2016 7:50 pm

Re: How to Get SmartObject info?

Postby Dimatokis » Fri Feb 10, 2017 7:23 am

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:


Return to “Help Me”

Who is online

Users browsing this forum: No registered users and 1 guest