Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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…
Copy link to clipboard
Copied
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
Find more inspiration, events, and resources on the new Adobe Community
Explore Now