Calling rhinoscript script files with arguments?


#1

Dear community,

We have created a quite extensive rhinoscript, which is called many times with different parameters. We would like to call this script automatically with the different parameters parsed from a config file.

For now, this config file is read after a Rhino.OpenFileName opens a dialog box. Now, I would like to be able to generate several config files automatically and call my rhinoscript with each time the new config file as an argument. Something like

_-LoadScript MyRvbScriptFileName MyConfigFileName

Is this possible and if yes, how would this work?

Any leads would be highly appreciated.

Kind regards,

Filip


(Dale Fugier) #2

LoadScript loads script files.

RunScript runs scripts already loaded into memory (by LoadScript).

If you want to pass an argument to a subroutine, load it and then run it.

http://4.rhino3d.com/5/rhinoscript/introduction/loading_scripts.htm

http://4.rhino3d.com/5/rhinoscript/introduction/running_scripts.htm

Does this help?


#3

Dear Dale,

Many thanks for your suggestions and support so far. I already helped my a lot!
Two additional questions however that I still didn’t figure out:

1. After loading the script, the subroutine I would like to access again is not in the list of subroutines in memory. Only one subroutine of my rvb file seems to be available, while there were 5 subroutines… The other 4 are not visible as explained on http://4.rhino3d.com/5/rhinoscript/introduction/running_scripts.htm but should still be available. However, I was not yet able to access these:

there is a subroutine froMain that takes one argument. However, when trying to call it from C# like:

Rhino.RhinoApp.RunScript("-RunScript froMain 1 “, true)
or
Rhino.RhinoApp.RunScript(”
-RunScript froMain “1” ", true)

Ik keep getting the error message "Wrong number of arguments or invalid property assignment: 'froMain’
While I am sure that froMain is defined and takes 1 argument… So I guess I still missed something. Could you point out what?

2. Objects defined in rhinoscript are still in memory after a run of my script (I can see this when clicking the debug button of the monkey editor when running my script for a second time, before the initialization subroutine is called.
Is there a way to access these variables and objects in memory still in memory in Rhinoscript from C#?

Many thanks in advance,

Filip


(Dale Fugier) #4

The RunScript dialog only displays “top-level” procedures - subroutines that do not require arguments. Other procedures are not visible because they require arguments to execute.

Your script sound be surrounded with parentheses:

_-RunScript (froMain "1")

Is there a way to access these variables
[/quote]

Sorry no.

Why do you need access to these variables? If you have a C# plug-in, why are you running scripts?


#5

The reason is legacy. In our company, we wrote quite an extensive script (about 4000 lines of Rhinoscript code) to construct a certain parametrized model. Now, I added a panel that can call this script from C#. Maybe in the long run, the script will be translated completely to C#, but for now I don’t have the time to do that…