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

JSX method/function does not execute in Illustrator

Contributor ,
Jun 17, 2023 Jun 17, 2023

Copy link to clipboard

Copied

I have done this before and for the life of me I can't get why it's not working this time around.

I create two variables which have the root path and file to a jsx script:

 

    const root = decodeURI(csiRun.getSystemPath("extension")).replace(/file\:\/{1,}/, "");
    const createArtBuild = `${root}/jsx/buildArt.jsx`;

 

Inside of buildArt.jsx I have a function with alert:

 

function buildArtwork() {
    alert('this is running')
}

 

 

I then evaluate the file and run the method:

 

    csiRun.evalScript(`$.evalFile('${createArtBuild}')`);

                    // execucte jsx in illustrator
                    csiRun.evalScript(`buildArtwork(${'test'})`, async (returnVal) => {  
                        console.log('this hit?')
                    })

 

 

I do get console.log "this hit" but the function never alerts.

I've set the correct settings in terminal for the CEP.

defaults write com.adobe.CSXS.11 PlayerDebugMode 1

 

Any idea what I'm doing wrong? 

TOPICS
Scripting

Views

207

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

Community Expert , Jun 18, 2023 Jun 18, 2023

Hi @OhmsG , By looking at your file structure and method, I have written extra line above your hit console line

 console.log(returnVal);

to see whether I am getting any error or not. So there is an error when which is mentioned below

Error 2: test is undefined.Line: 1->  buildArtwork(test)

 

So correct way will be

csiRun.evalScript(`buildArtwork(${JSON.stringify('test')})`, async (returnVal) => {
        console.log(returnVal);
        console.log('this hit?')
    })

 

Votes

Translate

Translate
Adobe
Community Expert ,
Jun 18, 2023 Jun 18, 2023

Copy link to clipboard

Copied

Hi @OhmsG , By looking at your file structure and method, I have written extra line above your hit console line

 console.log(returnVal);

to see whether I am getting any error or not. So there is an error when which is mentioned below

Error 2: test is undefined.Line: 1->  buildArtwork(test)

 

So correct way will be

csiRun.evalScript(`buildArtwork(${JSON.stringify('test')})`, async (returnVal) => {
        console.log(returnVal);
        console.log('this hit?')
    })

 

Best regards

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
Contributor ,
Jun 18, 2023 Jun 18, 2023

Copy link to clipboard

Copied

LATEST

You're awesome and 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