Skip to main content
Known Participant
October 13, 2022
Question

extend script is not working in photoshop but working fine in illustrator

  • October 13, 2022
  • 2 replies
  • 197 views

function ImageTracingPaste(){
var len=0;
var CountPath=0;
var dirImages = new Folder(ClipBoard_image_path);
var imagesList = dirImages.getFiles('*.jpeg');
var length=imagesList.length;
Paste_Image = imagesList[length-1].name;
var index;
var doc = app.activeDocument;
var DocLayerCount=doc.layers.length;
for(var i=0;i<DocLayerCount;i++){
if(doc.layers[i].name==Paste_Layer){
index=i;
break;
}
}
if(doc.layers[index].groupItems.length>0 && doc.layers[index].pageItems[0].name !="Clipped_Group"){
ExpendFunction(index,0);
}
var len=doc.layers[index].pageItems.length;
for(var i=0;i<len;i++){
CountPath++;
var pathitm=doc.layers[index].pageItems[i];
if(pathitm.name!="Clipped_Group"){
var placedItem1 = doc.layers[index].placedItems.add();
placedItem1.moveToEnd(doc.layers[index]);
placedItem1.file = new File(ClipBoard_image_path+"/"+Paste_Image);
placedItem1.selected=true;
pathitm.selected=true;
app.executeMenuCommand("makeMask");
doc.layers[index].pageItems[i].name="Clipped_Group";
exportFileToJPEG();
} else{
pathitm.placedItems.removeAll();
var plcd=pathitm.placedItems.add();
plcd.moveToEnd(pathitm);
plcd.file = new File(ClipBoard_image_path+"/"+Paste_Image);
exportFileToJPEG();
}
}
return Paste_Image+","+CountPath;
}

This topic has been closed for replies.

2 replies

CarlosCanto
Community Expert
Community Expert
October 13, 2022
quote

extend script is not working in photoshop but working fine in illustrator


By @Rishabh22425292b5db

 

That's expected, these are different programs with their own Object Models. Photoshop script won't work on Illustrator and   vice versa

Charu Rajput
Community Expert
Community Expert
October 13, 2022

@Rishabh22425292b5db 
When you say extend script is not working in Photoshop, do you mean that you are not able to debug the script in Photoshop or above script is not working in Photoshop but working fine in Illustartor?

 

If you mean above script is not working in Photoshop, then it will not work, because the API for the photoshop and Illustrator are different. There is nothing like pageItems in the photoshop. In photoshop everything is a layer. So to get the expected result you need to use those methods and properies that are available in Photoshop not in Illustartor.

Best regards