Copy link to clipboard
Copied
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.
@Param docName the name of the document to be saved or exported
@Param ext the extension the file extension to be applied
@Param 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);
Bonjour,
Gaz factory
Un peu d'ordre ne fait pas de mal !
...// JavaScript Document for Illustrator
// elleere Sat, 17 March 2018 20:39:43 GMT
var doc = app.activeDocument;
if ( app.documents.length > 0 ) {
var destFolder = null;
destFolder = Folder.selectDialog( 'Sélectionner le dossier des fichiers DXF.', '~' );
if (destFolder != null) {
var options = getOptions();
var type = ExportType.AUTOCAD;
var fileSpec = new File(destFolder+"/"+doc.name+".dxf"); // "~/essai.dxf"
d
Copy link to clipboard
Copied
Bonjour,
Gaz factory
Un peu d'ordre ne fait pas de mal !
// JavaScript Document for Illustrator
// elleere Sat, 17 March 2018 20:39:43 GMT
var doc = app.activeDocument;
if ( app.documents.length > 0 ) {
var destFolder = null;
destFolder = Folder.selectDialog( 'Sélectionner le dossier des fichiers DXF.', '~' );
if (destFolder != null) {
var options = getOptions();
var type = ExportType.AUTOCAD;
var fileSpec = new File(destFolder+"/"+doc.name+".dxf"); // "~/essai.dxf"
doc.exportFile( fileSpec, type, options );
}
}
//--------
function getOptions() {
var exportOptions = new ExportOptionsAutoCAD();
exportOptions.exportFileFormat = AutoCADExportFileFormat.DXF;//DWG DXF
exportOptions.exportOption = AutoCADExportOption.PreserveAppearance;
exportOptions.version = AutoCADCompatibility.AutoCADRelease14;
exportOptions.exportSelectedArtOnly = true; //export selected objects true
exportOptions.convertTextToOutlines = false;
exportOptions.generateThumbnails = true
exportOptions.unit = AutoCADUnit.Millimeters;
return exportOptions;
}
de elleere
Copy link to clipboard
Copied
operation not supported on this object
Copy link to clipboard
Copied
If possible, please send the full script code for the community to review. At first glance, there are no problems in these lines and the export will work.
Copy link to clipboard
Copied
Here is the working script
Copy link to clipboard
Copied
is it possible to export without creating a new document also when I export again it will override with new content. i'm facing so many issues in debugging
Copy link to clipboard
Copied
In my ExportToDXF script, I am not creating a new document to export selected objects https://github.com/creold/illustrator-scripts/blob/master/md/Export.md#exporttodxf
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Result: undefined is correct because it returns nothing in the code. By the way, isn't this document created in Large Canvas mode? I've found that this breaks the PNG export function in ExtendScript.
UPD: I think you have a large canvas. The exportFile method does not work on it. It's ExtendScript bug. I forgot to add a warning about a large canvas to the ExportToDXF script. My article about PNG and large canvas also applies to DXF: https://medium.com/@aiscripts/export-large-canvas-to-png-2b05d4354b66
Copy link to clipboard
Copied
yes, I'm working on a large canvas, thanks