Skip navigation
Currently Being Moderated

Can I batch create symbols from layers?

Apr 19, 2013 2:59 PM

Tags: #illustrator #flash #create #batch #layers #symbols

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?

 
Replies
  • Currently Being Moderated
    Apr 19, 2013 3:45 PM   in reply to theplu

    I would even be willing to code something to do this but I can't find any information about how it can be done.

     

     

    check the Scripting Reference it has plenty of samples, this one is for creating symbols

     

    Creating a symbol
    // Creates a path item from each graphic style
    // then adds each item as a new symbol
    var docRef = documents.add();
    var y = 750;
    var x =25;
    var iCount = docRef.graphicStyles.length;
    for(var i=0; i<iCount; i++) {
    var pathRef = docRef.pathItems.rectangle( y, x, 20, 20 );
    docRef.graphicStyles[i].applyTo(pathRef);
    // are we at bottom?
    if( (y-=60) <= 60 ) {
    y = 750; // go back to the top.
    x+= 200
    }
    redraw();
    docRef.symbols.add(pathRef);
    }
    
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 19, 2013 4:12 PM   in reply to theplu

    Illustrator gets scripted from the inside, javascript (crossplatform), applescript and vbscript

     

    here are the guides

    http://www.adobe.com/devnet/illustrator/scripting.html

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 23, 2013 9:34 AM   in reply to theplu

    unfortunately not everything is exposed to scripting, type of clip is one of those things, but the sample above created "movie" by default.

     

    are you getting "graphic" in your script?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 23, 2013 10:41 AM   in reply to theplu

    you're welcome, I made a test with your script and it does import the symbols as movie clips into Flash...but my test consisted of simple shapes and text, I wonder if the problem is dependent on what kind of art is being made into symbols.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 23, 2013 11:23 AM   in reply to theplu

    I see you used import to stage, I did import to Library, unchecked "Check Illustrator layers to import" and down below I checked "import unused symbols" that brought up all symbols and art to the Library.

     

    what happens I think, is that the script creates symbols but don't automatically links the art to the symbol it just created, while manually creating a symbol does. Then when you import to the stage, I guess it imports what's on the Ai Artboard (just art, not symbol instances).

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 23, 2013 12:04 PM   in reply to theplu

    after you turn your artObject into a symbol, you have to add it to the canvas var mysymbolInstance = docRef.symbolItems.add(yourSymbol); then you can move it to where the artObject is and delete artObject afterwards

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points