Script Runs on Every File Open - Why?

I had this issue in Rhino 6 and now also in Rhino 7. I have ten or so scripts that I load into RhinoScript to load when Rhino starts. There is a single script that always runs when I open Rhino, so when I take control of the cursor, the program is already in mid-command, and it is super frustrating - I have to hit escape to exit the command as soon as Rhino opens. In Rhino 6 the script was MoveProject, now in Rhino 7 it is HarmonyDistribution. When I remove the script, the issue is gone.

I have tried loading and unloading, changing the order of the scripts that load, unassigning aliases to the scripts, and cannot figure this one out. Any help is much appreciated.

Hi,

Did you find a fix already?

Could it be the script is setup as a startup script?

Or startup command

Hi Willem - thank you for the reply! I have not found a fix. There are no commands listed under the general tab you screenshot but I do have scripts loaded at startup. What I cannot figure out is if I unload the HarmonyDistribution script, none of them actually run on startup. Only that one…

Can you open the Harmony script in a text editor and do a screen capture of the first several lines in the file?

I haven’t done any vb stuff in a long while, but IIRC, scripts could be set up to run immediately on load - or not. @pascal, do you remember how this worked? My 3 remaining brain cells seem to have gotten occupied with other information. :stuck_out_tongue_winking_eye:

Yeah, if the main section of the script is called in the script, it will run on loading,

Call Main()

Sub Main ()
blah
blah
End Sub()

will run on loading. Without the top level (not called from within another sub) line that calls the main sub, it will just load. That line can be anywhere on the top level, I believe, and the script will run.

-Pascal

That’s what I thought, but I wasn’t sure anymore…

See screenshot below - I don’t see the “Call Main()” you mentioned. Is this a matter of deleting something in the script text? I’m afraid scripting is beyond my capability.

Look at line 38. From what I recall the use of “Call” was optional, but even without it, it’s going to run.

At least that’s how I remember it.

1 Like

Thanks for the feedback, everyone. So what it sounds like is there is not a fix to this one? It isn’t the end of the world - I just have to cancel the command on each file open.

If you comment out line 38 and save the file, does it still run on startup?

Amazing - I deleted line 38 and now it doesn’t run on startup. Thank you!

Does it run if you call the script alias?

Yes, that appears to be working just fine.

OK, problem solved then!

BTW, it’s not necessary to delete the line of code, to inactivate it you can just comment it out. In VB(Rhino)Script, comments start with a ' (apostrophe). If you put an ' at the beginning of a line, it will still be there and readable, but the script will ignore it when it runs.

Thanks for clarifying - I’m a total noob at scripting so I’ll have to remember that one!