I’m new to ruby, so probably it’s something basic.
I’m trying to get a variable containing just a folder path via UI.openpanel.
There seems to be no option to select a folder, so I’m asking users to select any file in the folder, so that in the next step I can just remove filename from it (ugh).
imglocation = UI.openpanel("Choose any image from images folder", "/", "Image Files|*.jpg;*.png;||")
However, using this code returns the path stripped of slashes: C:UsersMeDesktopimage.jpg
Perhaps you have not installed SketchUp properly ?
When logged in as your normal User account…
Find its installer exe file’s icon - probably in your Downloads folder ?
Select it and right-click > context-menu > “Run as administrator”
When prompted, choose ‘Repair’.
Restart SketchUp and retest.
Installing any complex app, like SketchUp, in any other way causes weird and unexpected issues.
Do NOT double-click the installer’s exe icon to Run it.
Even if you have admin-powers you still need to install it properly !
Also do not install it whilst logged in with the separate ‘administrator’ account, and do NOT set the SketchUp.exe Properties to “always run as administrator” - this leads to new separate issues…
Thanks @TIG, I found the bug.
It was in the beautiful Alexander Schreyer’s Ruby code editor, which I was using.
Running same code straight in Ruby Console works perfectly.
That’s a pity - I’ll report to him, and go looking for some other workflow…
Perhaps Aerelius’ Ruby Console+ could be of interest? I use the native console myself (don’t really know why, just have got so used to it I guess) but this one looks and feels very much like a console, and probably doesn’t have that specific bug.
Thanks @DanRathbun, that looks way more elegant, I’ll give it a try.
Also, I see you can select multiple directories. Is it somehow possible to select multiple files as well?
Thanks @eneroth3, naturally, I continued working with Aerelius’ Ruby Console+ after this, - it’s quite good as well. Funny enough, that Console+ did return folder names, but with backslashes instead of forward ones, so I had to replace them with .gsub!. And after I did that to my code, it became usable on Schreyers’ Ruby code editor again!
I guess you’re right about Schreyers’ Ruby code editor - it doesn’t escape before output,
because UI.openpanel("Choose", "/", "*") removes the slashes,
but UI.openpanel("Choose", "/", "*").gsub!(/\\/, '/') outputs a nice path.