0

In Illustrator, I want to create a function in one of my scripts for Bring to Front. In the CS5 Type Library, I find the object, AiZOrderMethod.aiBringToFront, however, I can't figure out how to use it.

Here is what I've come up with so far:

//BringToFront

mySelection = activeDocument.selection;
    if (mySelection.length>0){
        var doc = app.activeDocument;                   //current document
        var s    = doc.selection;                              //current slection
        var sl   = s.length;                                     //number of selected objects
        s.AiZOrderMethod.aiBringToFront();

        //for(var i = 0 ; i < sl; i++) s[i].aibringtofront();   //for each selected element...
        app.redraw();
    }else{
        alert("Nothing selected!")
}
bgmCoder
  • 6,205
  • 8
  • 58
  • 105

1 Answers1

2

app.activeDocument.selection is an Array

Try this:

var doc = app.activeDocument;  //current document
var sel = doc.selection;       // array
var sl   = sel.length;       //number of selected objects

    if (sl>0){
        for(var i = 0 ; i < sl; i++){
            // for every item in selection array
          sel[i].zOrder(ZOrderMethod.BRINGTOFRONT);
            }
        app.redraw();
    }else{
        alert("Nothing selected!")
}
fabianmoronzirfas
  • 4,091
  • 4
  • 24
  • 41
  • you can get the whole content of the ESTK Object Model Viewer for AI, ID and PSD here as .chm or .html files. It is much easier to browse http://www.jongware.com/idjshelp.html – fabianmoronzirfas Feb 04 '13 at 14:44