Copy link to clipboard
Copied
I'm currently trying to run some code to be executed in an illustrator file from my script. I'll explain my scenario and what I'm trying to achieve.
I'm using illustrator cc 2019.
I have the extensions panel test from Adobe and in it there is the following file in CSXS/manifest.xml here I have my resource and script path like this:
<MainPath>./html/index.html</MainPath>
<ScriptPath>./jsx/core.jsx</ScriptPath>
Now in my index html file I put this:
var csInterface = new CSInterface();
csInterface.evalScript('app.documents.add();', evalScriptCallback());
in core.jsx file I put this call back:
function evalScriptCallback(result)
{
alert('this is my test');
}
This isn't working for me and nothing happens. The expected result would be to have an alert that says "This is my test".
However when I put this function evalScriptCallback in my index.html file then it works. I'm assuming the core.jsx file isn't linking but it's in the manifest.xml file that is my confusion.
I also tried this:
removing the core.jsx from the manfiest and adding it in a jsx call back file like so:
jsx.file("../jsx/citylocs.jsx", myFabCallBack);
Can anyone give me any direction?
Copy link to clipboard
Copied
Could you show me the full HTML source?
Copy link to clipboard
Copied
Here it is along with my file structure.
Index.html
----- different htmls in the left side bar
---- myfile.html <--- this is the file I'm working from this is selected from index.html
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test Nodejs</title>
<script type="text/javascript" src="../js/JQuery/jquery.js"></script>
<script src="../js/CSInterface.js"></script>
<script>
var csi = new CSInterface();
csi.evalScript("myFreshCall()");
}
</script>
<style type="text/css">
#dbs {
width: 760px;
height: 280px;
border: 1px solid #B8B8B8;
padding: 10px;
color: #E3E3E3;
}
.serverInfo {
width: 67px;
margin-right: 3px;
}
.sql {
width: 625px;
margin-top: 40px;
}
.selectMongoAPI {
width: 500px;
margin-top: 40px;
}
.serverInfoDiv {
margin-top: 25px;
}
.resultTable {
margin-top: 55px;
}
.result {
width: 680px;
height: 47px;
resize: none;
}
</style>
</head>
<body>
<div id="dbs">
<div>
<table>
<tr>
<span id="restartExit" class="Button">Restart Extension</span>
<label>Check if Node is enabled: </label>
<button name="btnCheckEnabled" id="btnCheckEnabled"> IsNodeJSEnabled </button>
</tr>
</table>
<label for="db">Connect to get orders: </label>
<select name="db" id="db">
<option value="mysql">Shopify</option>
</select>
<button name="btnConnect" id="btnConnect"> Connect to DB </button>
</div>
<div>
<label id="userInputLabel"></label>
<select name="selectSQLAPI" id="selectSQLAPI" class='selectSQLAPI'>
</select>
<button name="btnExecute" id="btnExecute"> Setup Templates </button>
</div>
<div>
<table class="resultTable">
<tr>
<td><label for="result">Result:</label></td>
<td><textarea id="result" name="result" class="result" readonly="readonly" ></textarea></td>
</tr>
</table>
</div>
</div>
</body>
</html>
The file core.jsx contains:
function evalScriptCallback()
{
alert('this is my test');
}
Copy link to clipboard
Copied
Ok so when I put the evalScript
var csi = new CSInterface();
csi.evalScript("evalScriptCallback()");
In the main index.html file it works. But when it's in a sub file like the myindex.html which is nested inside index.html it does not work.
Is there away to link it so it'll work?
Copy link to clipboard
Copied
Ah man! Not it works!
I notice that the problem is it doesn't reload the core.jsx file when I close the extensions pallet. I think it wasn't picking up my test code until I restarted illustrator. Is this the way it is?
Copy link to clipboard
Copied
Here is a diagram of how evalScript method works.
and you can use remote debugging. Reference below.
CEP-Resources/CEP 8.0 HTML Extension Cookbook.md at master · Adobe-CEP/CEP-Resources · GitHub