Skip to main content
Participating Frequently
March 13, 2019
解決済み

[ Branched ] How to relink all embedded images under clipping mask

  • March 13, 2019
  • 返信数 2.
  • 1642 ビュー

Hey pixxxel schubser It works for link image.
But i have many files with embedded image under clipping mask. Could you help make a change the script for it? Thanks

[ Branched by moderator from previous discussion ] --> relink all selected

このトピックへの返信は締め切られました。
解決に役立った回答 CarlosCanto

here you go, you still need to select the clipped images (the images themselves, not the mask). You can do that with the group selection tool

 

//#target Illustrator
 
// script.name = relinkAllSelected.jsx;
// script.description = relinks all selected placed images at once;
// script.required = select at least one linked image before running;
// script.parent = CarlosCanto // 7/12/11; 05/12/19 updated for CC2019
// script.elegant = false;
 
var idoc = app.activeDocument;
sel = idoc.selection;
if (sel.length>0) {
      var file = File.openDialog ("open file");
      file = new File(file.fsName.replace("file://","")); // Mac OS Lion fix by John Hawkinson
      
      for (i=0 ; i<sel.length ; i++ ) {
           if (sel[i].typename == "PlacedItem") {
                var iplaced = sel[i];
                iplaced.file = file;
             }
           if (sel[i].typename == "RasterItem") {
                var iplaced = idoc.placedItems.add();
                iplaced.file = file;
                
                iplaced.move(sel[i], ElementPlacement.PLACEBEFORE);

                h = sel[i].height;
                w = sel[i].width;
                x2 = sel[i].left;
                y2 = sel[i].top;

                iplaced.position = [x2+w/2-iplaced.width/2, y2-h/2+iplaced.height/2];
                
                sel[i].remove();
             }
       }
}
else
     {
          alert("select at least one placed item before running");
     }

返信数 2

CarlosCanto
Community Expert
CarlosCantoCommunity Expert解決!
Community Expert
May 12, 2019

here you go, you still need to select the clipped images (the images themselves, not the mask). You can do that with the group selection tool

 

//#target Illustrator
 
// script.name = relinkAllSelected.jsx;
// script.description = relinks all selected placed images at once;
// script.required = select at least one linked image before running;
// script.parent = CarlosCanto // 7/12/11; 05/12/19 updated for CC2019
// script.elegant = false;
 
var idoc = app.activeDocument;
sel = idoc.selection;
if (sel.length>0) {
      var file = File.openDialog ("open file");
      file = new File(file.fsName.replace("file://","")); // Mac OS Lion fix by John Hawkinson
      
      for (i=0 ; i<sel.length ; i++ ) {
           if (sel[i].typename == "PlacedItem") {
                var iplaced = sel[i];
                iplaced.file = file;
             }
           if (sel[i].typename == "RasterItem") {
                var iplaced = idoc.placedItems.add();
                iplaced.file = file;
                
                iplaced.move(sel[i], ElementPlacement.PLACEBEFORE);

                h = sel[i].height;
                w = sel[i].width;
                x2 = sel[i].left;
                y2 = sel[i].top;

                iplaced.position = [x2+w/2-iplaced.width/2, y2-h/2+iplaced.height/2];
                
                sel[i].remove();
             }
       }
}
else
     {
          alert("select at least one placed item before running");
     }
RobertNg作成者
Participating Frequently
May 13, 2019

It's works. Thank you so much!

Known Participant
May 11, 2019

This is what I would need as well