
I am trying to use scripts in illustrator. Some of these require being able to import other scripts so I found the below code. When I try to run it I receive
Error 21: Undefined is not an object.
Line 6 -> var Libraries = (function(libpath){"
I have looked through other answers and it seems the issue is that "Libraries" (?) is undefined, and that I ought to define it first. Sadly I don't know what it ought to be defined as. Or I don't understand the problem in general.
I expected it to import helloworld.jsx and hence be able to run the helloWorld function. It threw up the error described above.
//Library importing function from https://gist.github.com/jasonrhodes/5286526 // indexOf polyfill from https://gist.github.com/atk/1034425 [].indexOf||(Array.prototype.indexOf=function(a,b,c){for(c=this.length,b=(c+~~b)%c;b<c&&(!(b in this)||this[b]!==a);b++);return b^c?b:-1;}); var Libraries = (function(libPath) { return { include: function(path) { if (!path.match(/\.jsx$/i)) { path = path + ".jsx"; } return $.evalFile(libPath + path); } }; })($.fileName.split("/").splice(0,$.fileName.split("/").indexOf("adobe_scripts") + 1).join("/") + "/lib/"); Libraries.include("HelloWorld.jsx"); helloWorld();
11 Answer
It's many moons since I did this stuff ... Isn't Libraries a function that takes a libPath, so you would need to call
Libraries('c:\whereever').include('HellowWorld.jsx');
ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobG5uYG6GdYGOoaawZaSkeqe112asp5yVm7avscNmoKxlnqTBbq3NZqabopWYwW6x0aumq2WZo3qrrdWaqpyqmaXB