Skip to main content
Participant
September 25, 2018
Question

help with applescript running export script please

  • September 25, 2018
  • 3 replies
  • 2844 views

I have an applescript that I'm using to open a DPF in AI2017 and then running the ExportAsDWG script (copied from the Scripting/Sample Scripts folder). File opens and then Applescript bounces a message

Script Error

Adobe Illustrator got an error: Illegal argument - argument 2

- Required value is missing

Result

error "Adobe Illustrator got an error: Illegal argument - argument 2

- Required value is missing" number 1243

Is the related to the export as options possibly?

Any help appreciated!

Here is the modified ExportAsDWG script

var docRef = app.documents.add();

var groupItems = docRef.groupItems;

var groupRef = groupItems.add();

var pathItems = groupRef.pathItems;

// Save document as AutoCAD DWG file.

var destFolder = Folder.selectDialog('Select the folder to export the AutoCAD(DWG/DXF) file to:');

if (destFolder) {

  exportAutoCADOptions.exportFileFormat = AutoCADExportFileFormat.DXF;

  exportAutoCADOptions.exportOption = AutoCADExportOption.MaximumEditability;

  exportAutoCADOptions.version = AutoCADCompatibility.AutoCADRelease18;

  docRef.exportFile(destFile, ExportType.AUTOCAD, exportAutoCADOptions);

}

Here is the applescript

tell application "Adobe Illustrator"

  activate

  set inputs to "Macintosh HD:Users:bbb:Desktop:TEST:Test_PDF.pdf" as string

  set outputFolder to "Macintosh HD:Users:bbb:Desktop:TEST:Final.dwg" as string

  set params to {}

  open file inputs

  do script "CGExportAsDWG"

  close current document

end tell

This topic has been closed for replies.

3 replies

Legend
September 29, 2018

(*

  "do script" is for executing an action. 

  To execute JavaScript, use "do javascript". 

*)

tell application "Adobe Illustrator"

  do javascript "var docRef = app.documents.add();

var groupItems = docRef.groupItems;

var groupRef = groupItems.add();

var pathItems = groupRef.pathItems;

// Save document as AutoCAD DWG file.

var destFolder = Folder.selectDialog('Select the folder to export the AutoCAD(DWG/DXF) file to:');

if (destFolder) {

  var destFile = new File(destFolder + '/ExportAsDWG.dwg');

  var exportAutoCADOptions = new ExportOptionsAutoCAD();

  exportAutoCADOptions.exportFileFormat = AutoCADExportFileFormat.DXF;

  exportAutoCADOptions.exportOption = AutoCADExportOption.MaximumEditability;

  exportAutoCADOptions.version = AutoCADCompatibility.AutoCADRelease18;

  docRef.exportFile(destFile, ExportType.AUTOCAD, exportAutoCADOptions);

}"

end tell

Participant
September 27, 2018

Thanks for your help Kevin! Very helpful

Inspiring
September 26, 2018

HI, try the below,   the jsx file for me errored

tell application "Adobe Illustrator"

activate

set CGExportAsDWG to "Macintosh HD:Users:bbb:Desktop:CGExportAsDWG.jsx" --path to jsx file

set inputs to "Macintosh HD:Users:bbb:Desktop:TEST:Test_PDF.pdf" as string

set outputFolder to "Macintosh HD:Users:bbb:Desktop:TEST:Final.dwg" as string

set params to {}

open file inputs

open file CGExportAsDWG --open jsx file

close current document

end tell

Inspiring
September 27, 2018

I looked at the jsx file you copied from Illustrator and found out why the jsx file failed, a few lines were missing

var docRef = app.documents.add();

var groupItems = docRef.groupItems;

var groupRef = groupItems.add();

var pathItems = groupRef.pathItems;

// Save document as AutoCAD DWG file.

var destFolder = Folder.selectDialog('Select the folder to export the AutoCAD(DWG/DXF) file to:');

if (destFolder) {

       var destFile = new File(destFolder + '/ExportAsDWG.dwg');

var exportAutoCADOptions = new ExportOptionsAutoCAD();

exportAutoCADOptions.exportFileFormat = AutoCADExportFileFormat.DXF;

exportAutoCADOptions.exportOption = AutoCADExportOption.MaximumEditability;

exportAutoCADOptions.version = AutoCADCompatibility.AutoCADRelease18;

docRef.exportFile(destFile, ExportType.AUTOCAD, exportAutoCADOptions);

}