Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Illustrator脚本:将单层导出到SVG_Javascript_Svg - Fatal编程技术网

Javascript Illustrator脚本:将单层导出到SVG

Javascript Illustrator脚本:将单层导出到SVG,javascript,svg,Javascript,Svg,我一直在尝试运行一个脚本,该脚本能够将特定illustrator文件导出为SVG格式。我一直在参考Adobe论坛的一篇文章,其中介绍了一种方法,并成功地实现了该方法,请参见以下内容: var singleLayer, doc, path = 'C:/Users/lukeb/Desktop/New folder', type = ExportType.SVG, options = new ExportOptionsSVG(), layerAmount

我一直在尝试运行一个脚本,该脚本能够将特定illustrator文件导出为SVG格式。我一直在参考Adobe论坛的一篇文章,其中介绍了一种方法,并成功地实现了该方法,请参见以下内容:

    var singleLayer,
    doc,
    path = 'C:/Users/lukeb/Desktop/New folder',
    type = ExportType.SVG,
    options = new ExportOptionsSVG(),
    layerAmount;

doc = this.myApp;
singleLayer = this.myApp.layers["buttons"];
options.embedRasterImages = false;
options.cssProperties = SVGCSSPropertyLocation.PRESENTATIONATTRIBUTES;
options.fontSubsetting = SVGFontSubsetting.None;
options.documentEncoding = SVGDocumentEncoding.UTF8;
options.coordinatePrecision = 4;
layerAmount = doc.layers.length;

hideAllLayers();
for (var i = layerAmount - 1, k = 0; i >= 0; i--, k++) {
    if (this.myApp.layers[i] === singleLayer) {
        var file;

        singleLayer.visible = true;
        file = new File(path + "/" + singleLayer);
        this.myApp.exportFile(file, type, options);
        singleLayer.visible = false;
    }
}
showAllLayers();

function hideAllLayers() {
    for(var i = 0; i < layerAmount; i++) {
        doc.layers[i].visible = false;
    }
}

function showAllLayers() {
    for(var i = 0; i < layerAmount; i++) {
        doc.layers[i].visible = true;
    }
}
var singleLayer,
博士,
路径='C:/Users/lukeb/Desktop/New folder',
type=ExportType.SVG,
选项=新导出选项SVG(),
layerAmount;
doc=this.myApp;
singleLayer=this.myApp.layers[“按钮”];
options.embedRasterImages=false;
options.cssprroperties=SVGCSSPropertyLocation.PresentationAttribute;
options.fontSubsetting=SVGFontSubsetting.None;
options.documentEncoding=SVGDocumentEncoding.UTF8;
options.coordinatePrecision=4;
layerAmount=doc.layers.length;
隐藏层();
对于(变量i=layerAmount-1,k=0;i>=0;i--,k++){
if(this.myApp.layers[i]==singleLayer){
var文件;
singleLayer.visible=true;
文件=新文件(路径+“/”+单层);
this.myApp.exportFile(文件、类型、选项);
singleLayer.visible=false;
}
}
showallayers();
函数hideAllayers(){
对于(变量i=0;i

这段代码在某种程度上运行得很好。它在我的图层库中挑出一个图层,并关闭除那个图层之外的所有图层。但出于某种原因,它不会将一个层作为SVG导出,它会导出很多层,如果不是全部的话。这个有什么遗漏吗?关于这一切的文档并不多,因此我们不太确定是否有一个简单的解决方案来获得一个图层。

隐藏图层可能不会阻止导出图层。这只会让他们感到厌烦。快速的网络搜索发现:这有帮助吗?