Copy link to clipboard
Copied
Hello, I anyone knows how to do this, I am looking for some assistance with making a script that will
1. Export Multipage PDF to an AutoCAD Version 2007/2008/2009 DXF file
2. Add a Suffix to the File Name of "-1" or "_1" that corresponds to the Page or Artboard Number
Any Assistance would be greatly appreciated!
Thank you 🙂
See if this works for you. If so, you can use the path your script creates as the arguement of the File() constructor.
var doc = app.activeDocument;
var ABs = doc.artboards;
for (var i = 0; i < ABs.length; i++) {
app.selection = null;
ABs.setActiveArtboardIndex(i);
doc.selectObjectsOnActiveArtboard();
var file1 = new File(app.activeDocument.path + "/file" + i + ".dxf");
var CAD = new ExportOptionsAutoCAD();
CAD.exportSelectedArtOnly = true;
CAD.exportFileFormat = Au
...
Copy link to clipboard
Copied
Okay so I was able to create the Saving with a Suffix piece... but it is saving as an AI File... is there a way I can adjust this to Export as an AutoCAD Version 2007/2008/2009 DXF file?
Thank you for looking! 🙂
var doc = app.activeDocument;
var boards = doc.artboards;
var strEnter = doc.name; //alert(strEnter);
var soNum = strEnter.slice(0,7);
var myNum = 1;
var arrayCount;
var arrayLength;
var arr;
var sc = "/";
var folderPrefix = sc + sc + "idp-fs-02" + sc + "Graphics" + sc;
var searchString1 = /\d{7}/;
var searchString2 = /(\d)(\d)(\d)/;
if (strEnter != null && searchString1.test(strEnter) === true) {
var strEnter = strEnter.replace(/^0+/, '');
var str = null;
var arr = strEnter.match (searchString2);
var folder1 = shorten (arr[1], first) +"-"+ shorten (arr[1], last) + sc;
var folder2 = shorten (arr[1]+arr[2], first) +"-"+ shorten (arr[1]+arr[2], last) + sc;
var folder3 = shorten (arr[1]+arr[2]+arr[3], first) +"-"+ shorten (arr[1]+arr[2]+arr[3], last) + sc;
var folderString = (folderPrefix + folder3);
function shorten (strt1, num) {
str = strt1 + num;
return str = str.slice(0, 7);
}
activeFolder = new Folder (folderString);
if (activeFolder.exists === false) {
activeFolder.create();
}
// loop through all artboards, make each one active and render before moving onto the next
for(var i = 0; i < boards.length; i++) {
doc.artboards.setActiveArtboardIndex(i);
var saveOptions = new IllustratorSaveOptions();
var aiDoc = new File(folderString + strEnter +"_"+(i+1).toString()); //alert(aiDoc);
saveOptions.saveMultipleArtboards = true;
saveOptions.artboardRange = (i+1).toString();
doc.saveAs(aiDoc, saveOptions);
}
}
Copy link to clipboard
Copied
To export as AutoCAD (I've just made a guess that AutoCADRelease21 corresponds to AutoCAD 2007):
var file1 = new File(app.activeDocument.path);
var CAD = new ExportOptionsAutoCAD();
CAD.exportFileFormat = AutoCADExportFileFormat.DXF;
CAD.version = AutoCADCompatibility.AutoCADRelease21;
app.activeDocument.exportFile(file1, ExportType.AUTOCAD, CAD);
Copy link to clipboard
Copied
@femkeblanco Thank you! Do you know where I can place that within my existing script to output a DXF file for each Artboard?
Copy link to clipboard
Copied
See if this works for you. If so, you can use the path your script creates as the arguement of the File() constructor.
var doc = app.activeDocument;
var ABs = doc.artboards;
for (var i = 0; i < ABs.length; i++) {
app.selection = null;
ABs.setActiveArtboardIndex(i);
doc.selectObjectsOnActiveArtboard();
var file1 = new File(app.activeDocument.path + "/file" + i + ".dxf");
var CAD = new ExportOptionsAutoCAD();
CAD.exportSelectedArtOnly = true;
CAD.exportFileFormat = AutoCADExportFileFormat.DXF;
CAD.version = AutoCADCompatibility.AutoCADRelease18;
app.activeDocument.exportFile(file1, ExportType.AUTOCAD, CAD);
}
Copy link to clipboard
Copied
That did it!!! I was Looping on the wrong piece of my script and couldn't figure out how to do the individual artboards for export and you solved it in like 12 lines of code!!
In all Sincerity, Thank you!
Copy link to clipboard
Copied
Glad I could help.
Copy link to clipboard
Copied
I found this here
https://ai-scripting.docsforadobe.dev/jsobjref/ExportOptionsAutoCAD.html#jsobjref-exportoptionsautoc...
and I have no clue how to include it in the script correctly...
// Export DXF Files for AutoCAD 2007/2008/2009
Copy link to clipboard
Copied
Also, see @renél80416020's answer here.
Copy link to clipboard
Copied
Bonjour Bryan,
Je peux faire un script pour vous...
René
Copy link to clipboard
Copied
Thank you! I can get my Script to do what I need it to do, except it only creates 1 DXF file.
If I have 3 artboards I need 3 DXF files. 1 for each artboard.
Copy link to clipboard
Copied
Hello,
I am new to Illustrator scripts. I am trying to make the script you are talking about but I have zero experiance.
I have several PDF files. Each file has 50+ artboards.
I want to open 1 PDF and export all artboards as seperate DXF files.
These are the settings:
AutoCAD Version 2010/2011/2012
scale 1:1 Milimeters
Maximum Editability
Outline Text
As I understand, I have to copy paste the script into notepad and save it in *.vbs file format. Then I open Illustrator, open the PDF I want and go to File > Scripts > Other scripts
But everything I try, I always get: "Expected statement" or "Expected end of statement"
I can make a small donation for someone who helps me.
Copy link to clipboard
Copied
Bonjour Ivan,
Extension .js (pour JavaSript)
Copy link to clipboard
Copied
@Ivan__V as @renél80416020 said, save it as *.js or *.jsx (not *.vbs).