V8 ScriptEditor python testing and bugs

Hi Eshan, can you please explain to me why Rhino has to install the same libraries each time I run a script on a fresh start of Rhino? Isn’t it installed? Is it just temporarily? Or have I missed something?
I also see that this happens every time a script is ran from a button, so some of my tools takes 8 seconds every time they are pressed because they install libraries over and over.

(And it would be really great if Rhino got locked and some feedback was given while this happens, because right now we can start other commands while this happens, or select other objects that are wrongly used if get-preselect=True is used)

Thanks again for the great work you have done, it is truly a huge step forward for me to be able to use libraries with python.

1 Like

@Holo

  • Ok this is great to know. I can make the “Restore” step lock the UI so nothing else could be done.
    • RH-73915 “Restore Packages” step should lock the UI so user can not make changes that changes script behaviour
  • Currently when you install a new Rhino WIP, it will setup a fresh instance of CPython runtime (Initialize Languages step). This will stop happening so frequently when we release the official Rhino as the runtime should stay fairly fixed after
  • Scripts currently attempt to install pip packages on every run. I made a ticket to make this step smarter
    • RH-73914 Scripts attempt to install packages on every run. This is very slow

@Holo I applied a fix for both RH-73914 and RH-73915 for the next WIP build

2 Likes

Nice!!! Can’t wait to test it out! Thanks Eshan.

1 Like

I like that the script window is minimized when the script is ran, but if I run the command rs.OpenFileName() then that window is minimized too. Can you please look into that too?

(Now I have to click on the WIP icon on the task manager and click on the script icon for that window to restore the two windows so I can pick a file)

Hi @eirannejad I get a run script error if I use the path with backslash like this:
(This is the coding Windows uses if I copy the file path to memory)

bitmap_path = “C:\Users\myname\Pictures\images.jpg”

But it works with slash:
bitmap_path = “C:/Users/myname/Pictures/images.jpg”

Should both work?

This won’t work in any programming language that Rhino supports. Backslash is reserved for special characters like newlines (\n) and tabs (\t). If you need to use a backslash in a string, use double backslash.
bitmap_path = “C:\\Users\\myname\\Pictures\\images.jpg”

1 Like

My bad, you are so right, and I thought it worked in the pythonscripteditor but I see I was wrong.
Thanks for clearing that up!

1 Like

It’ll work with raw strings though:

Edit: In GHPython, didn’t test with the new editor.

Thanks, yes, I do that in other scripts, this was just a brainfart where I thought it worked in the pythoneditor and not in the ScriptEditor :wink:

1 Like

@Holo This should work in both languages so you don’t have to modify the literal string.

bitmap_path = r“C:\Users\myname\Pictures\images.jpg”
string bitmapPath = @“C:\Users\myname\Pictures\images.jpg”;
1 Like

Hi, it’s me again :wink:

I see that the latest update doesn’t show the errors in the same manner as before, making a bit harder to code for us noobs, but I guess this is being worked on. Right now I do the main typing in the PythonEditor and then copy it over the the RhinoCode ScriptEditor to test AND HERE comes the question :wink: :

Coud RhinoCode accept print without paranteses? A lot of python examples for Rhino uses print without them and it would be nice to be able to use scripts for v7 directly without having to edit them all.

Here you can see it works in the python editor but not in the new script editor.

Python 3 requires print to have parentheses while python 2 did not. It is typically one of the first things people run into when transitioning from 2 to 3.

1 Like

Hi @eirannejad , thanks for the great updates, the autocompletion works much better and faster now!
And being able to hightlight and copy from the Terminal is great.

  1. I still miss examples being shown like in EditPythonScript when we complete a command and hit “(” so I often open EditPythonScript alongside RhinoCode to quickly get the guidelines for the different commands in rhinoscriptsyntax or Rhino Common. Will this be implemented soon?

  2. I would like for the icon for new script to be on the left side of the script tabs instead of to the right, that way we can quickly make a new script with out having to widen the editor window to see the end of the tabs.
    image
    And personally I prefer the tab for the new scripts to be added to the far left instead of to the right of the current tab, but that’s just me, so if this follows a standard then I’ll adjust :wink:

  3. I would also prefer if Terminal was maximized on startup so I don’t have to click that every time.

  4. The terminal still needs a scrollbar for it’s content if the content is longer than the Terminal width.

  5. the print commands are not shown in realtime in the Command line. Please update this so we can send info to the Command line with print while a script is running. Now I have to use prompt instead, but then it isn’t shown in the history.

Here is a simple example:

print("Asking for user feedback")
real = rs.GetReal("Choose a number")
if real:
    print(real)