如何在Illustrator Extendscript中使用aiBringToFront?

时间:2013-02-03 23:45:55

标签: adobe-illustrator extendscript

在Illustrator中,我想在我的一个脚本中为 Bring to Front 创建一个函数。在CS5类型库中,我找到了对象AiZOrderMethod.aiBringToFront,但是,我无法弄清楚如何使用它。

这是我到目前为止所提出的:

//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!")
}

1 个答案:

答案 0 :(得分:2)

app.activeDocument.selectionArray

试试这个:

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!")
}