Copy link to clipboard
Copied
I'm using a script which stores its Prefs in the script folder. But it does not work in my case, the file will not be created. It does not get a path where to build it, so no file is being stored.
I gave Illustrator full hard drive privileges already, but the script will not throw the script path.
var scriptPath = (new File($.fileName)).path
will throw "", with alert just an empty field
var scriptName = (new File($.fileName))
will throw /3 with alert (scriptName)
Any idea, why the script will not get it's path?
app.path will throw the rigth path to the app ...
@GNDGN @m1b @Sergey Osokin Oh f*** I got the issue!
I use a plugin called "Scripts Panel" to organize my scripts, as Adobe offers such a freaky script menu (actually from two different developers) and each of these break exactly this one code!
Starting the script with Illustrator menu it will make it run!
Copy link to clipboard
Copied
I have run into this exact issue a few times with client projects and on the command palette project (especially when using script launchers). So I always use one of the built-in Folder Class Properties of the Folder Object to save any preference files (or anything I need to be able to access easily on multiple computers/computer types). If it is something I don't want the user messing with, I will typically put it in the `Folder.userData` folder. If it is something they need to be able to access then I'll use either `Folder.desktop` or `Folder.myDocuments`.
And a note on "Script Launchers". I have found they all have different methods of executing the scripts you load into them. Some simply execute the actual script file (which typically doesn't cause too many issues), but others do weird things like reading and executing your actual code or firing the code with BridgeTalk.
It is very hard to plan for all of these possibilities when creating scripts, so I try and show people how to load scripts in the main Ai Script menu. Then it can easily be fired via a hotkey with something like BetterTouchTool/Keyboard Maestro for Mac or AutoHotkey for Windows.
Copy link to clipboard
Copied
Thanks @jduncan. In hindsight it is an obvious possibility given that $.fileName is returning the name of the active script but the script launchers themselves are the active scripts. I didn't think of it because I don't use any script launchers. My setup is to sync my development scripts folder with Illustrator's script folder (I use Hazel to do the syncing automatically) and then I launch them from keyboard with Palletro.
- Mark
Copy link to clipboard
Copied
@m1b, Hazel is a great solution for keeping dev scripts in sync with AI's script folder. I never though of that. Thanks for the idea 👍
Copy link to clipboard
Copied
BetterTouchTool sounds like a great idea!