exporting selected objects to dxf
I have tried everything to write a script and I cant. I am not experienced but I copied and pasted with no luck. can anyone help. all I need is to quickly export selected objects with one click to a temp folder
here is what I have
try {
if (app.documents.length > 0 ) {
var destFolder = null;
destFolder = Folder.selectDialog( 'Select folder for dxf files.', '~' );
if (destFolder != null) {
var options, i, sourceDoc, targetFile;
options = this.getOptions();
for ( i = 0; i < app.documents.length; i++ ) {
sourceDoc = app.documents; // returns the document object
targetFile = this.getTargetFile(sourceDoc.name, '.dxf', destFolder);
sourceDoc.exportFile(targetFile, ExportType.dxf, options);
}
alert( 'Documents exported as dxf' );
}
}
else{
throw new Error('There are no document open!');
}
}
catch(e) {
alert( e.message, "Script Alert", true);
}
var exportOptions = new ExportOptionsAUTOCAD(); {
var type = ExportType.DXF;
var file = new File(folder.fsName+"/"+layer.name+".DXF");
document.exportFile(file, ExportType.DXF, options);
exportAutoCADOptions.exportFileFormat = AutoCADExportFileFormat.DXF; // AutoCADExportFileFormat.DWG DXF
exportAutoCADOptions.exportOption = AutoCADExportOption.PreserveAppearance; //PreserveAppearance MaximumEditability
exportAutoCADOptions.version = AutoCADCompatibility.AutoCADRelease14;
exportAutoCADOptions.exportSelectedArtOnly = false;
exportAutoCADOptions.convertTextToOutlines = false;
exportAutoCADOptions.unit = AutoCADUnit.Millimeters;
app.activeDocument.exportFile( fileSpec, type, exportOptions );
return options;
}
/** Returns the file to save or export into.
@9397041 docName the name of the document to be saved or exported
@9397041 ext the extension the file extension to be applied
@9397041 destFolder the output folder
@Return File object
*/
function getTargetFile(docName, ext, destFolder) {
var newName = "";
if (docName.indexOf('.') < 0) {
newName = docName + ext;
} else {
var dot = docName.lastIndexOf('.');
newName += docName.substring(0, dot);
