Forgot password?

Create an account!

Forum

« back

RhinoScript – making libraries

Messages

Please log in to write a message.

  • 2. Johannes (Oct 08, 2009 08.13):

    hi,

    if you have some functions in your scripts you want to outsource because you want to clean up your script or using functions very often in several scripts it is well to build a library.

    You are still using functions out of libraries in your scriptfile (Rhino.*(), msgbox(),...). That are functions you didn't declare in your file. So someone else wrote's and runs them that they are available for you.

    There are some ways to handle that.
    At first you have to write all that functions in a seperate *.rvb-file.
    (take a look at a library on this site to see the syntax of it)

    Then you have to run that file beofre you run your scipt where you want to use the functions out of the library.
    - You can run it just before it like: load script "lib", load script "a",....
    - You can run scripts atomaticly at the rhino startup. go to rhino options into rhinoscript and add the scriptfiles to be load on rhino start. These scripts automaticly runs at startup. so every functions in it will be avaiable at all time.
    - You can write some code at the beginning of your scipt to open a library before running the rest of your scriptfile.

    Try out the following script with the different ways to load the library.

    ' ++++++++++++ library rvb-file

    Option Explicit

    Function a(x)
            a = x + 2
    End Function

    Function b(x)
            b = x + 4
    End Function


    ' ++++++++++++ application rvb-file

    Option Explicit

    Call test()

    Sub test()
            Dim intResult
            intResult = a(5)
            Call msgbox (intResult)
    End Sub

    Once you runs the library-file the functions are availible in the scriptfile.

    Johannes

  • 1. maher (Oct 08, 2009 04.04):

    Hello,
    Congrats on the website.
    I have developed a number of scripts to do many little tasks that I use quite often. I will clean them up and comment them for posting. I am also writing a script for making ribs, could be handy for others. I will upload it here soon.

    my 3 Qs:
    How can I make libraries of/for my scripts?
    How can I link a script to a library?
    What should I keep in mind to make a library?

    Thanks for your time,
    -m

Recommend

Why are these buttons gray?