Can I batch create symbols from layers?

I have Illustrator files of some fairly complicated schematics that I will be bringing in to Flash. The layers are already well organized and named so I would like to select particular layers, hit a "create symbols" button and have all of the selected layers turned into separate symbols that have the same name as their layer name. I would even be willing to code something to do this but I can't find any information about how it can be done.
I know that I can import an Illustrator file into Flash and select layers that I can then make into movie clips but again, I have to manually select the layer, tell it to be a movie clip and then give it an instance name. I would be happy to try to automate that process as well but haven't found any info on how it can be done either.
Does anyone have any ideas on how I can batch create symbols from my existing layers?

I figured this out using recursion. Pasted here in case it helps someone else:
#target Illustrator
var docRef = app.activeDocument;
var layersRef = app.activeDocument.layers;
var layersCount = layersRef.length;
var mySymbolInstance = null;
if ( app.documents.length > 0 ) {
    // if the file is not empty, loop through all levels
    recurseLayers(docRef.layers);
    clearEmptyLayers();
    alert("I'm done");
function recurseLayers(objArray) {
    // loop through main layers
    for (var l = 0; l < objArray.length; l++) {
        // loop through secondary layers
        if (objArray[l].layers.length > 0) {
            recurseLayers(objArray[l].layers);
        // loop through first level groups
        if (objArray[l].groupItems.length > 0) {
            recurseGroups(objArray[l].groupItems);
            // create a group
            var layerGrp = objArray[l].groupItems.add();
            //give new group the same name as the old group
            var layerName = objArray[l].name;
            layerGrp.name = layerName;
            // get all page items from group
            var layerGrpPageItems =  objArray[l].pageItems;
            //alert("how many group page items: " + layerGrpPageItems.length);
            for (var li= layerGrpPageItems.length-1; li >0; li--) {
                // will become the symbol name
                var layerPageItemName = layerGrpPageItems[li].name;
                // if it's not already a symbol, make it into one
                if (layerGrpPageItems[li].typename == "SymbolItem") {
                    layerGrpPageItems[li].moveToBeginning(layerGrp);
                } else {
                    // create symbols
                    createSymbol(layerGrpPageItems[li], layerGrpPageItems[li].name);
                    // add symbols to group
                    mySymbolInstance.moveToBeginning(layerGrp);
                    // remove original content
                    layerGrpPageItems[li].remove();
            // create symbols from layer
            createSymbol(layerGrp, layerName);
            // remove original layer content
            layerGrp.remove();
function recurseGroups(objArray) {
    for (var g = 0; g < objArray.length; g++) {
        // loop through second level groups
        if (objArray[g].groupItems.length > 0) {
            recurseGroups(objArray[g].groupItems);
            // create a group
            var grp = objArray[g].groupItems.add();
           //give new group the same name as the old group
            var groupName = objArray[g].name;
            grp.name = groupName;
            //alert("which group is this? " + groupName);
            // get all page items from group
            var grpPageItems =  objArray[g].pageItems;
            //alert("how many group page items: " + grpPageItems.length);
            for (var gi= grpPageItems.length-1; gi >0; gi--) {
                // will become the symbol name
                var pageItemName = groupName + "_" + grpPageItems[gi].name;
                createSymbol(grpPageItems[gi], pageItemName);
                // add symbols to group
                mySymbolInstance.moveToBeginning(grp);
                // remove original content
                grpPageItems[gi].remove();
function createSymbol(element, elementName) {
    //alert("elementName" + elementName);
    // create symbols from all items in the group
    var symbolRef = docRef.symbols.add(element);
    //alert("element unnamed before: " + elementName);
    // if the element name is empty, give it a name
    var addElementIndex = 0;
    if(elementName == "") {
        elementName = "unnamed" + addElementIndex;
        addElementIndex++;
    // loop through all the symbols in the document
    var symbolCount = docRef.symbols.length;
        for(var s=0; s<symbolCount; s++)  {
            // existing symbols
            var symbolCheck = docRef.symbols[s];
            //alert(symbolCheck.name);
            var addIndex = 0;
            // if the name already exists, add the index number to it and increment
            if(elementName == symbolCheck.name) {
                elementName = elementName + addIndex;
                addIndex++;
    symbolRef.name = elementName;
    //alert("symbol name: " + symbolRef.name);
    mySymbolInstance = docRef.symbolItems.add(symbolRef);
    mySymbolInstance.left = element.left;
    mySymbolInstance.top = element.top;
function clearEmptyLayers() {
    if (documents.length > 0 && activeDocument.pathItems.length >= 0){
        for (var ni = layersCount - 1; ni >= 0; ni-- ) {
            // get sub layers
            var topLayer = docRef.layers[ni];
            for(var ii = topLayer.layers.length - 1; ii >=0; ii--) {
                // delete empty sub layers
                if ( topLayer.layers[ni].pageItems.length == 0 ) {
                    topLayer.layers[ni].remove();

Similar Messages

  • Can't create frames from layers CS6

    I have looked at multiple tutorials saying that to create an animated gif in Photoshop CS6, you just open the Timeline palette and select "Create Frames from Layers" from the dropdown. I don't see this option, not even grayed out. What is the problem?

    Thanks - didn't realize it was even a button. Thought picking it from the dropdown was enough.  O_o

  • Illustrator script to create symbols from images in folder

    Time to give back to the community...
    Here is a script I recently devised to bulk create symbols from images in a folder. Tested with Illustrator CC 2014.
    // Import Folder's Files as Symbols - Illustrator CC script
    // Description: Creates symbols from images in the designated folder into current document
    // Author     : Oscar Rines (oscarrines (at) gmail.com)
    // Version    : 1.0.0 on 2014-09-21
    // Reused code from "Import Folder's Files as Layers - Illustrator CS3 script"
    // by Nathaniel V. KELSO ([email protected])
    #target illustrator
    function getFolder() {
      return Folder.selectDialog('Please select the folder to be imported:', Folder('~'));
    function symbolExists(seekInDoc, seekSymbol) {
        for (var j=0; j < seekInDoc.symbols.length; j++) {
            if (seekInDoc.symbols[j].name == seekSymbol) {
                return true;
        return false;
    function importFolderContents(selectedFolder) {
        var activeDoc = app.activeDocument;     //Active object reference
      // if a folder was selected continue with action, otherwise quit
      if (selectedFolder) {
            var newsymbol;              //Symbol object reference
            var placedart;              //PlacedItem object reference
            var fname;                  //File name
            var sname;                  //Symbol name
            var symbolcount = 0;        //Number of symbols added
            var templayer = activeDoc.layers.add(); //Create a new temporary layer
            templayer.name = "Temporary layer"
            var imageList = selectedFolder.getFiles(); //retrieve files in the folder
            // Create a palette-type window (a modeless or floating dialog),
            var win = new Window("palette", "SnpCreateProgressBar", {x:100, y:100, width:750, height:310});
            win.pnl = win.add("panel", [10, 10, 740, 255], "Progress"); //add a panel to contain the components
            win.pnl.currentTaskLabel = win.pnl.add("statictext", [10, 18, 620, 33], "Examining: -"); //label indicating current file being examined
            win.pnl.progBarLabel = win.pnl.add("statictext", [620, 18, 720, 33], "0/0"); //progress bar label
            win.pnl.progBarLabel.justify = 'right';
            win.pnl.progBar = win.pnl.add("progressbar", [10, 35, 720, 60], 0, imageList.length-1); //progress bar
            win.pnl.symbolCount = win.pnl.add("statictext", [10, 70, 710, 85], "Symbols added: 0"); //label indicating number of symbols created
            win.pnl.symbolLabel = win.pnl.add("statictext", [10, 85, 710, 100], "Last added symbol: -"); //label indicating name of the symbol created
            win.pnl.errorListLabel = win.pnl.add("statictext", [10, 110, 720, 125], "Error log:"); //progress bar label
            win.pnl.errorList = win.pnl.add ("edittext", [10, 125, 720, 225], "", {multiline: true, scrolling: true}); //errorlist
            //win.pnl.errorList.graphics.font = ScriptUI.newFont ("Arial", "REGULAR", 7);
            //win.pnl.errorList.graphics.foregroundColor = win.pnl.errorList.graphics.newPen(ScriptUIGraphics.PenType.SOLID_COLOR, [1, 0, 0, 1], 1);
            win.doneButton = win.add("button", [640, 265, 740, 295], "OK"); //button to dispose the panel
            win.doneButton.onClick = function () //define behavior for the "Done" button
                win.close();
            win.center();
            win.show();
            //Iterate images
            for (var i = 0; i < imageList.length; i++) {
                win.pnl.currentTaskLabel.text = 'Examining: ' + imageList[i].name; //update current file indicator
                win.pnl.progBarLabel.text = i+1 + '/' + imageList.length; //update file count
                win.pnl.progBar.value = i+1; //update progress bar
                if (imageList[i] instanceof File) {         
                    fname = imageList[i].name.toLowerCase(); //convert file name to lowercase to check for supported formats
                    if( (fname.indexOf('.eps') == -1) &&
                        (fname.indexOf('.png') == -1)) {
                        win.pnl.errorList.text += 'Skipping ' + imageList[i].name + '. Not a supported type.\r'; //log error
                        continue; // skip unsupported formats
                    else {
                        sname = imageList[i].name.substring(0, imageList[i].name.lastIndexOf(".") ); //discard file extension
                        // Check for duplicate symbol name;
                        if (symbolExists(activeDoc, sname)) {
                            win.pnl.errorList.text += 'Skipping ' + imageList[i].name + '. Duplicate symbol for name: ' + sname + '\r'; //log error
                        else {
                            placedart = activeDoc.placedItems.add(); //get a reference to a new placedItem object
                            placedart.file = imageList[i]; //link the object to the image on disk
                            placedart.name =  sname; //give the placed item a name
                            placedart.embed();   //make this a RasterItem
                            placedart = activeDoc.rasterItems.getByName(sname); //get a reference to the newly created raster item
                            newsymbol = activeDoc.symbols.add(placedart); //add the raster item to the symbols                 
                            newsymbol.name = sname; //name the symbol
                            symbolcount++; //update the count of symbols created
                            placedart.remove(); //remove the raster item from the canvas
                            win.pnl.symbolCount.text = 'Symbols added: ' + symbolcount; //update created number of symbols indicator
                            win.pnl.symbolLabel.text = 'Last added symbol: ' + sname; //update created symbol indicator
                else {
                    win.pnl.errorList.text += 'Skipping ' + imageList[i].name + '. Not a regular file.\r'; //log error
                win.update(); //required so pop-up window content updates are shown
            win.pnl.currentTaskLabel.text = ''; //clear current file indicator
            // Final verdict
            if (symbolcount >0) {
                win.pnl.symbolLabel.text = 'Symbol library changed. Do not forget to save your work';
            else {
                win.pnl.symbolLabel.text = 'No new symbols added to the library';
            win.update(); //update window contents
            templayer.remove(); //remove the temporary layer
        else {
            alert("Action cancelled by user");
    if ( app.documents.length > 0 ) {
        importFolderContents( getFolder() );
    else{
        Window.alert("You must open at least one document.");

    Thank you, nice job & I am looking forward to trying it out!

  • Get the ID of a dynamically created symbol from library, INSIDE another symbol.

    Hi everyone,
    I'm trying to get the id from a dynamic created symbol from library.
    When dynamically creating the symbol directly on the stage (or composition level), there's no problem.
    But I just can't get it to work when creating the symbol inside another symbol. 
    Below some examples using both "getChildSymbols()" and "aSymbolInstances" 
    // USING "getChildSymbols()" ///////////////////////////////////////////////////////////////////////// 
    // ON THE STAGE 
    var m_item = sym.createChildSymbol("m_item","Stage");
    var symbolChildren = sym.getChildSymbols(); 
    console.log(symbolChildren[0].getSymbolElement().attr('id')); // ok eid_1391853893203
    // INSIDE ANOTHER SYMBOL
    var m_item = sym.createChildSymbol("m_item", sym.getSymbol("holder").getSymbolElement()); 
    var symbolChildren = sym.getSymbol("holder").getChildSymbols(); // Am i using this wrong maybe?
    console.log(symbolChildren.length) // returns 0 so can't get no ID either
    // USING "aSymbolInstances"" ////////////////////////////////////////////////////////////////////////// 
    // ON THE STAGE
    var m_item = sym.createChildSymbol("m_item","Stage"); 
    console.log(sym.aSymbolInstances[0]); // ok (i guess) x.fn.x.init[1] 0: div#eid_1391854141436
    // INSIDE ANOTHER SYMBOL
    var m_item = sym.createChildSymbol("m_item", sym.getSymbol("holder").getSymbolElement());
    console.log(sym.getSymbol("holder").aSymbolInstances[0]); // Javascript error in event handler! Event Type = element 
    In this post http://forums.adobe.com/message/5691824 is written: "mySym.aSymbolInstances will give you an array with all "names" when you create symbols"
    Could it be this only works on the stage/ composition level only and not inside a symbol? 
    The following methods to achieve the same are indeed possible, but i simply DON'T want to use them in this case:
    1) Storing a reference of the created symbol in an array and call it later by index.
    2) Giving the items an ID manually on creation and use document.getElementById() afterwards.
    I can't believe this isn't possible. I am probably missing something here.
    Forgive me I am a newbie using Adobe Edge!
    I really hope someone can help me out here.
    Anyway, thnx in advance people!
    Kind Regards,
    Lester.

    Hi,
    Thanks for the quick response!
    True this is also a possibility. But this method is almost the same of "Giving the items an ID manually on creation and use document.getElementById() afterwards".
    In this way (correct me if i'm wrong) you have to give it an unique ID yourself. In a (very) big project this isn't the most practical way.
    Although I know it is possible.
    Now when Edge creates a symbol dynamically on the Stage (or composition level) or inside another symbol it always gives the symbol an ID like "eid_1391853893203".
    I want to reuse this (unique) ID given by Edge after creation.
    If created on the stage directly you can get this ID very easy. Like this;
    var m_item = sym.createChildSymbol("m_item","Stage");
    var symbolChildren = sym.getChildSymbols(); 
    console.log(symbolChildren[0].getSymbolElement().attr('id')); // ok eid_1391853893203
    I want to do exactly the same when created INSIDE another symbol.
    var m_item = sym.createChildSymbol("m_item", sym.getSymbol("holder").getSymbolElement());
    Now how can I accomplish this? How can I get the Id of a dynamically created symbol INSIDE another symbol instead of created directly on the stage?
    This is what i'm after.
    Thnx in advance!

  • Batch create snippets from topics?

    Hi all, just wondering if its possible to batch create snippets from a heap of topics. I've got a lot of topics that I want to create snippets from for single source purposes and having to add them to the snippet library one by one is becoming teadous. Just wondering if it can be done, evena drag and drop or something would speed things up.....
    another quick thing, once I've create these snippets (from topics), the original topic that they were made from is now totally redundant isn't it? meaning I can delete it, I can see any relationship between the 2.
    These are only snippets made from an entire topic.

    Hi there
    I'm unclear on how snippets will help here. Please advise us on exactly how this topic you wish to change to a snippet currently works. Are you inserting it using inline frames or what?
    I'm failing to see why you would want to change an entire topic to a snippet.
    Indeed if you had the topic content as a snippet you would be able to delete the topic as the data is now inside the snippet.
    Snippets are used to insert repetitive text into certain areas of other topics.
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7 or 8 within the day - $24.95!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • Can I batch delete photos from iPad and if so how?

    Can I batch delete photos from iPad and if so how?

    I would add that if you don't want to delete the photos from your computer and want them off your iPad, then (1) create a duplicate folder of the photos to be deleted on your computer (select the folder, then cmd-D), (2) rename the duplicate to something else (thus retaining your computer's photos under a different name), and (3) opening the original folder--the one that was synced to the iPad originally -- and drag its contents to trash. Don't drag the FOLDER to trash---drag its CONTENTS to trash. Now resync this empty folder to your iPad. The photos on the iPad will go away, but you still have them on your computer. I know this is clunky but it works. It sure your be nice to allow you to delete individual photos from a synced folder on the iPad! (and iPhone)

  • I can not delete the $ symbol from template "green grocer" under invoice templates!

    I can not delete the $ symbol from template "green grocer" under invoices, how do I do it, so it will stay deleted and not just keep coming back?

    Select the cells:
    Go to Inspector >Table > Format > Cell Format > Number or whatever you want other than currency.
    The table is actually a spreadsheet.
    Take the time to investigate where all the formatting resides in toolbars, menus and inspectors, most of it is where you would expect to find it.
    Peter

  • In the Animation Timeline panel menu "create frames from layers" is not showing.

    I am watching a tutorial on basic animation and when it gets to the point where they say to open the "Animation Timeline Panel Menu" the panel that opens for me is not the same one in the tutorial.  I am supposed to click on "create frames from layers" but that is not an option.  I'm confused as to why my panel is not the same as the one in the tutorial.

    It could be that you are using a different version of photoshop. Some of the older versions were split into two versions a standard version and an extended version, in most of those versions, it was required to have the extended version to use video editing features.
    Perhaps you could tell us what version of photoshop you have and what operating system.

  • Create symbol from "scratch"

    Hello all!
    I've been busy and haven't checked in here for awhile - I guess for me that's good :-)
    I've got a question that I know I'm not the only one and was wondering what others do...
    I have a stage with everything on it I want, including 6 buttons.  Now I want to create "symbols" that each button will call.  Is there a "correct" way to do this?
    I know I could add a small rectangle off stage, create a symbol from it and then remove it from the stage and create what I want.
    Is there a better way?
    Just curious :-)
    James

    Hey James,
    You can also create symbols and then export them and reuse them in other compositions.
    I usually create all my symbol elements, right-click on all the divs and then convert to symbol. then, if it is something I think I could reuse somewhere else, I export it.
    But different people have different ways of doing things.

  • How can i Use the symbols from the main html page?

    Hello!
    Im trying to find a solution for days!!
    i need to use my symbols from the html page, for example to hide the symbol i want to use: sym.$( "sym1" ).hide(); or to make it draggable (with jquery UI) i wanna use: sym.$( "sym1" ).draggable(); but it doesn't work.
    i know i can do the same from the edgeActions.js file and here is the working code:
          Symbol.bindElementAction(compId, symbolName, "document", "compositionReady", function(sym, e) {
             var ex1 = sym.$( "farmer" );
             //ex1.html( '<input type="text" />' );
             yepnope({
                 both: [
                     "libs/jquery-ui.min.js",
                     "libs/jquery-ui.css",
                 callback: function() {
             ( ex1 ).draggable();
    but the main problem is that it's always include this file as the very last .js, so in case Im trying to use the symbols from the index.html page (For example:  ( ex1 ).draggable();  ) the variables are undefined (because it read the html first)...
    Please Help, Im desperate..
    Thank you very much!!!
    Eran

    Hi, Eran-
    You will want to use the AdobeEdge.* APIs, which should give you access from external JavaScript into your Edge Animation.  The API document has information on that.  However, you will need to wait until the runtime loads, so you should use the bootstrapping method that is outlined in Josh Hatwich's post on our blog:
    http://blogs.adobe.com/edge/2012/05/15/bootstrapping-edge-compositions/
    Hope that helps!
    -Elaine

  • Create symbol from layer PageItems

    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!

    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...

  • Aperture originals are gone, can I re-create them from referenced images?

    I have several photos in aperture with the icon indicating that they are referenced files for which the originals can't be located, and I would like tore-create originals from the thumbnails. All I've been able to find are instructions telling me to reconnect the hard drive containing the original images, or otherwise locate them. But I have no such hard drive. The images with these icons seem to be random; I'll have a project with several hundred photos, and a dozen or two have this icon for no apparent reason. There is no other hard drive to connect or anyplace else to look. Skipping over how that might have happened, I just want to be able to re-create originals from the thumbnails I have (which are actually high enough quality). Is this possible?

    All I've been able to find are instructions telling me to reconnect the hard drive containing the original images, or otherwise locate them. But I have no such hard drive.
    Is your Aperture library referenced? Where are you storing the originals of your images? In the Aperture library or in a folder outside the library? You can only reconnect images that have been imported as referenced, not managed image files.
    First thing to do, save the previews. Create a folder on the Desktop and drag the thumbnails of the images in question to that folder. That will save a jpeg of the preview to that folder.
    The images with these icons seem to be random; I'll have a project with several hundred photos, and a dozen or two have this icon for no apparent reason.
    Select one of the images  in that event, that do not show this problem and use the command "File > Show in Finder". If your image files are referenced, this will open the folder with the originals for that project and you can check, if the originals are still there. If not, your image files are not referenced, and there is no possibility in Aperture to reconnect the original files.
    Can you see the originals in the Finder?

  • Can you export created videos from Premiere Pro Trial to youtube?

    Is it posible to export a created video from a trial of Premiere Pro to social media networks such as youtube or vimeo?

    Yes.
    Mylenium

  • Batch create PDF from multiple InDesign documents

    Is it possible to create PDF files from multiple InDesign documents, or is there perhaps a script that can do this?

    Thanks for this script, it works wonderful.
    It saved me a lot of time.

  • Creating symbol from animated layer

    Hi all. Newbie post here.
    I created an animation of a stick figure in my flash project,
    then decided that I wanted to make it a symbol. Is there some way
    to make the animation/set of frames part of the symbol? When I
    select the layer and its frames, "convert to symbol" becomes dimmed
    (because it's a layer maybe). But other attempts have resulted in
    my just getting the original stick figure over and not the
    sequence.
    I am probably overlooking something obvious, but I can't
    figure it out!
    Thanks for any help.
    Karen

    Actually it's ridiculously complicated ;-)
    Easier to explain visually:
    http://www.stevenlyons.org/uploaded_files/tools2/frames-symbol.jpg

Maybe you are looking for

  • Crystal Report Taking too much time to load

    Dear Support team, Every time I open an existing Crystal Report, it is taking me about 5 minutes to load (Even if its a new and Blank report). Also after one report has loaded for the first time, Loading further reports would take the same long time.

  • Question on creation of t-code for SAP query

    Hello, I posted a thread in here back on 06/20/2007 asking for help on creating a t-code for a SAP query. one of the responses that I recieved was <i>"Sure, all you need to do is get the report name which is generated by the query. You can find this

  • Logic Pro/TDM

    I have PTHD3 (3 PCIe cards) installed on my G5. I want to continue to use Logic Pro for certain things on this computer but had to remove my Symphony card. It is my understanding that Logic Pro can utilize the converters going through the Protools ca

  • Sync purchased music...eve cassidy!!!

    Can anyone help?? I just bought a video ipod..i have had itunes for a while though, and i am using all the latest versions... i synced my music from itunes to my ipod, and all was sucessful It downloaded all my music including all my recently purchas

  • Painting over patterns-- is this even possible?

    Hi all, So basically, here's the situation... I'm trying to paint on an element on a layer (belt for jeans) that has been filled with a pattern to match the pants and tie at the waist. (This is a texture map.) The problem is that PS doesn't seem to w