Increase language support for scripts run at Rhino startup

Continuing a discussion in a different topic Migrating plugin from RhinoScriptCompiler to Script Editor - #6 by eirannejad, it seems like support for .rvb scripts in Rhino 8 is being put to pasture, @eirannejad are there any plans to support more languages in Rhino’s startup scripts?

Right now only .rvb are supported here:

I have a plugin that is a collection of python scripts made into Rhino commands, and it relies on two scripts being run at startup to

  1. start the plugin if its the first time that Rhino is being launched that day, and
  2. to automatically open associated grasshopper files for these example Rhino/GH files we have.

These .rvb scripts are dead simple scripts that just call the appropriate plugin command ( a plugin .py script) in Rhino.

'Calls the command to open a GH file of the same name as 3DM file in same folder
Option Explicit
Sub SameName()
	Dim commandName
	commandName = "OpenAssociatedGhFile"
	Call Rhino.Command(commandName, False)	
End Sub
SameName

It would be great for us to completely move away from .rvb and have the option to run .py scripts at startup or the option to have Rhino commands run on startup :slight_smile:

Hi Michael,

I agree that it would be good to be able to include python scripts on the startup list.

You probably know this, but in case you missed it; you can run python scripts at startup if you are willing to type command line options or run Rhino from a batch file. Here’s a post that shows an example: Launching Rhino from .bat and running command with space in path - #7 by dale

1 Like

Hi @Michael_H,

Try using this:

– Dale

I’ve logged the wish, btw.

https://mcneel.myjetbrains.com/youtrack/issue/RH-80862

– Dale

2 Likes

Thanks @dale - is it possible to add the commands to here with a python script? I’m hoping to automate this process so it can be deployed on all my colleagues’ computers.

Something similar to the below in rvb
Rhino.AddStartupScript(filePath)

Hi @Michael_H, you might try something like below:

#! python 2
import Rhino

def AddStartupCommand(str_cmd):
    '''adds a new command to startup command list'''
    
    rhino_id = Rhino.RhinoApp.CurrentRhinoId
    settings = Rhino.PlugIns.PlugIn.GetPluginSettings(rhino_id, False)
    settings = settings.GetChild("Options").GetChild("General")
    commands = settings.GetString("StartupCommands").splitlines()
    
    if str_cmd and not str_cmd in commands: 
        commands.append(str_cmd)
        settings.SetString("StartupCommands", "\n".join(commands))

Example usage, tested in Rhino 8 (Windows):

AddStartupCommand(str_cmd="! _-LoadScript MyExampleScript.rvb")

_
c.

2 Likes

Flawless! Thanks so much :slight_smile:

1 Like