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
Hi @Someone75, it works as expected for me on MacOS 14.2, Illustrator 28.0.
What do you get when you run the script file from your Desktop? If it works on Desktop, maybe look at the permissions on the "script folder" you mentioned. Could they be restrictive? It doesn't seem likely, because it wouldn't run at all if you didn't have read access, and you shouldn't need write access in your example script.
Hmm. Can you try this test code, just to rule out code issues:
(function () {
alert($.fileName);
})();
- Mark
Copy link to clipboard
Copied
@m1bI ran your script from desktop and it throws "3" ...
Copy link to clipboard
Copied
...it throws 3 twice?
Copy link to clipboard
Copied
Very curious. Again, just to rule out possibilities, can you do this?
1. Restart computer.
2. Launch Illustrator
3. Run my script (do not run any other script first).
- Mark
P.S. Trivial point that affects nothing, so I hope you don't mind me saying, just for learning: in many programming contexts (including ExtendScript) the term "throw" means throwing an exception (an error). In this case the alert function is showing "3", not throwing "3". You would say a function returns "3", not throws "3".
Copy link to clipboard
Copied
Sorry for the wrong term. As it does not work on two different machines, the restart did not address the issue ...
It's so wired. Even the "/3" alert. Where dos the 3 come from? It will always be three, no other number. ...
Copy link to clipboard
Copied
Yes, it's really very strange. Do you use VSCode and ExtendScript Debugger? It would be interesting to see if the script worked correctly when run from VSCode, and also to look at $ object in the debugger.
- Mark
Copy link to clipboard
Copied
No I just use Illustrator and Sublime. No debuggers at hand ...
Copy link to clipboard
Copied
You can use this package for basic ExtendScript debugging via ST:
https://github.com/rendertom/Sublime-Text-Adobe-Script-Runner
Copy link to clipboard
Copied
@GNDGN @m1b How wired is this?
Thaks a lot @GNDGN for the debugging package. So I started the script from sublime fodler and what happened?
The debugger opened Illustrator and I got the right pathes!
/Applications/Adobe Illustrator 2024/Presets.localized/de_DE/Skripten/
Than I ran the skript manually from Illustrator and what happened?
The wrong output. What that, how is this possible?
Copy link to clipboard
Copied
Another test (without much hope):
alert($.reflect.properties);
alert(""
+ app.version
+ '\n' + $.fileName
+ '\n' + $.os
+ '\n' + $.engineName
+ '\n' + $.includePath
);
By the way, it is the $.fileName that is returning "3" that is the problem. If you do
alert(new File("3"));
you will get "/3".
- Mark
Copy link to clipboard
Copied
@mb1 Starting your script with Extend Script debugger in Sublime I get these informations:
error,version,build,buildDate,global,stack,level,flags,strict,locale,localize,decimalPoint,memCache,appEncoding,screens,os,fileName,line,hiresTimer,dictionary,engineName,includePath,__proto__
starting it manually I get:
Copy link to clipboard
Copied
@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
Thanks for resolving this exciting episode. 😉
Copy link to clipboard
Copied
@GNDGN It was only possible because of your help! I would never, ever have expected this root cause ... on two different machines with different plugins and same error type ... really strange.
Copy link to clipboard
Copied
Excellent! Nice to have the cause discovered. I notice someone has posted as a bug on the github repo (maybe you!). Hopefully the developer can fix it. The code seems to evaluate the script through BridgeTalk I think. Maybe they can manually set $.fileName if the bridgeTalk route doesn't set it automatically? We'll see.
Copy link to clipboard
Copied
I use this extension: Scripshon Trees https://exchange.adobe.com/apps/cc/15873/scripshon-trees.
Copy link to clipboard
Copied
@Sergey OsokinI tested this script, too, but as a designer: It looks so old old old fashioned. I cannot use it without tears in my eyes, because of the uggly interface ... ðŸ˜
Copy link to clipboard
Copied
Appearance vs. functionality 🙂 Having a search box in Scriptshon Trees is important to me because I have a lot of scripts and some I run in the search results by first letters. Also, Scriptshon has a better view of the tree structure of the catalogs. In the Scripts panel, there is no tabulation and all catalogs and scripts in them are displayed in a single list. This is my subjective perception.
But I give credit to the fact that the Scripts panel has Live Input and Load Remote Script, which are important chips. So I installed both extensions.
Copy link to clipboard
Copied
Thanks for confirming this, I had an issue with a script I made a dialof for. One user also had this issue, after lots of messages back and forth. I believe we came to the same issue.
Copy link to clipboard
Copied
The read and write permissions of the script folder must be assigned to the user who is executing the script. (https://support.apple.com/guide/mac-help/mchlp1203/mac)
With the correct permissions, this test is running successfully for me:
var scriptPath = new File(File($.fileName).path + "/test.txt");
scriptPath.encoding = "utf-8";
scriptPath.open("w");
scriptPath.write("Hello world!");
scriptPath.close();
Copy link to clipboard
Copied
I know that it works for most others. My question was actually, why it does not work in my case on two different machines.
Permissions are set right, as app.path will work quite well and I run the script from Desktop.
Your skript does not work in my case, too. The generated path is /test.txt
Anyway I do not know which other permissions I would have to set. Illustrator hast full hard disk access and I (the current user) have access like all admins. I can read and write to all non-system restricted folders.
Copy link to clipboard
Copied
We are testing English localizations. But in another thread I saw your de_DE/Skripten path. Maybe we should look at different localizations of Adobe Illustrator on macOS? Or maybe macOS itself is German and this is the problem with $.filename in ExtendScript.
Because yesterday I had an update to macOS 12.7.2 without script path errors. English macOS, en_GB localization of Adobe Illustrator.
Copy link to clipboard
Copied
@Sergey OsokinMeanwhile I think it's exacrly what you write:The German OS and German Illustrator. As all other terms work, this is the only reason I could think of at the moment.
Updatet to 12.7.2 but it did not change the results.
alert($.fileName) >> 3
alert(new File($.fileName) >> /3
Copy link to clipboard
Copied
@jduncan I wondered if this thread might be relevent to your AI Command Palette project?
- Mark