Trouble Installing VBScripts as Buttons

The script works perfectly fine when loaded and then run with “loadscript” “runscript” commands.

Yet when trying to make it a button it fails for some reason.

At start I type

!-_Runscript (
and at the end of the script text I close it with:
)
This is the script.

HarmonyDistribution(RhV4).rvb (68.7 KB)

Error:

Tried both selecting objects and then running and viceversa.

Why don’t you just add this file to the list of scripts that Rhino loads when it starts (Tools -> Options -> RhinoScript). Then on your button, just run the ‘main’ function.

Check the RhinoScript help file for more details.

Wouldnt that increase the time Rhino takes to open everytime? Considering I add 10 buttons or so…

I just cant understand why it isnt working this way…

No, not really.

Alright, will do if there is no other way, thanks for the suggestion.
I still would like to find out why copy pasting the script in the command box isnt working… It happens with many scripts I try actually.

Some scripts are designed to be loaded only once. Thus, putting these types of scripts on a button would require modifications to the script.

Loading scripts you find at start up is efficient and much easier to maintain the copying/pasting tons of text onto a toolbar button…

But the button is just a shortcut for “runscript” there is no reason to change it.

Right. But before you can RunScript, you need to LoadScript once. Thus, adding the file to the list of start up scripts is efficient.

Indeed, you load it, then you run it. You mean that the button loads and runs it every time I click it? I thought it just ran it.

It all depends what you put on a button. If copy/paste the entire script file in between a RunScript() statement on a button, then the entire script file is going to be ‘run’, which basically redefines all of the functions every time you click.

Like I said, add the script file to the list of startup up scripts (as the script was designed to be). Then make simple buttons to run the subroutines.

For example:

_-Runscript (
HarmonyDistribution
)