RunPythonScript first call is slow

_RunPythonScript takes up to 20 seconds to react on first call.
This is when the PC was rebooted, or Rhino slept overnight.
After the first call the reaction time is normal.

The irritating thing is on first call there is no info, like “Initializing Python…” or something.
Rhino is simply unresponsive.

Is there a way to speed this up?


SysInfo

Rhino 8 SR6 2024-3-19 (Rhino 8, 8.6.24079.11001, Git hash:master @ 0d13b06881495403bd28e1cee93f8c8ea0baec7c)
License type: Commercial, Build 2024-03-19
License details: Cloud Zoo

Windows 11 (10.0.22631 SR0.0) or greater (Physical RAM: 32GB)
.NET 7.0.17

Computer platform: DESKTOP

Standard graphics configuration.
Primary display and OpenGL: NVIDIA GeForce RTX 2070 (NVidia) Memory: 8GB, Driver date: 11-29-2023 (M-D-Y). OpenGL Ver: 4.6.0 NVIDIA 546.29
> Accelerated graphics device with 4 adapter port(s)
- Windows Main Display attached to adapter port 0

OpenGL Settings
Safe mode: Off
Use accelerated hardware modes: On
Redraw scene when viewports are exposed: On
Graphics level being used: OpenGL 4.6 (primary GPU’s maximum)

Anti-alias mode: 8x
Mip Map Filtering: Linear
Anisotropic Filtering Mode: High

Vendor Name: NVIDIA Corporation
Render version: 4.6
Shading Language: 4.60 NVIDIA
Driver Date: 11-29-2023
Driver Version: 31.0.15.4629
Maximum Texture size: 32768 x 32768
Z-Buffer depth: 24 bits
Maximum Viewport size: 32768 x 32768
Total Video Memory: 8 GB

Rhino plugins that do not ship with Rhino
C:\Program Files\SimLab\Plugins\SimLab 3D PDF From Rhino 6\plugins\SimLabPDFExporter.rhp “SimLab PDF Exporter”
C:\Program Files\Common Files\McNeel\Rhinoceros\7.0\Plug-ins\XNurbs (80be33b0-13b2-4ac4-9c77-03829214f9e9)\6.0.0.0\XNurbsRhino7.rhp “XNurbs”

Rhino plugins that ship with Rhino
C:\Program Files\Rhino 8\Plug-ins\Commands.rhp “Commands” 8.6.24079.11001
C:\Program Files\Rhino 8\Plug-ins\WebBrowser.rhp “WebBrowser”
C:\Program Files\Rhino 8\Plug-ins\rdk.rhp “Renderer Development Kit”
C:\Program Files\Rhino 8\Plug-ins\RhinoRenderCycles.rhp “Rhino Render” 8.6.24079.11001
C:\Program Files\Rhino 8\Plug-ins\rdk_etoui.rhp “RDK_EtoUI” 8.6.24079.11001
C:\Program Files\Rhino 8\Plug-ins\NamedSnapshots.rhp “Snapshots”
C:\Program Files\Rhino 8\Plug-ins\MeshCommands.rhp “MeshCommands” 8.6.24079.11001
C:\Program Files\Rhino 8\Plug-ins\IronPython\RhinoDLR_Python.rhp “IronPython” 8.6.24079.11001
C:\Program Files\Rhino 8\Plug-ins\RhinoCycles.rhp “RhinoCycles” 8.6.24079.11001
C:\Program Files\Rhino 8\Plug-ins\Toolbars\Toolbars.rhp “Toolbars” 8.6.24079.11001
C:\Program Files\Rhino 8\Plug-ins\3dxrhino.rhp “3Dconnexion 3D Mouse”
C:\Program Files\Rhino 8\Plug-ins\Displacement.rhp “Displacement”
C:\Program Files\Rhino 8\Plug-ins\SectionTools.rhp “SectionTools”

The delay (a few seconds) was already there in Rhino 7, but in Rhino 8 it got a lot slower. To solve the problem, I have a small startup script which I gave an alias LoadPython to and it runs when Rhino starts:

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
print "Rhino Version V{} - Python loaded!".format(rs.ExeVersion())

This seems also to work in V8, if I restart the computer, open Rhino, make an object and then run a script from an alias or button on it, it runs instantly.

As a couple of my scripts use Grasshopper components and that is also very slow to load, I added this line later:

import ghpythonlib.components

Anyway that seems to help. Opening ScriptEditor for the first time after a restart is still slow, and VERY slow after a new version install.

3 Likes

Hello guys,

Do you know why we need to open the ScriptEditor everytime we start Rhino?
This wasn’t needed before…

In a training last week, on the customers PC, it took > ONE MINUTE to get Python alive.
While that Rhino was unresponsive.

This is not acceptable.
Can’t Rhino initialize Python in a background task?

That sounds typical after a new version installation… if you launch ScriptEditor. I have never seen that just using already programmed tools that run via _-RunPythonScript

Ok, we know or guess the reason…

When you run a command in software, you expect an immediate response.
If immediate execution is not possible, a progress bar would be good.
“Initializing Python - please wait” + progress bar

When the software seems to do nothing, it is confusing and frustrating.

@Charles

We do have a progress bar on almost any form of running any scripts that required python initialization (e.g. RhinoPythonScript, ScriptEditor, or Grasshopper script component.

Is it possible that your Rhino window might be smaller and the progress bar is not visible?

This is a test that I just rain in my local SR7 build. See the progress bar at the bottom right:


s

@CSousa

Do you use any of scripting features in Rhino? If yes, and there are chanegs to the runtime, the scripting tool that you’d use (script editor, grasshopper component) will perform a one-time update when a new Rhino is installed.

Helvetosaur,

May I ask how you get the alias that loads python to run on start up?

Save the script somewhere.
Create an alias “LoadPython” (or whatever else you want) using
_-RunPythonScript "Full path to script" (include the .py extension)
In Options >Files, put the name of the alias in the box “Scripts to run at startup”
That’s it…

1 Like

Thank you so much! That’s a tremendous help!

No, not in here with (8.7.24101.10001, 2024-04-10).

The Rhino window is 1920x1080.
Also no progress bar when at 3840x2160.
_Reset makes no difference.

EDIT:
I tried in SR6, and I can see the progressbar now.

1 Like

Then the installer should do the initial things to do.
On software installation we are prepared to have to wait.

this is indeed sloe