Copy link to clipboard
Copied
How can i place an image into the active document, but not as a smart object?
...var filePath = new File(decodeURI('~/Downloads/Safari_logo.png')),
currentValue = getPlaceRasterSmartObjectValue();
if (currentValue == true) {
placeRasterSmartObject(false);
}
placeEmbedded(filePath); /* Place Image */
placeRasterSmartObject(currentValue); /* Return the default value */
function placeRasterSmartObject(__bool) {
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(charIDToTypeID('Prpr'), charIDToTypeID('GnrP'));
ref1
Copy link to clipboard
Copied
Edit > Preferences > General > Always Crete Smart Objects when Placing
placeRasterSmartObject(false);
/* Do something */
placeRasterSmartObject(true);
function placeRasterSmartObject(__bool) {
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(charIDToTypeID('Prpr'), charIDToTypeID('GnrP'));
ref1.putEnumerated(charIDToTypeID('capp'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
desc1.putReference(charIDToTypeID('null'), ref1);
var desc2 = new ActionDescriptor();
desc2.putBoolean(stringIDToTypeID("placeRasterSmartObject"), __bool);
desc1.putObject(charIDToTypeID('T '), charIDToTypeID('GnrP'), desc2);
executeAction(charIDToTypeID('setd'), desc1, DialogModes.NO);
}
Copy link to clipboard
Copied
Could you demonstrate this being using with an actual image file?
Copy link to clipboard
Copied
var filePath = new File(decodeURI('~/Downloads/Safari_logo.png')),
currentValue = getPlaceRasterSmartObjectValue();
if (currentValue == true) {
placeRasterSmartObject(false);
}
placeEmbedded(filePath); /* Place Image */
placeRasterSmartObject(currentValue); /* Return the default value */
function placeRasterSmartObject(__bool) {
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putProperty(charIDToTypeID('Prpr'), charIDToTypeID('GnrP'));
ref1.putEnumerated(charIDToTypeID('capp'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
desc1.putReference(charIDToTypeID('null'), ref1);
var desc2 = new ActionDescriptor();
desc2.putBoolean(stringIDToTypeID("placeRasterSmartObject"), __bool);
desc1.putObject(charIDToTypeID('T '), charIDToTypeID('GnrP'), desc2);
executeAction(charIDToTypeID('setd'), desc1, DialogModes.NO);
}
function placeEmbedded(filePath) {
var actDesc = new ActionDescriptor();
actDesc.putPath(charIDToTypeID('null'), filePath);
actDesc.putEnumerated(charIDToTypeID('FTcs'), charIDToTypeID('QCSt'), charIDToTypeID('Qcsa'));
executeAction(charIDToTypeID('Plc '), actDesc, DialogModes.NO);
}
/* Update: Check current value */
function getPlaceRasterSmartObjectValue() {
var ref = new ActionReference();
ref.putProperty(charIDToTypeID("Prpr"), charIDToTypeID("GnrP"));
ref.putEnumerated(charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
var psKey = executeActionGet(ref).getObjectValue(charIDToTypeID("GnrP")).getBoolean(stringIDToTypeID("placeRasterSmartObject"));
return psKey
}