Copy link to clipboard
Copied
I am writing a script that obtains the Bessel curve coordinate data after obtaining the deformation of the smart object, and I didn’t find the relevant API.
const layers = app.activeDocument.layers;
for(var i = 0; i < layers.length; ++i) {
var layer = layers[i];
if (layer.kind === LayerKind.SMARTOBJECT) {
alert(layer.kind);
// layer, Layer is an smart object, but the smart object data cannot be obtained from Layer
}
}
Does this help?
// get stuff for warp on a smart objects;
// based on code by michael l hale;
// 2024, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var layerDesc = executeActionGet(ref);
var soDesc = layerDesc.getObjectValue(stringIDToTypeID('smartObject'));
var soMoreDesc = layerDesc.getObjectValue(stringIDToTypeID('smartObjectMore'));
var
...
Copy link to clipboard
Copied
I don’t understand what you mean.
Please explain with the help of screenshots/sketches.
Copy link to clipboard
Copied
I want to get these coordinate data
Copy link to clipboard
Copied
Does this help?
// get stuff for warp on a smart objects;
// based on code by michael l hale;
// 2024, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var layerDesc = executeActionGet(ref);
var soDesc = layerDesc.getObjectValue(stringIDToTypeID('smartObject'));
var soMoreDesc = layerDesc.getObjectValue(stringIDToTypeID('smartObjectMore'));
var placedDesc = soDesc.getEnumerationValue(stringIDToTypeID('placed'));
var theFileRef = soDesc.getString(stringIDToTypeID('fileReference'));
var theDocID = soDesc.getString(stringIDToTypeID('documentID'));
var warp = soMoreDesc.getObjectValue(stringIDToTypeID("warp"));
var envelopeWarp = warp.getObjectValue(stringIDToTypeID("customEnvelopeWarp"));
var meshPoints = envelopeWarp.getList(stringIDToTypeID("meshPoints"));
var xx = new Array;
for (var m = 0; m < meshPoints.count; m++) {
xx.push(checkDesc2 (meshPoints.getObjectValue(m)));
};
alert ("warp\n\n"+xx.join("\n\n"));
};
//////
////// based on code by michael l hale //////
function checkDesc2 (theDesc, theAlert) {
var c = theDesc.count;
var str = '';
for(var i=0;i<c;i++){ //enumerate descriptor's keys
str = str + 'Key '+i+' = '+typeIDToStringID(theDesc.getKey(i))+': '+theDesc.getType(theDesc.getKey(i))+'\n'+getValues (theDesc, i)+'\n';
};
if (theAlert == true) {alert("desc\n\n"+str);
return};
return str
};
////// check //////
function getValues (theDesc, theNumber) {
switch (theDesc.getType(theDesc.getKey(theNumber))) {
case DescValueType.ALIASTYPE:
return theDesc.getPath(theDesc.getKey(theNumber));
break;
case DescValueType.BOOLEANTYPE:
return theDesc.getBoolean(theDesc.getKey(theNumber));
break;
case DescValueType.CLASSTYPE:
return theDesc.getClass(theDesc.getKey(theNumber));
break;
case DescValueType.DOUBLETYPE:
return theDesc.getDouble(theDesc.getKey(theNumber));
break;
case DescValueType.ENUMERATEDTYPE:
return (typeIDToStringID(theDesc.getEnumerationValue(theDesc.getKey(theNumber)))+"_"+typeIDToStringID(theDesc.getEnumerationType(theDesc.getKey(theNumber))));
break;
case DescValueType.INTEGERTYPE:
return theDesc.getInteger(theDesc.getKey(theNumber));
break;
case DescValueType.LISTTYPE:
return theDesc.getList(theDesc.getKey(theNumber));
break;
case DescValueType.OBJECTTYPE:
return (theDesc.getObjectValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getObjectType(theDesc.getKey(theNumber))));
break;
case DescValueType.REFERENCETYPE:
return theDesc.getReference(theDesc.getKey(theNumber));
break;
case DescValueType.STRINGTYPE:
return theDesc.getString(theDesc.getKey(theNumber));
break;
case DescValueType.UNITDOUBLE:
return (theDesc.getUnitDoubleValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getUnitDoubleType(theDesc.getKey(theNumber))));
break;
default:
break;
};
};
Copy link to clipboard
Copied
Error 8800: Conventional Photoshop errors occur. This function may not be used in this version of Photoshop:
-<No basis information is available>
Line: 15
var envelPewarp = Warp.getObjectValue (Stringidtotypeid ("customEnvelopeWarp");
Copy link to clipboard
Copied
Could you please post meaningful screenshots with the pertinent Panels (Toolbar, Layers, Options Bar, …) visible?
Is a Smart Object with a Warp applied the active Layer?
Copy link to clipboard
Copied
Is there any corresponding action documentation
Copy link to clipboard
Copied
Is there any corresponding action documentation
By @zeyou36248626sb54
What do you mean?
What good would Actions be in this case?
Copy link to clipboard
Copied
Want to see some "ACTINDEScripts" related documents, improve the skills
Copy link to clipboard
Copied
Thing is ExtendScript Photoshop Scripting is on legacy status and may »vanish« at some point in the future.
So if you are (relatively) new to the matter you may want to focus on UXP Scripting right away.
For ExtendScript you could do a search for »photoshop-scripting-guide-2020.pdf« and »photoshop-javascript-ref-2020.pdf«.
You could also look into @DavideBarranca ’s book/s, I think he has published on both ES and UXP Sxripting.
Copy link to clipboard
Copied
It can be successful with my other file, which may be caused by different operations. You have helped me, thank you
Copy link to clipboard
Copied
Blue dot coordinate data
Copy link to clipboard
Copied
May I ask how you intend to process/use the information?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
customEnvelopeWarp does not exist
Can you provide the image file for testing?
Copy link to clipboard
Copied
Please try this Script:
// get stuff for warp on a smart objects;
// based on code by michael l hale;
// 2025, use it at your own risk;
if (app.documents.length > 0) {
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var layerDesc = executeActionGet(ref);
var soDesc = layerDesc.getObjectValue(stringIDToTypeID('smartObject'));
var soMoreDesc = layerDesc.getObjectValue(stringIDToTypeID('smartObjectMore'));
var placedDesc = soDesc.getEnumerationValue(stringIDToTypeID('placed'));
var theFileRef = soDesc.getString(stringIDToTypeID('fileReference'));
var theDocID = soDesc.getString(stringIDToTypeID('documentID'));
if (soMoreDesc.hasKey(stringIDToTypeID('quiltWarp'))) {
var quiltWarp = soMoreDesc.getObjectValue(stringIDToTypeID('quiltWarp'));
var envelopeWarp = quiltWarp.getObjectValue(stringIDToTypeID("customEnvelopeWarp"));
} else {
var warp = soMoreDesc.getObjectValue(stringIDToTypeID("warp"));
var envelopeWarp = warp.getObjectValue(stringIDToTypeID("customEnvelopeWarp"));
};
var meshPoints = envelopeWarp.getList(stringIDToTypeID("meshPoints"));
var xx = new Array;
for (var m = 0; m < meshPoints.count; m++) {
xx.push(checkDesc2 (meshPoints.getObjectValue(m)));
};
alert (meshPoints.count+" points in warp\n\n"+xx.join("\n\n"));
};
//////
////// based on code by michael l hale //////
function checkDesc2 (theDesc, theAlert) {
var c = theDesc.count;
var str = '';
for(var i=0;i<c;i++){ //enumerate descriptor's keys
str = str + 'Key '+i+' = '+typeIDToStringID(theDesc.getKey(i))+': '+theDesc.getType(theDesc.getKey(i))+'\n'+getValues (theDesc, i)+'\n';
};
if (theAlert == true) {alert("desc\n\n"+str);
return};
return str
};
////// check //////
function getValues (theDesc, theNumber) {
switch (theDesc.getType(theDesc.getKey(theNumber))) {
case DescValueType.ALIASTYPE:
return theDesc.getPath(theDesc.getKey(theNumber));
break;
case DescValueType.BOOLEANTYPE:
return theDesc.getBoolean(theDesc.getKey(theNumber));
break;
case DescValueType.CLASSTYPE:
return theDesc.getClass(theDesc.getKey(theNumber));
break;
case DescValueType.DOUBLETYPE:
return theDesc.getDouble(theDesc.getKey(theNumber));
break;
case DescValueType.ENUMERATEDTYPE:
return (typeIDToStringID(theDesc.getEnumerationValue(theDesc.getKey(theNumber)))+"_"+typeIDToStringID(theDesc.getEnumerationType(theDesc.getKey(theNumber))));
break;
case DescValueType.INTEGERTYPE:
return theDesc.getInteger(theDesc.getKey(theNumber));
break;
case DescValueType.LISTTYPE:
return theDesc.getList(theDesc.getKey(theNumber));
break;
case DescValueType.OBJECTTYPE:
return (theDesc.getObjectValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getObjectType(theDesc.getKey(theNumber))));
break;
case DescValueType.REFERENCETYPE:
return theDesc.getReference(theDesc.getKey(theNumber));
break;
case DescValueType.STRINGTYPE:
return theDesc.getString(theDesc.getKey(theNumber));
break;
case DescValueType.UNITDOUBLE:
return (theDesc.getUnitDoubleValue(theDesc.getKey(theNumber))+"_"+typeIDToStringID(theDesc.getUnitDoubleType(theDesc.getKey(theNumber))));
break;
default:
break;
};
};
Copy link to clipboard
Copied
The script works fine, thank you very much。
Find more inspiration, events, and resources on the new Adobe Community
Explore Now