• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

How to select all vector smart objects in .psd file and save as separate .ai files?

Explorer ,
Mar 15, 2020 Mar 15, 2020

Copy link to clipboard

Copied

Hi all!

I have .psd file with different layers. Some layers are vector smart objects (VSO) and some are just image layers. What I need to do is to select (or filter) only VSO and export them as separate .ai files. I know I can do it by right click on layer -> Export contents. But when I select multiply layers "Export contents" is inactive. Please assist.

Views

3.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 15, 2020 Mar 15, 2020

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-c
...

Votes

Translate

Translate
Adobe
Community Expert ,
Mar 15, 2020 Mar 15, 2020

Copy link to clipboard

Copied

That would in all likelihood need a Script. 

How familiar are you with JavaScript? 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 15, 2020 Mar 15, 2020

Copy link to clipboard

Copied

Basics only and I have no idea how to implement JS into Photoshop =( Can you assist?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2020 Mar 15, 2020

Copy link to clipboard

Copied

Not at current. 

Maybe it would help you do it manually if you hid all non-SOs with the Layers Panel’s Filter. 

layersPanelFilterSmartObject.png

 

And a warning: If you created the Vector SOs by pasting content copied in Illustrator that will export contents not as ai but as pdf. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 15, 2020 Mar 15, 2020

Copy link to clipboard

Copied

Oh.. Many thanks. I've created objects in the way you described =( 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2020 Mar 15, 2020

Copy link to clipboard

Copied

I do not understand your question? All vector smart object layers are Placed AI files. The vector Ai files exists.  If you open a vector smart object layer to update its content it will open in Ai not Photoshop because Photoshop does not support vector files. With a script you can process all Smart object layers and open the vector files in AI. R-bin posted script code to get smart object file types.

 

 

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"; }  
}    

 

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 15, 2020 Mar 15, 2020

Copy link to clipboard

Copied

You are right.

I struggle with issue when I must double-click every VSO in Photoshop to open it Illustrator and than save as .ai file beacuse I dont have source files. As far as I understood your script can open all VSO in Illustrator tabs and I can save all opened tabs in Illustrator as separate files, right?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2020 Mar 15, 2020

Copy link to clipboard

Copied

The thing is a Photoshop script will lose control if the script open a smart object layer that is a AI vector file.  For Adobe Illustrator will be started by your Operating systems file association for the temp vector file Photoshop will create for the object file either Linked or embedded in system temp space.   You would need to saved that files from Illustrator.  When you do that if you do not save the system temp work document created by Photoshop. Photoshop will not update the documents smart object and the script would have no idea if you save to file somewhere else from Illustrator. This script could most likely access the temp vector file created by Photoshop and use JavaScript do a file copy to some location that you programmed into the script. If it exist either replace or add a sequence  number to the file name. You can not export the Ai file from Photoshop for Photoshop does not support AI vector file formats.  Photoshop may be able to export shape layers as a .svg file and the .svg file may well contain vector graphics.  You can open the .svg file in a text editor to see if any Paths are recorded in the text .svg file.

 

Photoshop can rasterize AI files and process the raster layer. Photoshop can not process AI files.

 

Here is a Shape layer I exported as a .svg file. Included here in text format.

<svg xmlns="http://www.w3.org/2000/svg" width="3200" height="3200" viewBox="0 0 3200 3200">
  <defs>
    <style>
      .cls-1 {
        fill-rule: evenodd;
      }
    </style>
  </defs>
  <path id="Impossible_Star_1" data-name="Impossible Star 1" class="cls-1" d="M1862.17,400h259.68l351.56,993.39H3500.12L3600,1634.35l-799,672.12,383.52,1086.4L2960.8,3600l-910.86-684.81L1218.98,3600l-239.7-177.54,327.594-1086.4L400,1642.8l95.88-249.41H1566.54Zm4,16.909L1438.7,1858.39l219.73,156.41L2105.87,416.909h-239.7Zm247.69,4.227L1666.42,2019.02l159.8,109.91,195.75-735.54h435.46Zm-83.9,989.164-55.93,211.36H3584.02l-87.89-207.13Zm-1498.125,4.23L1906.12,2429.06l-227.72,186-359.55-270.54-319.6,1061.03L2309.61,2374.11l-67.91-211.36L2045.94,2310.7l-623.22-452.31,135.83-443.86H531.835Zm-23.97,0L423.97,1634.35,1678.4,2593.92l203.75-164.86ZM1970.04,1634.35l-55.93,224.04H2641.2l155.8,435.4,787.02-659.44H1970.04Zm-59.93,236.72-71.91,266.31,207.74,152.18,191.76-143.72-83.89-274.77h-243.7Zm259.68,0,231.71,760.9-339.58,274.77,890.89,676.35L2365.54,1871.07H2169.79Zm211.73,0,583.27,1712.02,207.74-194.45L2633.21,1871.07H2381.52Zm-67.91,515.72L999.251,3418.23l219.729,164.86,1170.53-955.35Z" transform="translate(-400 -400)"/>
</svg>

Here is how Chrome displays thet .svg

image.png

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 15, 2020 Mar 15, 2020

Copy link to clipboard

Copied

Many thanks for your time JJMack!
It seems this script doesn't work for me since when I create .psd files I copie and paste objects from Illustrator to Photoshop and now I have only .psd file with a lot of AI vector smart objects. The thing is when I right-click any VSO and click "Export Contents" I get what I need "Vector Smart Object.ai" file from selected VSO in Photoshop. The only problem is I have near 150 VSObjects in my .psd file and I extremely need "Export Contents" for all of them instead of manual clicking one by one.. Maybe you have any Ideas how can I get .ai files from all my VSOs in .psd?


Another way I can accept is 'proper' (resizable) SVG files that I "save as" from .ai. Thats why I export VSOs to .ai and then save as SVG because there in no other way to get (resizable) SVG from Photoshop.
I appreciate your help.

 

 

If I export VSO layer as SVGs I get the following code:Screenshot 2020-03-15 at 17.24.44.png

And as a result I can't use it as SVG =(

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2020 Mar 15, 2020

Copy link to clipboard

Copied

Photoshop can not export AI files it does not support them. It can only rasterize them or ues them as smart vector objects.  Vector Smart object only resize via vector graphics because Photoshop reprocess the AI file at the required resize by rasterizing the smart object vector file at the required size there are no vector actually in Photoshop.

 

Even exporting .SVG may not be the file that AI would create for the same image for AI is a vector editor and has more vector tools and features than  Photoshop.  I show a .svg exported for a shape layer the looked most likely line one AI would have saved. AI has tools photoshop does not have and may be able to  fill and shade areas with different colors.  I do not install AI so I'm have idea as to what tools and features  AI has.  I filled in that star ares with a Raster layer  containing several  colors.  When I exported it as a svg the svg files contain both vectors and raster data. Which  most likely would be very different than an AI svg file.

image.png 

 

It is SVG file but not like the one that would have been create with the tools available in AI. Photoshop has limited vector support.  Smart object layers pixels act like a raster layer normally. Only AI  file are resized via rerasterizing that object ai file at the correct size. What is in Photoshop is a raster layer. Not a vector layer.

 

As I wrote the Photoshop Script would need to use JavsScript to do a file copy of the Temp work AI file that photoshop created in your system temp space. Or you save the AI file where you want it when AI opens the temp Work file.

JJMack
JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 15, 2020 Mar 15, 2020

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2020 Mar 15, 2020

Copy link to clipboard

Copied

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 );
	};
};

 

 

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 15, 2020 Mar 15, 2020

Copy link to clipboard

Copied

Oh! Yeah! It works! Many thanks to you! But this window appears and interrupt after each iteration of script. And I must click "OK" after each layers export, is it ok?Screenshot 2020-03-15 at 20.18.45.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2020 Mar 15, 2020

Copy link to clipboard

Copied

The message is there to pause Photoshop execution to give you to opportunity to save the Ai file in Ai.  Photoshop does not support AI Vector files.  If that message was not there Photoshop would rapidly try to open all vector Ai files in AI.  As I wrote I do not install AI.  I do not know how AI would handle getting many system messages to open temp Ai files in system temp space. You could try commenting out the pausing message.  I use Windows it may create a queue and work without all the pausing messages. 

add a // to the front of line 52

 

      //alert("Save the ." + smartobject_file_ext(layer) + " file for layer " + layer);

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 15, 2020 Mar 15, 2020

Copy link to clipboard

Copied

LATEST

I'll try! Many thanks to you JJMack! You save me a lot of time!

 

 

Now everything works great! I appreciate your help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines