What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Copying multiple images from PS to Illustrator.


Oh for Chrissake!

Well-Known Member
Messages
82
Likes
7
Hi,

I have a guitar chord chart. A collection of chords (5 x 5 grid) that I've copied and pasted into PS.

I would like to make multiple selections, selecting each chord individually and simultaneously. I do know that this is possible using the Marquee tool plus holding Shift. So I would have 25 individual selections on the same layer. From this point I COPY.

Problem begins here...

I want to be able to PASTE, all at once, into separate layers. My preference is paste into Illustrator, but pasting into PS is also fine.

The result will be 25 different individual layers, each layer will be its own guitar chord.


Thanks in advance!!
 
You could try this script, run the script after you have made all your selections.
Photoshop only.
Code:
#target photoshop
app.bringToFront();

main();
function main(){
if(!documents.length) return;
selectTransparency();
try{
    var SB=activeDocument.selection.bounds;
    }catch(e){
        alert("No selection has been made!");
        return;
        }
app.activeDocument.selection.makeWorkPath(0.5);
try{
activeDocument.pathItems.getByName('Work Path').name='WP';
}catch(e){
    alert("Work Path does not exist!");
    return;
    }
var currentRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var res = app.activeDocument.resolution;
if( res != 72 ) app.activeDocument.resizeImage (undefined, undefined, 72, ResampleMethod.NONE);
var pathLayer = activeDocument.activeLayer;   
var pathInfo = activeDocument.pathItems.getByName('WP');
var sp = pathInfo.subPathItems.length;
for(var a = 0;a<sp;a++){
      var tempPath = app.activeDocument.pathItems.add("Temp Path", extractSubPathInfo('WP',a));
      tempPath.makeSelection();
      executeAction( charIDToTypeID( "CpTL" ), undefined, DialogModes.NO );
      tempPath.remove();
      activeDocument.activeLayer = pathLayer;
}
 if( res != 72 ) app.activeDocument.resizeImage (undefined, undefined, res, ResampleMethod.NONE);
 pathInfo.remove();
 app.preferences.rulerUnits = currentRulerUnits;
 }
  
function extractSubPathInfo(pathName,subPathNo){
var pathObj = activeDocument.pathItems.getByName(pathName)
    var pathArray = new Array();
        var pArray = new Array();
          for(var i=0;i<pathObj.subPathItems[subPathNo].pathPoints.length;i++){
             pArray[i] = new PathPointInfo;
             pArray[i].kind = pathObj.subPathItems[subPathNo].pathPoints[i].kind;
             pArray[i].anchor = pathObj.subPathItems[subPathNo].pathPoints[i].anchor;
             pArray[i].leftDirection = pathObj.subPathItems[subPathNo].pathPoints[i].leftDirection;
             pArray[i].rightDirection = pathObj.subPathItems[subPathNo].pathPoints[i].rightDirection;
          };
        pathArray[pathArray.length] = new Array();
        pathArray[pathArray.length - 1] = new SubPathInfo();
        pathArray[pathArray.length - 1].operation = pathObj.subPathItems[subPathNo].operation;
        pathArray[pathArray.length - 1].closed = pathObj.subPathItems[subPathNo].closed;
        pathArray[pathArray.length - 1].entireSubPath = pArray;
    return pathArray;
};
function selectTransparency() {
    var desc113 = new ActionDescriptor();
        var ref83 = new ActionReference();
        ref83.putProperty( charIDToTypeID('Chnl'), charIDToTypeID('fsel') );
    desc113.putReference( charIDToTypeID('null'), ref83 );
        var ref84 = new ActionReference();
        ref84.putEnumerated( charIDToTypeID('Chnl'), charIDToTypeID('Chnl'), charIDToTypeID('Trsp') );
    desc113.putReference( charIDToTypeID('T   '), ref84 );
    try{
    executeAction( charIDToTypeID('setd'), desc113, DialogModes.NO );
    }catch(e){}
};
 
Hi Paul,

I copied all of your script and pasted it into a .txt file with no edits.

I saved the .txt file as a .jsx file to my hard drive.

I opened PS and brought up a file with an image to test the script.

I copied multiple locations with the marquee tool...

1549759377695.png

I copied the selections with CTRL - C...

I selected the script with File / Scripts / Browse...

1549759556803.png

But got this error...

1549759602170.png


Do I try a different order of steps? Have I overlooked something? I even tried it without copying first, still the same error message.

1549759196568.png
 
Could you try copying the script once again as the error message is cmplaining of a curly bracket missing. I have copyed the above script and tested it so I know it is ok.
 
**APPLAUSE**

You're the MAN! It created different layers in PS. Then I saved the file as .PSD, opened it in Illustrator and it offered to open the file in multiple layers as well. DYNAMITE!
 
I don't know as Ican't get it to fail here?
The code can be shortened as it doesn't need to select trancparency.
Code:
#target photoshop
app.bringToFront();

main();
function main(){
if(!documents.length) return;
try{
    var SB=activeDocument.selection.bounds;
    }catch(e){
        alert("No selection has been made!");
        return;
        }
app.activeDocument.selection.makeWorkPath(0.5);
try{
activeDocument.pathItems.getByName('Work Path').name='WP';
}catch(e){
    alert("Work Path does not exist!");
    return;
    }
var currentRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var res = app.activeDocument.resolution;
if( res != 72 ) app.activeDocument.resizeImage (undefined, undefined, 72, ResampleMethod.NONE);
var pathLayer = activeDocument.activeLayer;   
var pathInfo = activeDocument.pathItems.getByName('WP');
var sp = pathInfo.subPathItems.length;
for(var a = 0;a<sp;a++){
      var tempPath = app.activeDocument.pathItems.add("Temp Path", extractSubPathInfo('WP',a));
      tempPath.makeSelection();
      executeAction( charIDToTypeID( "CpTL" ), undefined, DialogModes.NO );
      tempPath.remove();
      activeDocument.activeLayer = pathLayer;
}
 if( res != 72 ) app.activeDocument.resizeImage (undefined, undefined, res, ResampleMethod.NONE);
 pathInfo.remove();
 app.preferences.rulerUnits = currentRulerUnits;
 }
function extractSubPathInfo(pathName,subPathNo){
var pathObj = activeDocument.pathItems.getByName(pathName)
    var pathArray = new Array();
        var pArray = new Array();
          for(var i=0;i<pathObj.subPathItems[subPathNo].pathPoints.length;i++){
             pArray[i] = new PathPointInfo;
             pArray[i].kind = pathObj.subPathItems[subPathNo].pathPoints[i].kind;
             pArray[i].anchor = pathObj.subPathItems[subPathNo].pathPoints[i].anchor;
             pArray[i].leftDirection = pathObj.subPathItems[subPathNo].pathPoints[i].leftDirection;
             pArray[i].rightDirection = pathObj.subPathItems[subPathNo].pathPoints[i].rightDirection;
          };
        pathArray[pathArray.length] = new Array();
        pathArray[pathArray.length - 1] = new SubPathInfo();
        pathArray[pathArray.length - 1].operation = pathObj.subPathItems[subPathNo].operation;
        pathArray[pathArray.length - 1].closed = pathObj.subPathItems[subPathNo].closed;
        pathArray[pathArray.length - 1].entireSubPath = pArray;
    return pathArray;
};
 

Back
Top