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

Why can't I do "layer.kind = LayerKind.SMARTOBJECT;"?

New Here ,
Mar 20, 2009 Mar 20, 2009
I want to save each image layer from a PSD separately, and if the image has an effect OR its opacity is < 100%, it needs to be converted to an SmartObject layer and then rasterized (so it becomes a "LayerKind.NORMAL" layer with its effect, rasterized).

I can do it in two clicks, but when I try to do it by scripting, I get an alert saying something like "ArtLayers can't be converted to SmartObjects". I think that makes no sense, because you can do it by right-clicking a layer a selecting "Create smartObject", but whatever...

Is there a workaround for this?
TOPICS
Actions and scripting
2.0K
Translate
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
Adobe
Valorous Hero ,
Mar 20, 2009 Mar 20, 2009
You will have to use ScriptListener to do this...







executeAction( stringIDToTypeID('newPlacedLayer'), undefined, DialogModes.NO );



rasterizeSmart();



function rasterizeSmart() {

var desc201 = new ActionDescriptor();

var ref89 = new ActionReference();

ref89.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );

desc201.putReference( charIDToTypeID('null'), ref89 );

desc201.putEnumerated( charIDToTypeID('What'), stringIDToTypeID('rasterizeItem'), stringIDToTypeID('placed') );

executeAction( stringIDToTypeID('rasterizeLayer'), desc201, DialogModes.NO );

};

Translate
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
New Here ,
Mar 20, 2009 Mar 20, 2009
Thanks Paul! But wow, I don't understand that code at all (lol). Do the "201" and "89" stand for something or are they just random numbers?

On the other hand, my problem is not to rasterize, but to convert a LayerKind.NORMAL to LayerKind.SMARTOBJECT, and I don't see that in the code (maybe it is there but I can't see it).
Translate
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
Valorous Hero ,
Mar 20, 2009 Mar 20, 2009
Yes its all scriptListener code auto generated with the ScriptListner plugin.

this line..
executeAction( stringIDToTypeID('newPlacedLayer'), undefined, DialogModes.NO );

converts the normal layer to a smart layer.
The function will rasterize the layer.

The layer must be the active one.
the "201" and "89" are just auto generated variables.
Translate
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 Expert ,
Mar 21, 2009 Mar 21, 2009
Luis, isnt going via Smart Objects more time-intensive than grouping the layer and then merging the resulting group?
But of course that would trash existing Clipping Masks
Translate
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
New Here ,
Mar 21, 2009 Mar 21, 2009
The purpose is to apply layer masks and effects and get just a rasterized layer, so that would be a great and easy way to do it. I'll try and tell you 😉 Thanks!
Translate
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
New Here ,
Mar 24, 2009 Mar 24, 2009
LATEST
Done! It was a bit difficult to obtain exactly what I needed, but the group->merge solution has worked perfectly. Thank you very very much Christoph! :D
Translate
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