Highlighted

[Paid request] Find installed pattern names with script?

Community Beginner ,
Sep 15, 2020

Copy link to clipboard

Copied

My app has already shipped and i'm encountering an issue, so I am happy to pay cash today for this help via cashapp/paypal so I can get this running again.

 

BiWxerw

 

I'm looking for a way to fetch the names of the users installed patterns. For example, "Trees", "Grass", "Water". I want my extension to automatically install a pattern pack, however what happens is that it reinstalls the same patterns every time it runs. I would like to check if the pattern pack name matches any of the users installed pattersn, and if not, install them.

 

I would also be okay with an alternative method of installation that doesn't require that, but gets the same job done.

 

 

Topics

Actions and scripting, SDK

Views

88

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

[Paid request] Find installed pattern names with script?

Community Beginner ,
Sep 15, 2020

Copy link to clipboard

Copied

My app has already shipped and i'm encountering an issue, so I am happy to pay cash today for this help via cashapp/paypal so I can get this running again.

 

BiWxerw

 

I'm looking for a way to fetch the names of the users installed patterns. For example, "Trees", "Grass", "Water". I want my extension to automatically install a pattern pack, however what happens is that it reinstalls the same patterns every time it runs. I would like to check if the pattern pack name matches any of the users installed pattersn, and if not, install them.

 

I would also be okay with an alternative method of installation that doesn't require that, but gets the same job done.

 

 

Topics

Actions and scripting, SDK

Views

89

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 15, 2020 0
Adobe Community Professional ,
Sep 15, 2020

Copy link to clipboard

Copied

You can take this script as a basis

var r = new ActionReference();    
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("presetManager"));  
r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

var list = executeActionGet(r).getList(stringIDToTypeID("presetManager")).getObjectValue(4).getList(stringIDToTypeID("name"));        

var patterns = new Array();    

for (var i = 0; i < list.count; i++) patterns.push(list.getString(i));    

alert(patterns);

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 15, 2020 1
Community Beginner ,
Sep 15, 2020

Copy link to clipboard

Copied

Thank you, where should I send a check?! 

 

I'm serious thank you a ton. One question, this seems to deliver the individual texture names instead of the folder/group name. Is that possible to retrieve?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 15, 2020 0
r-bin LATEST
Adobe Community Professional ,
Sep 16, 2020

Copy link to clipboard

Copied

Such an organization of patterns appeared not so long ago.
What can be done.
This script receives a structure as an array of objects.
The array element contains the path property - an array of strings. Also, if the element is a pattern, it contains the pattern property - the name of the pattern.
 
var r = new ActionReference();    
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("presetManager"));  
r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));

var list = executeActionGet(r).getList(stringIDToTypeID("presetManager")).getObjectValue(4).getList(stringIDToTypeID("name"));        

var patterns = new Array();    

for (var i = 0; i < list.count; i++) patterns.push(list.getString(i));    

var file = new File(Folder.temp.fsName + "/" + "TMP");

file.remove();

var d = new ActionDescriptor();
d.putPath(stringIDToTypeID("null"), file);
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("pattern"));
r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
d.putReference(stringIDToTypeID("to"), r);
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);

patterns.reverse();


file.open("r");
file.encoding = "BINARY";

var s = file.read();

file.remove();

var n = s.indexOf("8BIMphry");

if (n > 0)
    {
    s = s.substr(n+12);

    var d = new ActionDescriptor();
    d.fromStream(s);

    var list = d.getList(stringIDToTypeID("hierarchy"));

    var hierarchy = new Array();

    var grp = new Array();

    for (var i = 0; i < list.count; i++)
        {
        switch (list.getClass(i))
            {
            case stringIDToTypeID("group"):
                var nm = list.getObjectValue(i).getString(stringIDToTypeID("name"));
                grp.push(nm);

                hierarchy.push({path:[]});

                for (var x = 0; x < grp.length; x++) hierarchy[hierarchy.length-1].path.push(grp[x]);

                break;

            case stringIDToTypeID("groupEnd"):
                grp.pop();
                break;
                

            case stringIDToTypeID("preset"):
                hierarchy.push({path:[]});

                for (var x = 0; x < grp.length; x++) hierarchy[hierarchy.length-1].path.push(grp[x]);

                hierarchy[hierarchy.length-1].pattern = patterns.pop();
                break;
            }
        }

    alert(hierarchy.toSource())        
    }        

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 16, 2020 3