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

export range of artboards to SVG files with names

Explorer ,
May 24, 2021 May 24, 2021

Copy link to clipboard

Copied

i got this script that allow me to export range of artboards to SVG files , but I cant find how to export each artboard with its name or an array of names 

var docRef = app.activeDocument;

var path = docRef.path;

function exportFileToSVG (dest) {

  

    if ( app.documents.length > 0 ) {

        var exportOptions = new ExportOptionsWebOptimizedSVG();

        var type = ExportType.WOSVG;

        var fileSpec = new File(dest);

    

        exportOptions.saveMultipleArtboards = true;

        exportOptions.artboardRange = '1-2';

        exportOptions.coordinatePrecision = 2;

        exportOptions.fontType = SVGFontType.OUTLINEFONT;

        exportOptions.svgMinify = true;

        exportOptions.svgId = SVGIdType.SVGIDREGULAR;

        app.activeDocument.exportFile( fileSpec, type, exportOptions );

    }

}

exportFileToSVG('~/Desktop/blah.svg');
TOPICS
Scripting

Views

574

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

Guide , May 25, 2021 May 25, 2021
var ABs = app.activeDocument.artboards;
for (var i = 0; i < ABs.length; i++) {
    ABs.setActiveArtboardIndex(i);
    exportFileToSVG("~/Desktop/" + ABs[i].name + ".svg");
}
function exportFileToSVG (dest) {
    if ( app.documents.length > 0 ) {
        var exportOptions = new ExportOptionsSVG();
        var type = ExportType.SVG;
        var fileSpec = new File(dest);   
        exportOptions.saveMultipleArtboards = true;
        exportOptions.artboardRange = '1-2';
        exportOptions.coordi
...

Votes

Translate

Translate
Adobe
Guide ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

What exactly is the problem? You iterate through the artboards, make each artboard active in turn and call the function with the active artboard's name added to the path. Or am I misunderstanding the question?

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 ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

hey @femkeblanco  hope you have an amzing day , the problem is thate i wont the artboard exported with her name I misunderstanding btw 

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
Guide ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

var ABs = app.activeDocument.artboards;
for (var i = 0; i < ABs.length; i++) {
    ABs.setActiveArtboardIndex(i);
    exportFileToSVG("~/Desktop/" + ABs[i].name + ".svg");
}
function exportFileToSVG (dest) {
    if ( app.documents.length > 0 ) {
        var exportOptions = new ExportOptionsSVG();
        var type = ExportType.SVG;
        var fileSpec = new File(dest);   
        exportOptions.saveMultipleArtboards = true;
        exportOptions.artboardRange = '1-2';
        exportOptions.coordinatePrecision = 2;
        exportOptions.fontType = SVGFontType.OUTLINEFONT;
        exportOptions.svgMinify = true;
        app.activeDocument.exportFile( fileSpec, type, exportOptions );
    }
}

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 ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

this is working fine but i still git thise under scoers when its rebeat the artboard name again 

var ABs = app.activeDocument.artboards;
for (var i = 0; i < ABs.length; i++) {
    ABs.setActiveArtboardIndex(i);
    exportFileToSVG("~/Desktop/" + ABs[i].name + ".svg");
    
}
function exportFileToSVG (dest) {
    if ( app.documents.length > 0 ) {
        var exportOptions = new ExportOptionsSVG();
        var type = ExportType.SVG;
        var fileSpec = new File(dest);   
        exportOptions.saveMultipleArtboards = true;
        exportOptions.artboardRange = (i+1).toString();
        exportOptions.coordinatePrecision = 2;
        exportOptions.fontType = SVGFontType.OUTLINEFONT;
        exportOptions.svgMinify = true;
        app.activeDocument.exportFile( fileSpec, type, exportOptions );
    }
}

i need to enter this svg's to another app thats way i need there names to be clean as i set them unless is not going to work  

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 ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

Screenshot (10).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
Explorer ,
May 25, 2021 May 25, 2021

Copy link to clipboard

Copied

LATEST

oh , i just know how (: thank you soo much , i just had to turn off the save multiple artboards option this is how i get clean file name @femkeblanco 

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