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

Updating SmartObject Layer Comps according to their names

Explorer ,
Feb 16, 2018 Feb 16, 2018

Copy link to clipboard

Copied

Layers structure:

SO_Structure.png

Each of these Smart Objects has it's own LayerComps with names similar to the layer name:

SO_Properties.png

I need to switch on each of the Smart Objects in the LayerSet "Element" one by one and apply the specified LayerComp at the same time. E.g. "Element Red" got "Red" LayerComp applied, "Element Yellow" - "Yellow", etc.

What I have for now.
I've modified a bit Michael L Halecode posted here​ to switch layers one by one. It's all looks like that:

var DBG = 1;

var id = getSelectedLayerID();

var name = getLayerNameByID(id);

var variations = ["Red", "Yellow", "Green", "Blue"];

if(DBG) {alert("id="+id+"; name="+name); };

for( i=0; i<variations.length; i++ ) {

    layerName = name+" "+variations;

    showSetByOne( layerName, name );

    if(DBG) {alert(layerName)};

}

function showSetByOne( layerName, groupName ){

    var setFolder = app.activeDocument.activeLayer;

    if (setFolder.typename == 'LayerSet' && setFolder.name == groupName ) {

        for( var setIndex = 0; setIndex<setFolder.layers.length; setIndex++) {

            if(setFolder.layers[setIndex].name == layerName){

                setFolder.layers[setIndex].visible = true;

                switchPlacedLayerComp(setFolder.layers[setIndex].id, 1402355601); //exact ID of one of the LayerComps got from ScriptListener

            }else{

                setFolder.layers[setIndex].visible = false;

            }

        }

    }

}

function switchPlacedLayerComp(id, compID) {

        // (ref = new ActionReference()).putEnumerated(sTT('layer'), sTT('ordinal'), sTT('targetEnum'));

        (ref = new ActionReference()).putIdentifier( sTT("layer"), id );

        // (ref = new ActionReference()).putIndex( sTT("layer"), id );

        (desc = new ActionDescriptor()).putReference( sTT("null"), ref );

        // alert("Inside Func: "+id);

        desc.putInteger( sTT("compID"), compID );

        // desc.putString( sTT("comp"), "Red" );

        executeAction( sTT("setPlacedLayerComp"), desc, DialogModes.NO );

}

But I can not find any way to process the Smart Objects Layer Comps applying. If to select the exact SO layer and use the exact "compID" ( 1402355601) that was got from Script Listener then LayerComp applies to. But I have only LayerComps names but not IDs. And I could not apply LayerComp to SmartObject without selecting it. Neither by SmarObject id nor by name.

Kukurykus​ it seems I could not solve this puzzle without your help

Thanks to all for help in advance!

TOPICS
Actions and scripting

Views

3.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

LEGEND , Feb 18, 2018 Feb 18, 2018

At the bottom you find script that should work. As you understand I can not test it as following part was not yet part of CS6:

(ref2 = new ActionReference()).putEnumerated(sTT('layer'),

sTT('ordinal'), sTT('targetEnum')); (dsc3 = new ActionDescriptor())

.putReference(sTT('null'), ref2), dsc3.putInteger(sTT('compID'), compID)

executeAction(sTT('setPlacedLayerComp'), dsc3, DialogModes.NO)

Anyway to see that works - for both files you sent - I alerted compID instead of above code nested in script you fi

...

Votes

Translate

Translate
Adobe
Enthusiast ,
Feb 16, 2018 Feb 16, 2018

Copy link to clipboard

Copied

You need to use generator plugin with action manager code. This code can see comps inside smart object event when it is not opened in the window and here you can read comps IDs and names so you can pair them. Then you can compare layer name with comp names and assign comp id from the pair into action which changes current smart object comp.

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
Explorer ,
Feb 16, 2018 Feb 16, 2018

Copy link to clipboard

Copied

So with this generator plugin all the code stays the same? Or how should I use my script with this plugin?

I've installed Generator as described here. But what's the next?

The scripts still works as it was before.

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 ,
Feb 17, 2018 Feb 17, 2018

Copy link to clipboard

Copied

There are no Artboards in CS6 EXTENDED I use as well as Properties panel doesn't show everything what you have in CC's. compID's aren't created for me by ScriptListener (however you could say what action you did to record them?), only names of comps, both for normal and placed layers, so I assume they were added in later versions, though I think they were earlier already avialable in binaries. I checked there're such key words so probably they existed before to be used one day in future.

I don't use Layer Comps and Smart Objects but was able to write script which makes a loop over layers in Element layerSet, then reads colour part name of certain layer and searches for it in binaries. When found it checks ID to use it in place of last selected layer comp by user before Smart Object got saved. Unfortunately though this switch really works (you can check it editing certain object), as it fills demanded checkbox it doesn't refresh SmartObject until checkbox will be clicked again (or applied by script when smart object is opened in case of CS6, but probably changed by Properties panel / compID by script in later versoin). To refresh layers (visibility, position and apperance for CS6) I had to write one part more of script that edits Smart Object to reclick / apply checkbox / layer comp found in binaries using colour name. After all - that step for browsing binaries isn't necessary in CS6. Sole applying layer comp basing on layer name is sufficient.

If I'm right you can edit Layer Comp of Smart Object without opening it by Properties? You can not use name of layer comp, but compID that I can read in binaries to compare with name. This way using comp name while binaries are beeing read by script you could have compID taken from them and applied by script. Send me a file (that with 'Element' folder contianing 4 Smart Objects (red, yellow, green and blue), also tell me exact compID's they were created for all of layer comps names and I'll make sure they are placed in the same spots I already found in binaries writing this script:

(HERE'S A PART OF POST THAT WAS REMOVED FOR SOME REASON BY MODERATION WITHOUT ANY EXPLANATION!)

function sTT(v) {return stringIDToTypeID(v)}

(ref1 = new ActionReference()).putName(sTT('layer'), 'Element')

j = (dsc1 = executeActionGet(ref1)).getInteger(sTT('itemIndex')) - 1

while(typeIDToStringID(dsc1.getEnumerationValue(sTT(lS = 'layerSection'))) != lS + 'End') {

     (ref1 = new ActionReference()).putIndex(sTT('layer'), j--); (dsc1 = executeActionGet(ref1))

     .putReference(sTT('null'), ref1), dsc1.putBoolean(sTT('makeVisible'), false)

     executeAction(sTT('select'), dsc1, no = DialogModes.NO)

     if (nme = dsc1.getString(sTT('name')).match(/\w+$/)) {

          function pL(v) {

               (dsc2 = new ActionDescriptor()).putPath(sTT('null'), fle)

               executeAction(sTT('placedLayer' + v + 'Contents'), dsc2, no)

          }

          (function bin(){pL('Export'), fle.open('r'); var r = fle.read()

               var m = r.match(/Nm  TEXT.{4}.*?.{6}compIDlong.{4}/g)

               for(; i < m.length;) {if (RegExp(nme).test(m[i++].slice(12, -20).match(/[^\x00]/g).join(''))) {

                    fle.open('w'), fle.write(r.replace(/(last.{11}long)(.{4})/, '$1' + m[--i].slice(-4)))

                    fle.close(), pL('Replace'); break}} fle.close(), fle.remove()

          })((fle = File('~/desktop/.psb')).encoding = 'binary')

          executeAction(sTT('placedLayerEditContents'));

          (ref2 = new ActionReference()).putName(sTT('compsClass'), nme[0]);

          (dsc2 = new ActionDescriptor()).putReference(sTT('null'), ref2)

          executeAction(sTT('applyComp'), dsc2, DialogModes.NO);

          (aD = activeDocument).save(), aD.close()

     }

}

In case of CS6 following part is not needed:

(function bin(){pL('Export'), fle.open('r'); var r = fle.read()

     var m = r.match(/Nm  TEXT.{4}.*?.{6}compIDlong.{4}/g)

     for(; i < m.length;) {if (RegExp(nme).test(m[i++].slice(12, -20).match(/[^\x00]/g).join(''))) {

          fle.open('w'), fle.write(r.replace(/(last.{11}long)(.{4})/, '$1' + m[--i].slice(-4)))

          fle.close(), pL('Replace'); break}} fle.close(), fle.remove()

})((fle = File('~/desktop/.psb')).encoding = 'binary')

It searches binaries for compID of layer comp name, and then replace last used layer compID to that pointed by script.

If I left above part, but removed this one:

executeAction(sTT('placedLayerEditContents'));

(ref2 = new ActionReference()).putName(sTT('compsClass'), nme[0]);

(dsc2 = new ActionDescriptor()).putReference(sTT('null'), ref2)

executeAction(sTT('applyComp'), dsc2, DialogModes.NO);

(aD = activeDocument).save(), aD.close()

the only change was that desired layer comp checkboxes inside SmartObjects were filled, but sole document not refresehed untill user reclicked / applied by script that layer comp (during editing of Smart Object in CS6). Fortunately for users of CC it seems above part can be replaced to that applying compID (found by script in binaries basing on layer comp names). It's all thx to Properties where you can edit LayerComps without opening smart object, right? As to reading compID from binaries it took just 50 milliseconds for me. Script does not work with background and non SO layers, so only like in your example).

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
Explorer ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

Hi, Kukurykus.

however you could say what action you did to record them?

I've manually switched through the avaliable comps of the SmartObject in the Properties panel.

If I'm right you can edit Layer Comp of Smart Object without opening it by Properties?

You're right. Not exactly "edit" but switch on any LayerComp ("Red", "Yellow" etc.) present in a SmartObject. The main problem is that via script I've found only one way to do that. It's by putting compID value which I do not know:

desc.putInteger( sTT("compID"), compID );

So, I've used your code and noticed that all SO layers were renamed to the color names ("Element Red"->"Red" etc.). I can not distinguish if the script got this values from the SO directly or just renamed the layers. If it got, then would it be able to get according compIDs to this names? If it's possible then we are on the finishing line.

Here are the PSD file - with Artboard present and without it. I do not remember how CS6 understands newish file format, so just in case.

These are the compIDs of the every layerComp in the SmartObject:

1559146104 - Red

1563667187 - Yellow

1568356340 - Green

1572927844 - Blue

They are the same for both of the files with Artboard or without.

Btw, if I use not Embed SmartObjects but Linked (it's a bit new feature. It seems it's not avaliable in CS6) one - the function pL() does not work. It throws an error that:

"The command "Edit Contents" is not currently avaliable"

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 ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

At the bottom you find script that should work. As you understand I can not test it as following part was not yet part of CS6:

(ref2 = new ActionReference()).putEnumerated(sTT('layer'),

sTT('ordinal'), sTT('targetEnum')); (dsc3 = new ActionDescriptor())

.putReference(sTT('null'), ref2), dsc3.putInteger(sTT('compID'), compID)

executeAction(sTT('setPlacedLayerComp'), dsc3, DialogModes.NO)

Anyway to see that works - for both files you sent - I alerted compID instead of above code nested in script you find below:

function sTT(v) {return stringIDToTypeID(v)}

(ref1 = new ActionReference()).putName(sTT('layer'), 'Element')

j = (dsc1 = executeActionGet(ref1)).getInteger(sTT('itemIndex')) - 1

while(typeIDToStringID(dsc1.getEnumerationValue(sTT(lS = 'layerSection'))) != lS + 'End') {

     (ref1 = new ActionReference()).putIndex(sTT('layer'), j--); (dsc1 = executeActionGet(ref1))

     .putReference(sTT('null'), ref1), dsc1.putBoolean(sTT('makeVisible'), false)

     executeAction(sTT('select'), dsc1, dmno = DialogModes.NO)

     if (nme = dsc1.getString(sTT('name')).match(/\w+$/)) {

          (function bin(){

               /*beginning*/e = sTT('placedLayerExportContents');

               (dsc2 = new ActionDescriptor()).putPath(sTT('null'), fle)

               executeAction(e, dsc2, dmno), fle.open('r'); var r = fle.read()

               length = nme[0].length * 2, reg = 'Nm  TEXT.{4}.{0,' + length

               + '}.{6}compIDlong.{4}'; var m = r.match(RegExp(reg, 'g'))

               for(; i < m.length;) {if (RegExp(nme).test(m[i++].slice(12, -20)

               .match(/[^\x00]/g).join(''))) {compID = eval('0x' + m[--i]

               .slice(-4).replace(/./g, function(v) {return v.charCodeAt()

               .toString(16)})); break}} fle.close(), fle.remove();/*end*/

               (ref2 = new ActionReference()).putEnumerated(sTT('layer'),

               sTT('ordinal'), sTT('targetEnum')); (dsc3 = new ActionDescriptor())

               .putReference(sTT('null'), ref2), dsc3.putInteger(sTT('compID'), compID)

               executeAction(sTT('setPlacedLayerComp'), dsc3, dmno)

          })((fle = File('~/desktop/.psb')).encoding = 'binary')

     }

}

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
Explorer ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

With the last code I always get an error:

Error 21: undefined is not an object

--> (dsc3 = new ActionDescriptor()).putReference(sTT('null'), ref2), dsc3.putInteger(sTT('compID'), compID)

But I've figured it out by just changing to this (semicolons instead of commas):

(dsc3 = new ActionDescriptor()).putReference(sTT('null'), ref2); dsc3.putInteger(sTT('compID'), compID);

Ha, and it works! Bingo! Now the Smart Object layer comps became applied!

You had to give me some examples of those no latin and space characters

Any name with spaces. E.g. rename the Smart Object to something like "Red with spaces". And then edit Smart Object itself and change "Red" layer comp name to the same "Red with spaces". And this will not work.

Or any cyrillic name gives the same behaviour. E.g. "Красный".

And still does not work with Linked Smart Objects.

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 ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

There should not be difference using semicolons / commas in this kind of construction. I always do so and never met error. So I'm surprised you had to change commas to semicolons in this case. Most importatnt is that works with new delimiters.

You asked for script that works with layer names schemas like 'Element Red' and 'Red' for Layer Comp. So this is obvious when you change name of Smart Object to 'Red with spaces', and even go further and change name of comp to 'Red with spaces' as well then script won't work. How that has to recognise that name if you wanted they were precised to 'Element Red' for layers and 'Red' for comps? You must decide what you want, because now I see you forgot what you came with Non english characters do not work because you wanted english names for colours, at least you did not mention anything they can appear with other characters. I can't help with linked layers as I don't use CC and you said it's something new. As far as I have CS6 still I can only help with things I can use myself, or like in case of this script they are some way available.

For now I did everyting you wanted in original post. You got script there wasn't available for many years on this forum and nowhere, while coders could do nothing like it (I do have no idea why?) to write themselves something like it but begging Adobe to do it for them. And before some plugin was not released they could not make some time to wrtie similar script 😕

As to cyrylic letters it's possible to do but needs extra work as they are not written in binaries as regular letters you can see.

If I used: /[\wАаБбВвГгДдЕеЁёЖжЗзИиЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЪъЫыЬьЭэЮюЯя]+$/

that was not be still enough as first I had to change every such encoded letter from binaries to that they are used in real life.

More about original regex I wrote in previous post that was later edited by me, so I'm not sure you saw its whole content

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
Explorer ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

I've changed that part of code to comma and it still works. Maybe I missed something as I totally do not understand such kind of constructions you've used E.g. I absolutely do not understand why there should be comma but not semicolon.

Yes IT WORKS! It's absolutely amazing and I'm very appreciated to you! 

And I did not forget what I came with. When I wrote this topic I had no hope that anybody helps me with that So just not to frighten anyone I've put a simple example of layer names (Name+LayerCompName). I did not keep in mind that that there could be an issue with spaces

And yes! You did impossible! Nobody was able to do this but Kukurykus was! You're a genius!

Forget about cyrillic. It's not such important.

Linked Objects is still an issue. It's a pity you're not able to help with them. I'll try to play with that function I've found but do not think I'll be able to get it work.

Updated

Yes, there is no problem with spaces at all!! All layercomps are always one single word. But if to use them with spaces how the regexp should be changed to fit them? E.g. if to use @ as a separator between layer name and layercomp name?

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 ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

You can use both semicolons and commas between separated lines of code they could be also started from new lines (each of them). In earlier ECMA versions there always had to be semicolons at end of line, now they have to be only when two or more codes are in the same line. Theres difference in many cases you cant replace semicolon to comma but in this situation there is no difference what you use.

In update of last post you say there is no problem with spaces, then there is... well give few examples of named layers and layer comps, as there are too many possible regex matches to solve it to just waste time and say what should be just used.

I didn't test it but in 11th line you could replace current regex to /@?\w+/ (@ character is written to binaries like you see it)

Regarding cyrylic it's not worth now to start it yet while linked objects you must get more answers to give me proper infos.

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 ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

Kukurykus  wrote

You can use both semicolons and commas between separated lines of code they could be also started from new lines (each of them). In earlier ECMA versions there always had to be semicolons at end of line, now they have to be only when two or more codes are in the same line. Theres difference in many cases you cant replace semicolon to comma but in this situation there is no difference what you use.

In update of last post you say there is no problem with spaces, then there is... well give few examples of named layers and layer comps, as there are too many possible regex matches to solve it to just waste time and say what should be just used.

I didn't test it but in 11th line you could replace current regex to /@?\w+/ (@ character is written to binaries like you see it)

Regarding cyrylic it's not worth now to start it yet while linked objects you must get more answers to give me proper infos.

I don't know what you are doing but most every one of your posts gets kicked back to the Moderation queue Multiple time.

I approve it. It gets kicked back. I approve it again it gets kicked back. this happen over and over.

If you are making changes to it multiple times please stop doing that. Compose it properly before posting.

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 ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

It's sad to say but jive forums doesn't let to compose text before submitting it. There is no Preview option. Maybe enable 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 ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

Use the Advanced Editor. The link to it is in the upper right hand corner of the reply window.

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 ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

That doesn't give preview I can have for example in PHP forums. So see how text will be looking after I submit it.

Btw, there was good time (nearly 2 months) that I was taken off from moderation and my posts were accepted without checking. Maybe just do it again

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
Explorer ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

Kukurykus, ha, I looked through your code once more and see that you've already able to get both layer comp name and compID from binary file. Still I can not adopt the script to get these pairs to use them with my switchPlacedLayerComp() function.

And one more issue is that if the Layer Comp name has spaces inside or even has non latin symbols it's became stripped somehow or does not appears at all.

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 ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

Yes you are right I did not mean edit, just switch, only wrote so All layers were renamed to colour names? That shouldn't happen. Ps informed me when I were opening your both files that their data is specific as they were created in later version, fortunately I could use them, but my script did not work with them completely as not any last layer comp item was selected inside smart object, so in binaries (when I did that and saved files it worked). That is no problem as you still needed script to be modified. Maybe now newest version of script will work however objects are embed or linked - as it only looks for layer comp name and id pairs to apply compID value. You had to give me some examples of those no latin and space characters.

EDIT:

I changed in the script:

var m = r.match(/Nm  TEXT.{4}.*?.{6}compIDlong.{4}/g)

to:

var m = r.match(/Nm  TEXT.{4}.{0,20}.{6}compIDlong.{4}/g)

so now script is going to work 80 times faster! The only limitation is that colours you use can't be longer than 10 characters (each letter in binaries in that part is preceded by \x00 so it's why I put there 20 (as it's 2 * 10 characters). If you have longer names then that value should be increased to bigger. And then I changed that again doing it mathematically that each time program knows the upper limit of colour characters. It won't speed up script over 80 times, be make it's always more exact.

length = nme[0].length * 2, reg = 'Nm  TEXT.{4}.{0,' + length

+ '}.{6}compIDlong.{4}'; var m = r.match(RegExp(reg, 'g'))

A problem with non latin and space character is that I adapted script to your example. I assumed there's always something like 'Element Red' name, so 2 words where first is always the same, then we have space and then single word colour name, where first letter is uppercase. To match it I used dsc1.getString(sTT('name')).match(/\w+$/) where \w+ is for letters/digits/_ and $ marks end of line. If you have other patterns just show them - as there is way to write more complex regex matching wider range of cases still without matching too many characters. Just test everything and tell me what else can be changed.

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
Explorer ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

The name "Element" was taken as an example. In my case it could be a single word or a sentence (sometimes cyrillic) with some spaces. I can assume that 30 characters should be enough in most of the cases but even if not it seems I will be able to increase it in your regexp.

One thing that I use to determine which layer comp of the smart object to switch on is the last word (I name it postfix) of this sentence (layer name). It's always equal the one of the smart object layer comps names and could not be more than one word. Often but not always I separate this last word with @ character. E.g. the layer name can be "Element One Stretched @Red". So one of its layer comp names would be just "@Red". Thats all here. If it's too difficult to figure out cyrillic issue forget about. I'll try to avoid such names. But spaces are used very often.

About Linked Smart Objects. There is no command for them "Export Content" that Embed ones have. So that's why the script could not proceed with them. But I've found that there is a possibility to get this linked psb file path here. So it seems that there is a way to check if smart object has path then use it for bin() function to get compIDs. And if not then use current one routine.

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 ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

There's no problem with many words in name of layer, even having more than 30 characters. There's also no problem with @ character, even when sometimes it is not present as first character of last word layer name. I am able to make script with cyrylic letters, but that would make process slower, while now it's super fast what I did not suppose it may be. Less than 50 milliseconds for one smart object! I wonder how fast plugin works? I completely don't understand problem with spaces ???

You said it compares only last word of layer name (so no spaces between letters) to single word of layer comp name (theres only one word and no spaces). So what spaces you are talking about? You gave me earlier example of layer name 'Red with spaces', but I still don't understand is it full name of layer where 'spaces' word has to be compared with single 'spaces' word of layer comp name? Or you mean layer name is: 'R e d'? That had no sense as you said it's always last word of layer name, but maybe you understand last word also as word with spaces between its letters? So is that layer name: 'Element R e d' & this is layer comp name: 'R e d', or 'Element Red with spaces' is layer name & 'Red with spaces' is layer comp name, well ?!

I do not know how linked objects looks like in layers panel, do not know is it possible they sometimes have path and other time not? If so has it something to do .psd file wasn't saved yet? Send me other smart objects structure with linked objects, I'll see are they written to binaries. If you can't export it, you can't save it, but it seems it can have path? When is it created, can user do it manually, how those linked objects work, what's difference between them and normal smart/placed layers?

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
Enthusiast ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

Generator plugin is by default in CC and higher. Layers comps in properties panel are since CC only.

Try to google github page with generator examples of code.

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
Explorer ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

Yes, I've already googled it and installed generator. Some test scripts work fine but still it's a bit difficuld for me to undersatand how to rewrite or adopt my code to be usable as generator plugin.

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 ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

As I hardly understood you need to find the LayerComp ID for the smart object.
This will probably help you.

try {

var r = new ActionReference();   

r.putProperty(charIDToTypeID("Prpr"), stringIDToTypeID("smartObjectMore"));   

r.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));

var list = executeActionGet(r).getObjectValue(stringIDToTypeID("smartObjectMore")).getObjectValue(stringIDToTypeID("compInfo")).getList(stringIDToTypeID("compList"));

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

    {

    var d = list.getObjectValue(i);

    var nm = d.getString(stringIDToTypeID("name"));

    var cm = d.getString(stringIDToTypeID("comment"));

    var id = d.getInteger(stringIDToTypeID("ID"));

    alert(nm + " ID:" + id, "COMP № "+0);

    }

}

catch(e) { alert("This layer has no layercomps") }

P.S. Or maybe not )

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 ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

Would be really cool that worked. I can't check it with CS6 of course but if Jarda Berezasaid there's needed plugin then I believe there is or you have to play with binaries I read today there was bug with smartObjectMore, but maybe not anymore and now it will be working

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
Explorer ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

I've add some more stuff to Kukurykus code and now it can understand linked smart objects as well. And as it usually happens after all the work was done and script tested r-binwrote his post with a more simple solution that uses standart functions. And even understands cyrillic! LOL

Thanks a lot to all! But especially to Kukurykus who found not standart but still perfect solution.

Guys you're awesome!

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 ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

What code you used that worked with linked smart objects? Share it, let everyone have this knowledge as it seems to be very useful stuff for many people, even those who don't know it yet

What about my post that has number 14 on in this theard. Can you after all explain to me what was problem with spaces I asked there about and give some examples, however I understand this problem is gone now, right?

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
Enthusiast ,
Feb 18, 2018 Feb 18, 2018

Copy link to clipboard

Copied

r-bin your code is better and should be fastest. I thought that this object contains only IDs without names but they are present at least since CC2015.5

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