Copy link to clipboard
Copied
Hi!
I am looking for some help to create a script that will batch export assets to dxf.
I have a large document with around 1000 symbols in, all individually named and collected for batch export (asset export). I have been trying to create a script that will export all these assets as individual dxf files with the same name as the collected assets.
Can anyone help with this?
Thanks,
Copy link to clipboard
Copied
where are the symbols? on the artboard or in the symbols panel?
can you post a sample file?
Copy link to clipboard
Copied
Hi, hee is something I use for a similar setup, exporting to jpeg.
The file is set up as a symbol sheet, so all objects are in the library, and instances are placed on the artboard
var doc = app.activeDocument;
if(!doc.selection.length)
doc.selectObjectsOnActiveArtboard();
var sel = doc.selection.slice();
var fn = doc.fullName.fsName;
var tfn = fn.replace('.ai', '');
alert(tfn);
var fo = new Folder(tfn);
if(!fo.exists) fo.create();
var ndoc = app.documents.add();
//alert(ndoc.artboards[0].artboardRect)
var jpgopts = new ExportOptionsJPEG();
var lfdnr = 1;
var changed = 0;
var toplayer = ndoc.layers[0];
var problems = [];
for(var n = 0 ; n < sel.length ; n++)
{ var ob = sel[n];
ob.selected = false;
var nm;
if(ob.typename == 'SymbolItem')
{ nm = ob.symbol.name;
}
else if(ob.name) // in case something has not been converted to symbol
nm = ob.name;
else
{ nm = 'tmp_'+lfdnr++;
continue;
}
var nob = ob.duplicate(ndoc, ElementPlacement.PLACEATEND);
nob.move(toplayer, ElementPlacement.PLACEATEND);
var dfn = tfn + '/' + nm + '.jpg';
var dfo = new File(dfn);
nob.top = nob.left = 0;
var wd = nob.width, ht = nob.height;
var sc = 224 * 100 / Math.min(wd, ht);
try {
jpgopts.verticalScale = jpgopts.horizontalStyle = sc;
ndoc.exportFile(dfo, ExportType.JPEG, jpgopts);
toplayer.pageItems.removeAll();
} catch(e) { alert(nm+' '+e); }
}
ndoc.close(SaveOptions.DONOTSAVECHANGES);
alert('finish');
.All output files go to a folder naed like the original art file