Copy link to clipboard
Copied
Hi everybody,
my think goes to JET and his script:
#target illustrator
/*
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).
To Use:
Document must have at least one Symbol defined.
Select objects. Run the script.
*/
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;
currObj.remove();
redraw();
}
So.. this script works fine but, in fact i need that symbols keep same layer, same order and same name of previous.
Is there a simple method to swap symbol item by another one ? or need i to rename created layer (delete previous) and move it in correct order ?
Thanks in advance, art.chrome
(i don't know, but i'm trying )
Try add this line…
currInstance.move(currObj, ElementPlacement.PLACEBEFORE);
before this line…
currInstance.selected=true;
Copy link to clipboard
Copied
Try add this line…
currInstance.move(currObj, ElementPlacement.PLACEBEFORE);
before this line…
currInstance.selected=true;
Copy link to clipboard
Copied
Woohh,
Many thanks Muppet Mark simply and effective !
(and special thanks JET)
Regards, art.chrome
Copy link to clipboard
Copied
I have many a JET script too…
Copy link to clipboard
Copied
Here is a small variation on JET's original script.
Changes:
function swapSymbols(symbolName) {
var aDoc = app.activeDocument;
for (i = 0; i < aDoc.selection.length; i++) {
var currObj = aDoc.selection[i];
var currName = currObj.name;
var currLeft = currObj.left;
var currTop = currObj.top;
var currWidth = currObj.width;
var currHeight = currObj.height;
var currInstance = aDoc.symbolItems.add(aDoc.symbols[symbolName]);
currInstance.width *= currHeight / currInstance.height;
currInstance.height = currHeight;
currInstance.left = currLeft - (currInstance.width - currWidth/2) + (currInstance.width/2);
currInstance.top = currTop;
currInstance.name = currName;
currInstance.selected = true;
currObj.remove();
redraw();
}
}