Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Please explain the intended process with screenshots.
What dimensions and color mode is the new file supposed to have?
Copy link to clipboard
Copied
// 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}
};
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Could you please post screenshots with the pertinent Panels (Toolbar, Layers, Options Bar, …) visible to clarify what you mean?
Copy link to clipboard
Copied
It's just a example, but I want to do quite same as this picture, though want to adjust positions of path.
Copy link to clipboard
Copied
original path and document is just like this
Copy link to clipboard
Copied
So this is not about the Path at all but about pixels copied with a Selection based on the Path?
Copy link to clipboard
Copied
Sorry for confusing. I'm not familiar with photoshop.. so it would be related to Selections but I want to copy those selection based on the Path with the Path to new document..
Copy link to clipboard
Copied
This creates a Vector Mask on a copy of the image.
If this does not work out for you please post meaningful screenshots inclusing all pertinent Panels to clarify what you want to achieve.
// copy document and apply selected path as vector mask;
// 2024, use it at your own risk;
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var thePath = selectedPath2020 ();
if (thePath != undefined) {
// copy document;
try {
var theCopy = myDocument.duplicate ("thecopy", true);
theCopy.layers[0].isBackgroundLayer = false;
applyVectorMask ()
} catch (e) {};
};
};
////// apply vector mask //////
function applyVectorMask () {
var idpath = stringIDToTypeID( "path" );
var desc8 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putClass( idpath );
desc8.putReference( stringIDToTypeID( "null" ), ref2 );
var ref3 = new ActionReference();
ref3.putEnumerated( idpath, idpath, stringIDToTypeID( "vectorMask" ) );
desc8.putReference( stringIDToTypeID( "at" ), ref3 );
var ref4 = new ActionReference();
ref4.putEnumerated( idpath, stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ) );
desc8.putReference( stringIDToTypeID( "using" ), ref4 );
executeAction( stringIDToTypeID( "make" ), desc8, DialogModes.NO );
};
////// 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}
};
Copy link to clipboard
Copied
Can you provide a file and the resulting file/s you want to create?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I asked for an example image and the resulting image.
Copy link to clipboard
Copied
Do you mean these images?? Sorry for misunderstanding;;
Copy link to clipboard
Copied
But I guess this is not I want...
Copy link to clipboard
Copied
Again: Can you provide a file and the resulting file/s you want to create?
Not the result from the Script, the result as you want to get it?
And not screenshots, but the actual files? (Feel free to use a mock-up or black out sensitive content.)
Copy link to clipboard
Copied
Sorry for being late... I couldn't give further information but I have some questions so came back..
If I wanted to move those images which successfully duplicated by script seperately, is that possible? Maybe putting them into different layers would be work.. But keep making errors..
Copy link to clipboard
Copied
I don’t understand what you mean; please post meaningful screenshots (including all pertinent Panels) to illustrate what you mean – the image you start with and the result you want to achieve.
Copy link to clipboard
Copied
So this image is the original image that I want to deal with. Applying your script to this one,
It would be done like this. But now, I can't touch each images because they are in one layer? So what I want is..
Deal with those images seperately while copy with script to new document. Trying to find a way, but only making one new layer and then over...
Copy link to clipboard
Copied
Are you sure you mean »new document« and not just »new Layer«?
Copy link to clipboard
Copied
yeah not just new layers, need to be new document..
Copy link to clipboard
Copied
If this does not work out for you do not bother trying to describe the issue, but provide the files (the original and the resulting file/s you want to create).
// 2024, use at your own risk;
if (app.documents.length > 0) {
var myDocument = activeDocument.duplicate("thecopy", true);
var theCount = myDocument.pathItems.length;
myDocument.artLayers.add();
for (var m = 0; m < theCount; m++) {
mergVisibleToNewLayer();
myDocument.activeLayer.name = myDocument.pathItems[m].name;
myDocument.pathItems[m].select();
applyVectorMask ()
}
};
////////////////////////////////////
////// layer via copy //////
function mergVisibleToNewLayer (){
var desc23 = new ActionDescriptor();
desc23.putBoolean( stringIDToTypeID( "duplicate" ), true );
executeAction( stringIDToTypeID( "mergeVisible" ), desc23, DialogModes.NO );
};
////// apply vector mask //////
function applyVectorMask () {
var idpath = stringIDToTypeID( "path" );
var desc8 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putClass( idpath );
desc8.putReference( stringIDToTypeID( "null" ), ref2 );
var ref3 = new ActionReference();
ref3.putEnumerated( idpath, idpath, stringIDToTypeID( "vectorMask" ) );
desc8.putReference( stringIDToTypeID( "at" ), ref3 );
var ref4 = new ActionReference();
ref4.putEnumerated( idpath, stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ) );
desc8.putReference( stringIDToTypeID( "using" ), ref4 );
executeAction( stringIDToTypeID( "make" ), desc8, DialogModes.NO );
};
Copy link to clipboard
Copied
The result is quite great for me. Is there any script to help me to translate those layers by my own? Thank you!!
Copy link to clipboard
Copied
I do not understand what you mean, please provide actual examples (source image and intended resulting file/s).
Feel free to black out all the text and illustrations.
Copy link to clipboard
Copied
Hello I probably need some help with your smart things. Now, we have separate layers that hold each images in new document. I want to sort them with these code
Find more inspiration, events, and resources on the new Adobe Community
Explore Now