Copy link to clipboard
Copied
Hi guys i have a big illustrator file full of layers and I realized to late that I should have used symbols instead of object.
I found this amazing script that replace object by symbols:
My only problem is that the script rename every layer name by "new symbol", I would like to keep the names like they are.
Would you have a line for me to add to the code to change that?
I tried that: var layernames =currentLayer.name (failed)
Thank you
Copy link to clipboard
Copied
it does not rename the layers.
it just replaces the items with symbols,
and it does not keep layer structure intact.
but if it's doing what you need, then that's fine.
what you are wanting is to rename each symbol instance with the original objects name.
currInstance.name = currObj.name;
I also moved the redraw line outside the for loop.
this means you can undo (ctrl + Z) just once, instead of many times. if that makes sense.
/*
JET_ReplaceWithSymbol.jsx
A Javascript for Adobe Illustrator
Purpose: Replaces selected items with Instances of a Symbol from the Symbols Panel.
The desired Symbol can be defined by its index number (its number of occurrance in the Panel).
*/
var docRef=app.activeDocument;
var symbolNum=prompt("Enter the number of the Symbol you want to replace each selected object",1);
for(i=0;i<docRef.selection.length;i++){
var currObj=docRef.selection;
var currLeft=currObj.left;
var currTop=currObj.top;
var currWidth=currObj.width;
var currHeight=currObj.height;
var currInstance=docRef.symbolItems.add(docRef.symbols[symbolNum-1]);
currInstance.width*=currHeight/currInstance.height;
currInstance.height=currHeight;
currInstance.left=currLeft;
currInstance.top=currTop;
currInstance.selected=true;
currInstance.name = currObj.name;
currObj.remove();
}
redraw();
Copy link to clipboard
Copied
Hi,
First thank you for answering my question.
Unfortunately it doesn't work, I tried few times, sometimes the layer name is staying (20%) but the layers are moved back from the sublayers.
Any other suggestions?
Regards
Copy link to clipboard
Copied
Hi,
The layers are still being moved but...
I put the "redraw(); inside the loop, just to try....
I select the script---> objects are replace with my symbol ---> layers are rename "new Symbols" ---> I do cmd+z ----> layers name become like they were before (strange I know) ----> shift+cmd+z -----> done (with layers at the wrong place}
....
Copy link to clipboard
Copied
Any chance I can see the file.
im not sure I get what your saying.
THis is script won't change your layer names.
but it will delete all selected items.
REplacing them with symbols.
all the symbols are placed in the top layer.
so it will destroy your document structure.
if you can post your file or an example it may make it clearer
Copy link to clipboard
Copied
I can't share the full file due to privacy but I will make a sample as soon as I have some time soon.
Copy link to clipboard
Copied
once I see that it should make it clearer.
would be worth seeing 1 that is a before, and 1 that shows what you want it to be when your done.
Copy link to clipboard
Copied
Hey, I need this JET_ReplaceWithSymbol
Copy link to clipboard
Copied
the script is right here at the top of the page, the OP posted it
Find more inspiration, events, and resources on the new Adobe Community
Explore Now