Search code examples
c#lockingrhinorhino3d

How can I lock my rvb script file (Rhino Script)?


How Can I lock my rvb script file, I want to open the script without seeing the content.

Option Explicit


Call Main()

Sub Main()

    Rhino.Print("Test")

End Sub


Solution

  • If you would like to run a .rvb script without opening the script editor, there are several ways to do this.

    Here are some options. All options assume you have saved your script to a local .rvb file.

    Option 1:

    1. Open the .rvb file by double-clicking, this will launch Rhino and run the containing script.

    Option 2:

    1. With Rhino open, run the 'LoadScript' Command.
    2. Click the 'Add...' button and navigate to your .rvb file in the file browser and click 'open' once the file is selected. This will add the script to the 'Select a script file to load:' box. enter image description here
    3. Select the newly added script, and click 'Load'. This will run your script in the current rhino document.

    Option 3:

    1. Remove the Call Main() line from the script
    2. Make your Sub Method public public Sub Main()
    3. Save the script as a Main.rvb (I believe the file name and sub method name should match)
    4. Tell Rhino to load your script at startup by using the 'options' command and then navigating to 'RhinoScript>Startup>Script files' and adding the file path to the .rvb file. enter image description here
    5. Add an Alias to run the script as an easy command. This can be done with Options>Aliases>New. The 'Alias' is the command name you would like to have run the script and the 'Command macro' would be _-runscript Main.
    6. Type your Alias in the command line to run your script anytime without needing to re-load, view, or change the script. enter image description here

    Locking If you mean 'locking' in a more traditional sense of locking a file. I am not familiar with any Rhino options, but in Windows you can right-click the file, open 'Properties', and in the 'General' tab there is a 'Attributes: Read-Only' option, which would lock the file and prevent modification but will not prevent the scrip from being able to run in rhino.