Skip to main content
Participating Frequently
February 8, 2024
Question

Copy and paste whole path to new documents

  • February 8, 2024
  • 3 replies
  • 701 views

Hello, guys. I have asked question about path before and  got helped by this site so I came here with new problem that I faced.

 

so I got successed to making new paths by js code and found several paths on Paths tab.

and my goal is  copy the path and paste it on new document but I couldn't find relative reference on site so I wonder if anyone got the Idea with this problem?

 

thank you.

This topic has been closed for replies.

3 replies

c.pfaffenbichler
Community Expert
February 15, 2024

Can you provide a file and the resulting file/s you want to create? 

Participating Frequently
February 16, 2024

 

So basically, I cut those boxes by script with path and selected them, make a new document and then put those path infos with cut images to new document while putting those images vertically.

c.pfaffenbichler
Community Expert
February 16, 2024

I asked for an example image and the resulting image.  

c.pfaffenbichler
Community Expert
February 8, 2024

 

// 2024, use it at your own risk;
if (app.documents.length > 0) {
var thePath = selectedPath2020 ();
if (thePath != undefined) {
// copy path;
try {
var desc4 = new ActionDescriptor();
desc4.putString( stringIDToTypeID( "copyHint" ), "path" );
executeAction( stringIDToTypeID( "copyEvent" ), desc4, DialogModes.NO );
// new document;
var newDoc = app.documents.add(UnitValue (1000, "px"), UnitValue (1000, "px"), 300, "new image", NewDocumentMode.RGB);
// paste;
executeAction( stringIDToTypeID( "paste" ), undefined, DialogModes.NO );
} catch (e) {};
};
};
////// determine selected path //////
function selectedPath2020 () {
try {
var ref = new ActionReference();
ref.putProperty (stringIDToTypeID("property"), stringIDToTypeID("targetPathIndex")); 
ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
var docDesc = executeActionGet(ref);
var theIndex = docDesc.getInteger(stringIDToTypeID("targetPathIndex"))+1;
var ref = new ActionReference();
ref.putIndex( charIDToTypeID("Path"), theIndex); 
var pathDesc = executeActionGet(ref);
var theKind = pathDesc.getEnumerationValue(stringIDToTypeID("kind"));
var theName = pathDesc.getString(stringIDToTypeID("pathName"));
//
return [theIndex, theKind, theName];
}
catch (e) {return undefined}
};

 

Participating Frequently
February 14, 2024

Thanks and sorry for replying very late.

 

It's very similar to my wanted solution, but have some questions.

 

Is there any way to get images inside of path? Like, if I made path on the flower picture, I want to take the path with the selected flower images.

Participating Frequently
February 14, 2024

Could you please post screenshots with the pertinent Panels (Toolbar, Layers, Options Bar, …) visible to clarify what you mean? 


 

original path and document is just like this

c.pfaffenbichler
Community Expert
February 8, 2024

Please explain the intended process with screenshots. 

What dimensions and color mode is the new file supposed to have?