I uploaded the script and it appears in my Scripts list. Then I reloaded Photoshop and open my .psd file and run script from File - Scripts but nothing happens. Sorry Im not goog with all this scripting stuff, can you assit more?
Many thanks to you JJMack! I realized that my question is not about I'm trying to do. Thank you for that. I created the new one How to export contents from all smart objects? that is more focused on what I expect to get.
As I wrote I do not install AI. This photoshop script should open all Vector Smart objects in your layered Photoshop document in Ai for you to be able to save Ai .svg and .ai files.
/* ==========================================================
// 2017 John J. McAssey (JJMack)
// ======================================================= */
// This script is supplied as is. It is provided as freeware.
// The author accepts no liability for any problems arising from its use.
// enable double-clicking from Mac Finder or Windows Explorer
#target photoshop // this command only works in Photoshop CS2 and higher
// bring application forward for double-click events
app.bringToFront();
// ensure at least one document open
if (!documents.length) alert('There are no documents open.', 'No Document');
else { app.activeDocument.suspendHistory('Some Process Name','main()');
}
///////////////////////////////////////////////////////////////////////////////
// main function //
///////////////////////////////////////////////////////////////////////////////
function main() {
// declare local variables
var orig_ruler_units = app.preferences.rulerUnits;
var orig_type_units = app.preferences.typeUnits;
var orig_display_dialogs = app.displayDialogs;
app.preferences.rulerUnits = Units.PIXELS; // Set the ruler units to PIXELS
app.preferences.typeUnits = TypeUnits.POINTS; // Set Type units to POINTS
app.displayDialogs = DialogModes.NO; // Set Dialogs off
try { code(); }
// display error message if something goes wrong
catch(e) { alert(e + ': on line ' + e.line, 'Script Error', true); }
app.displayDialogs = orig_display_dialogs; // Reset display dialogs
app.preferences.typeUnits = orig_type_units; // Reset ruler units to original settings
app.preferences.rulerUnits = orig_ruler_units; // Reset units to original settings
}
///////////////////////////////////////////////////////////////////////////////
// main function end //
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
// The real code is embedded into this function so that at any point it can return //
// to the main line function to let it restore users edit environment and end //
/////////////////////////////////////////////////////////////////////////////////////
function code() {
processArtLayers(activeDocument)
}
function processArtLayers(obj) {
for( var i = obj.artLayers.length-1; 0 <= i; i--) {processLayers(obj.artLayers[i])}
for( var i = obj.layerSets.length-1; 0 <= i; i--) {processArtLayers(obj.layerSets[i])} // Process Layer Set Layers
}
function processLayers(layer) {
if (layer.kind == LayerKind.SMARTOBJECT) {
if (smartobject_file_ext(layer) == "svg" | smartobject_file_ext(layer) == "ai" ) {
app.activeDocument.activeLayer=layer;
openSmartObject(app.activeDocument.activeLayer);
alert("Save the ." + smartobject_file_ext(layer) + " file for layer " + layer);
}
}
}
// Thanks to r-bin
function smartobject_file_ext(layer) {
try {
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("smartObject"));
r.putIdentifier(stringIDToTypeID("layer"), layer.id);
var name = executeActionGet(r).getObjectValue(stringIDToTypeID("smartObject")).getString(stringIDToTypeID("fileReference"));
var n = name.lastIndexOf(".");
if (n < 0) return "";
return name.substr(n+1).toLowerCase();
}
catch (e) { return "error"; }
}
////// open smart object //////
function openSmartObject (theLayer) {
if (theLayer.kind == "LayerKind.SMARTOBJECT") {
// =======================================================
var idplacedLayerEditContents = stringIDToTypeID( "placedLayerEditContents" );
var desc2 = new ActionDescriptor();
executeAction( idplacedLayerEditContents, desc2, DialogModes.NO );
};
};