• 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 user Document.importFile() function?

New Here ,
Jun 14, 2017 Jun 14, 2017

Copy link to clipboard

Copied

Hello,

I would like to try out the Document.importFile() function introduced in CC2015.

Illustrator 2015 changes?

CC2015Document.importFile (importFile: File )
Adobe Illustrator 19 Type Library
Import the file into current Ai document.
importFile: Data Type: File

The file to import in the current document.

But I don't know which arguments to pass to the function.

I tried this code:

var doc = app.activeDocument;

var file = File('/Users/outcrash/Desktop/Sketches/CM8319_big.svg');

doc.importFile(file);

But I get "Illegal argument - argument 2"

I tried several variations for the second argument: 1, true, false, null etc...

Looking at the Data Browser in ESTK, the function clearly exists, but there are no arguments shown:

Screen Shot 2017-06-14 at 5.30.35 PM.png

When i print out the function like this:

$.writeln(doc.exportSelectionAsAi);

I only get this in the console:

function importFile() {

    [native code]

}

I also tried stepping into the function by setting a breakpoint, but it wouldn't go into the code.

Has anybody tried that function already and know which arguments to pass?

TOPICS
Scripting

Views

646

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

Enthusiast , Jun 15, 2017 Jun 15, 2017

Hi, the full documentation for that is :

Document.importFile (importFile: File , isLinked: Boolean , libraryName: string , itemName: string , elementRef: string , modifiedTime: number , creationTime: number , adobeStockId: string , adobeStockLicense: string )

So it seems only relative to  importing file from Creative Cloud Libraries, and the 1st argument should be Path (or the URL) to the library file. But still don't know what that is like. The 2nd argument will be true or false, all the others a

...

Votes

Translate

Translate
Adobe
Enthusiast ,
Jun 15, 2017 Jun 15, 2017

Copy link to clipboard

Copied

Hi, the full documentation for that is :

Document.importFile (importFile: File , isLinked: Boolean , libraryName: string , itemName: string , elementRef: string , modifiedTime: number , creationTime: number , adobeStockId: string , adobeStockLicense: string )

So it seems only relative to  importing file from Creative Cloud Libraries, and the 1st argument should be Path (or the URL) to the library file. But still don't know what that is like. The 2nd argument will be true or false, all the others are optional.

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
Participant ,
Jun 15, 2017 Jun 15, 2017

Copy link to clipboard

Copied

As an option, try:

activeDocument.importFile( File('your file path') );

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 ,
Jun 16, 2017 Jun 16, 2017

Copy link to clipboard

Copied

LATEST

Thanks moluapple​ and Alexander LAdygin

For other people, you can use the Object Model Viewer for looking all functions available.

On Mac go to Help -> Object Model Viewer.

Didn't know about this.

The only thing which has been bugging me for quite a long time now is the Swatch conflict popup.

Screen Shot 2017-06-16 at 9.53.59 AM.png

Even though I'm using:

app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

I still get these alerts.

That's why I was trying out the importFile() function, hoping to avoid that popup.

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