Copiar vínculo al Portapapeles
Copiado
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
...
Copiar vínculo al Portapapeles
Copiado
I don’t understand what you mean.
Please explain with the help of screenshots/sketches.
Copiar vínculo al Portapapeles
Copiado
I want to get these coordinate data
Copiar vínculo al Portapapeles
Copiado
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;
};
};
Copiar vínculo al Portapapeles
Copiado
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");
Copiar vínculo al Portapapeles
Copiado
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?
Copiar vínculo al Portapapeles
Copiado
Is there any corresponding action documentation
Copiar vínculo al Portapapeles
Copiado
Is there any corresponding action documentation
By @zeyou36248626sb54
What do you mean?
What good would Actions be in this case?
Copiar vínculo al Portapapeles
Copiado
Want to see some "ACTINDEScripts" related documents, improve the skills
Copiar vínculo al Portapapeles
Copiado
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.
Copiar vínculo al Portapapeles
Copiado
It can be successful with my other file, which may be caused by different operations. You have helped me, thank you
Copiar vínculo al Portapapeles
Copiado
Blue dot coordinate data
Copiar vínculo al Portapapeles
Copiado
May I ask how you intend to process/use the information?
Copiar vínculo al Portapapeles
Copiado
Copiar vínculo al Portapapeles
Copiado
customEnvelopeWarp does not exist
Can you provide the image file for testing?
Copiar vínculo al Portapapeles
Copiado
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;
};
};
Copiar vínculo al Portapapeles
Copiado
The script works fine, thank you very much。
Encuentra más inspiración, eventos y recursos en la nueva comunidad de Adobe
Explorar ahora