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

How do I make a symbol from selection?

Enthusiast ,
Oct 26, 2014 Oct 26, 2014

I've got the below script, but it's not working. I'm trying to select all the art in the document on different layers, and create a symbol. So far I have the first part down, but can't figure out how to reference what is selected. actDoc.selection comes out as undefined. I've also tried to use "actDoc.PageItem.selected = true" and a few other variants, but I'm coming up empty. Anyone have recommendations for this?

actDoc = app.activeDocument

var layerCount = actDoc.layers.length;

if(layerCount > 1) {

    for(i=0;i<layerCount;i++) {

    actDoc.layers.hasSelectedArtwork = true // selects all layers

    }

   actDoc.symbols.add(actDoc.selection); // <---------- Here's where the error is thrown

}

TOPICS
Scripting
503
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
Community Expert ,
Oct 26, 2014 Oct 26, 2014

if you want to make a symbol out of multiple items, group them first, the add() method takes one item as argument.

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
Enthusiast ,
Oct 26, 2014 Oct 26, 2014

Thanks! That makes sense! Now I'd like to put a layer with sublayers into a symbol to maintain any effects that are on the sub layers. I have an action that runs, that does this with nested layers like this. I used to just let it group everything, but then found some effects were falling off. I tried the below, but it didn't work, and states that it's an illegal argument. Is there any way to acheive this?

                        layer = actDoc.layers.getByName('Editorial'); //get a reference to the newly created raster item 

                        newsymbol = actDoc.symbols.add(layer); //add the raster item to the symbols  

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 ,
Oct 28, 2014 Oct 28, 2014
LATEST

no, I don't think you can add layers, the arguments must be pageItems

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