Edit symbol in Illustrator using javascript

I am trying to create a symbol or copy selected objects to a symbol in Illustrator 5.1 using JavaScript with no success. Here is my code:

sourceDoc.selection = null; // deselect everything  
sourceDoc.selectObjectsOnActiveArtboard(); // select all in artboard  
sel = sourceDoc.selection;
sourceDoc.symbols.add(sel); // <--- NOT WORKING

for (k=0; k<sel.length; k++) {         
    var newItem = sel[k].duplicate(destDoc.symbols.getByName("Symbol1"),ElementPlacement.PLACEATEND); 
    //^^^^ NOT WORKING
}  

      

Please help me how to fix this. Thank you!

+3


source to share


1 answer


sourceDoc.selection

need an index number to be successful.

Use sourceDoc.selection[0]

for example



if you have, for example, four elements, then the last created element is at index 0 and the first one is at index 3.

0


source







All Articles