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

Create symbol from layer PageItems

New Here ,
Mar 25, 2011 Mar 25, 2011

I'm having trouble figuring out how to create a single symbol from all the objects within a single layer.

Despite what the reference docs say, it doesn't seem that PageItems is a valid argument to pass into Symbols.add()...

Anyone have any insight or maybe some example code?

Thanks in advance!

TOPICS
Scripting
1.3K
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 ,
Mar 25, 2011 Mar 25, 2011

pageItems by itself is not the correct syntax, it should be

pageItems(1) // not really 1, but a number

if you need everything in a given layer, add all pageitems to a group then pass the group pageitem to the Symbols.Add() function

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 28, 2011 Mar 28, 2011

Hmm..  Creating a group seems to be troublesome as well...

The following code gives me

undefined is not an object

on line

var group = doc.groups.add(itemArray);

var doc =app.activeDocument;

var layer = doc.activeLayer;

layer.hasSelectedArtwork = true;

var itemArray = new Array;

for (var i in selection)

{

    itemArray.push(i);

}

var group = doc.groups.add(itemArray);

Symbols.Add(group);

My goal is simply to take all the objects on a given layer and create a symbol from them...  Sounded simple when I set out to figure it out.   Turning out not to be so simple...

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 28, 2011 Mar 28, 2011

this will do it

// script.name = turnActiveLayerIntoSymbol.jsx;
// script.description = creates a symbol out of all pageItems in the active layer;
// script.required = an open doc with at least one pageItem;
// script.parent = Carlos Canto // 3/28/11;
// script.elegant = false;

var doc =app.activeDocument;
var layer = doc.activeLayer;
var grp = layer.groupItems.add(); // add a group

for (i=layer.pageItems.length-1; i>=1 ; i--) // loop backwards
    {
        layer.pageItems.moveToBeginning(grp); // add each pageItem to the group
     }

doc.symbols.add(grp);
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
Participant ,
May 10, 2012 May 10, 2012

Carlos will this script answer my latest Post in the forum asking to make 35 layers into 35 symbols? Or can i make the script make individual symbols out of grouped items all on the same layer?

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
Participant ,
May 10, 2012 May 10, 2012

Carlos i've tested this one after reading more and understanding what you wrote. Is there a way for it to do every layer not just stop after doing one Layer?

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
Guru ,
May 10, 2012 May 10, 2012

Please don't mix your threads it gets very confusing to follow who responded with what when this happens… Yes its possible to do this for every layer… Stick to a thread…

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
Participant ,
May 10, 2012 May 10, 2012
LATEST

ok i was trying to find the answer and i didnt want to not search the forum thouroughly...i will post this in my other thread.

Thanks Mark

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