• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to Script Exporting Multiple Page PDFs to DXF files

Engaged ,
Nov 30, 2021 Nov 30, 2021

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 🙂

 

TOPICS
Scripting

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Dec 01, 2021 Dec 01, 2021

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
...

Votes

Translate

Translate
Adobe
Engaged ,
Nov 30, 2021 Nov 30, 2021

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);
    }   
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 30, 2021 Nov 30, 2021

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);

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 01, 2021 Dec 01, 2021

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 01, 2021 Dec 01, 2021

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);
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 02, 2021 Dec 02, 2021

Copy link to clipboard

Copied

@femkeblanco 

 

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 02, 2021 Dec 02, 2021

Copy link to clipboard

Copied

Glad I could help. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 30, 2021 Nov 30, 2021

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

    exportOptionsAutoCAD.exportFileFormat.DXF;    
    AutoCADCompatibility.AutoCADRelease17;
    AutoCADGlobalScaleOption.OriginalSize;
 
(I don't need the AI files but I am working with what I have)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 30, 2021 Nov 30, 2021

Copy link to clipboard

Copied

Also, see @renél80416020's answer here.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 01, 2021 Dec 01, 2021

Copy link to clipboard

Copied

Bonjour Bryan,

Je peux faire un script pour vous...

René

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 01, 2021 Dec 01, 2021

Copy link to clipboard

Copied

@renél80416020 

 

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 18, 2022 Oct 18, 2022

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 18, 2022 Oct 18, 2022

Copy link to clipboard

Copied

Bonjour Ivan,

Extension .js (pour JavaSript)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 19, 2022 Oct 19, 2022

Copy link to clipboard

Copied

LATEST

@Ivan__V  as @renél80416020 said, save it as *.js or *.jsx (not *.vbs). 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines