• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

[Paid request] Find installed pattern names with script?

Community Beginner ,
Sep 15, 2020 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

2.2K

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
community guidelines

correct answers 1 Correct answer

People's Champ , Sep 16, 2020 Sep 16, 2020
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"), string
...

Votes

Translate

Translate
Adobe
People's Champ ,
Sep 15, 2020 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);

Votes

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
community guidelines
Community Beginner ,
Sep 15, 2020 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?

Votes

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
community guidelines
People's Champ ,
Sep 16, 2020 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)) // not working in ps2021
        switch (list.getObjectType(i)) // edited 1-aug-2021 by r-bin
            {
            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())        
    }        

Votes

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
community guidelines
LEGEND ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

I tried your script in 22.4.3 release to be sure it works with no problem.

I'm getting Internal error (require failed) in switch (list.getClass(i)) 

Votes

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
community guidelines
People's Champ ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

Provide a file (TMP) that the script uses to parse. I'll take a look (on PS2020).

Votes

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
community guidelines
LEGEND ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

I sent it by Private Message.

 

I know you have older Ps release, but does the script work on your side (without my .tmp)?

Votes

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
community guidelines
People's Champ ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

On PS2020 your file and "hierarchy" list are parsed without problems or errors. In the screenshot, the names of the patterns are not specified, because I omitted the creation of the patterns array from the presetManager. The array is just empty.

 

Untitled-1.png

 

Look for the specific source of the problem and what causes it yourself.

 

P.S.

Do you think that I write scripts without checking their work, just using some idea? Naturally, I check everything before proposing. : )

Votes

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
community guidelines
LEGEND ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

I finished up in this topic somehow and noticed you created the code for the user but the answer was not marked as correct, so first that came to my mind was: 'aha, another user is asking for help, but when it's given to him, he suddenly vanishes without any feedback'.

 

As I learnt not once that 'you check everything before posting' as you always 'check your work' I marked the answer as correct. That of course would be stupid to do so without testing whether the code works indeed. There was still chance the user didn't mark the correct solution as the code didn't work for him, that he did not say.

 

I checked your code myself and that didn't work. So again like in the other topic I met the same situation: either I had to unmark the correct answer or ask you if that does work, however maybe not for me for unknown reason.

 

 

Ps. for now I have no idea how to find that specific source of problem 😉

Votes

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
community guidelines
Guide ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

22.4.3 same problem

 

list.getObjectType(i) instead list.getClass(i) works. 

 

P.S. How did you know that after 8BIMphry there is a descriptor in the file? I understand, experience and all that, but the hell, how? 🙂

I found a mention of the 8BIM signature Adobe Photoshop File Formats Specification November 2019, but no more. 

Votes

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
community guidelines
LEGEND ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

I changed getClass to getObjectType and it works for me too.

Votes

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
community guidelines
People's Champ ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

Kukurykus

Didn't understand how it helped you? All types are a "descriptor" (sort of)

Votes

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
community guidelines
LEGEND ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

I would answer, but I don't know what you ask me now for?

 

jazz-y figured out it works with getObjectType, so I used it and the code worked.

Votes

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
community guidelines
People's Champ ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

Yes, indeed, I was stupid about it. getObjectType can be used. This is probably even more correct. It is not clear why getClass is not working for 2021.

Votes

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
community guidelines
Guide ,
Aug 01, 2021 Aug 01, 2021

Copy link to clipboard

Copied

@r-bin I tried to create a new object with an arbitrary class ID, put it in an empty List. getClass () doesn't work for that list item. It's weird that this used to work

Votes

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
community guidelines
People's Champ ,
Aug 01, 2021 Aug 01, 2021

Copy link to clipboard

Copied

quote

@r-bin I tried to create a new object with an arbitrary class ID, put it in an empty List. getClass () doesn't work for that list item. It's weird that this used to work


By @jazz-y

 

It would be nice to bring the code.

So you did putClass and then getClass?

Does this not work for ActionList only or for ActionDescriptor too?

Probably a bug, you need to report with an example.

 

How does this code work for you?

var d = new ActionDescriptor();

d.putClass(stringIDToTypeID("name"), stringIDToTypeID("group"));

alert(d.getClass(stringIDToTypeID("name")))

var d = new ActionList();

d.putClass(stringIDToTypeID("group"));

alert(d.getClass(0))

 

getClass is used in my eventslistener script, for example when the tool select command is executed.

I wonder how the ScriptListener plugin works. It does not use getClass from the scripted DOM, but must do something similar to get the class from this command.

Votes

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
community guidelines
People's Champ ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

для jazz-y

 

Ну, во-первых, там структура как у дескриптора, видны всякие там 'Objc', 'TEXT' и прочая лабуда присущая дескриптору. Во-вторых, там магические цифры 00 00 00 10.

fromStream(string) отрабатывает только если строка начинается с этой фигни, я так думаю это версия.

Если fromStream() отработает без ошибок, значит точно десритор. Ну а дальше дело техники разобраться что там. Типо как-то так... 🙂

 

 

 

Votes

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
community guidelines
Guide ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

Я посмотрел несколько файлов пресетов. Так понял, что 8BIM - это общее обозначение ресурсов, а phry идет только там, где за ним следует дескриптор, т.е., видимо, это сигнатура его обозначающая. 
Спасибо за подсказку, покопаюсь 🙂


Может я загоняюсь, но в документации написано что для actionList getClass - Gets the value of a list element of type class, а getObjectType - Gets the class ID of a list element
of type object. Т.е. одна функция для классов, а другая для объектов.

Votes

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
community guidelines
People's Champ ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

Нет

8BIM или 8B64 это сигнатура ресурса. Далее обычно идёт 4-char название ресурса. В нашем случае это "phry", в других другое. Часто в этих ресурсах сидят дескрипторы. В описании формата (PSD(B)), если читать внимательно, многое описано.

 

Votes

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
community guidelines
Guide ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

Перечитал внимательно - да. Моя ошибка в том, что я смотрел только файлы пресетов, видимо, phry это и есть "пресет".

Votes

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
community guidelines
People's Champ ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

phry == Preset HieRarchY - я так думаю : )

Votes

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
community guidelines
LEGEND ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

Off-topic: I wonder if you ever saw historic Ps 5 scripting documentation I'm attaching.

Votes

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
community guidelines
People's Champ ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

Wow! Where did you find it?

Votes

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
community guidelines
LEGEND ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

Votes

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
community guidelines
Guide ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

@r-bin , sarcasm? 🙂 this pdf is in the archive with other SDK documents

Votes

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
community guidelines