alexey-n
1/16/2018 - 9:29 AM

Имя залинкованного файла

    /** 
    * @@@BUILDINFO@@@ SetCaption-GraphicName-SELECTION.jsx !Version! Mon Jan 15 2018 10:30:17 GMT+0100 
    */  
    // By Uwe Laubender  
      
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;  
    app.doScript  
        (  
         
        labelAllGraphicsOfSelection,  
        ScriptLanguage.JAVASCRIPT,  
        [],  
        UndoModes.ENTIRE_SCRIPT,  
        "Label all linked graphics of selection | SCRIPT"  
         
        );  
      
    function labelAllGraphicsOfSelection()  
    {  
      
    if(app.documents.length == 0){ return };  
      
    var objectStyleName = "Label";  
    var layerName = "Label";  
      
    var doc = app.documents[0];  
    var activeSpread = doc.layoutWindows[0].activeSpread;  
      
    var sel = app.selection;  
    var selLength = sel.length;  
    var allGraphics = [];  
      
    var objectStyle = doc.objectStyles.itemByName(objectStyleName);  
    if(!objectStyle.isValid){objectStyle = doc.objectStyles.add({name : objectStyleName})};  
      
    var newLayer = doc.layers.itemByName(layerName);  
    if(!newLayer.isValid){ newLayer = doc.layers.add({ name : layerName })};  
    newLayer.move( LocationOptions.BEFORE , doc.layers[0] );  
    newLayer.visible = true;  
    newLayer.locked = false;  
      
    // Get all graphics of selection:  
    for(var n=0;n<selLength;n++)  
    {  
        allGraphics = allGraphics.concat(sel[n].allGraphics);  
    };  
      
    var allGraphicsLength = allGraphics.length;  
      
    for(var n=0;n<allGraphicsLength;n++)  
    {  
        if(allGraphics[n].itemLink == null){ continue };  
        if(allGraphics[n].itemLink.status == LinkStatus.LINK_INACCESSIBLE){ continue };  
         
        activeSpread.textFrames.add  
        (  
            {  
                geometricBounds : allGraphics[n].parent.geometricBounds ,  
                appliedObjectStyle : objectStyle ,  
                contents : allGraphics[n].itemLink.name ,  
                itemLayer : newLayer  
            }  
        );  
    };  
      
    };