Skip to main content
Inspiring
June 17, 2023
Answered

JSX method/function does not execute in Illustrator

  • June 17, 2023
  • 1 reply
  • 465 views

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? 

This topic has been closed for replies.
Correct answer Charu Rajput

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?')
    })

 

1 reply

Charu Rajput
Community Expert
Charu RajputCommunity ExpertCorrect answer
Community Expert
June 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?')
    })

 

Best regards
OhmsGAuthor
Inspiring
June 19, 2023

You're awesome and thank you!