Hi CMRHM,

the Main() sub is a bit of an antiquated concept. Long ago, Visual
Basic application needed a Main() sub which is where the program
started. Today, if you write a VB application you can choose to either
start with a default window, or to designate a custom subroutine as
the runtime start point. A VB script inside Grasshopper on the other
hand is not a standalone application and as such does not need a Main
() like subroutine. Here's what happens:

1) you type in some custom code into the VB editor
2) Grasshopper inserts that code into a code template. You can see the
entire code if you export the source code through the VB component
menu (it's quite different from the stripped version you see inside
the VB editor).
3) this code template is compiled using the default DotNET framework
compiler and the result (a dll) is stored in memory.
4) when the component that contains your code is required to solve
itself, it will instantiate a new instance of the
Grasshopper_Custom_Script class and call the RunScript() sub directly.


--
David Rutten
[email protected]
Robert McNeel & Associates







On Mar 16, 6:05 am, CMRHM <[email protected]> wrote:
> David:
>
> I began to check the VB.NET sample code from book also online. I here
> would like to ask the first question:
>
> When I double click on the VB scriptable component, the code editor is
> being brought up.  I see there is a template:
> Class Grasshopper_Custom_Script
>
>   Sub RunScript(ByVal x As Object, ByVal y As Object)
>     ''' <your code>
>
>     ''' </your code>
>   End Sub
> End Class
>
> This is a class, obvious. But where is the Main? Why there is no Main
> here? If you have a link to explain this, please let me know too.
>
> Thanks.
>
> n Mar 13, 7:51 am, CMRHM <[email protected]> wrote:
>
> > Thank you David. I will post back some more questions later.
>
> > On Mar 13, 4:59 am, David Rutten <[email protected]> wrote:
>
> > > > Here I have a question: in Rhino 4.0 SDK help file, I can find the
> > > > definition of the namespace and class, but each class don't have any
> > > > explanation. I guess we can understand its function by just looking at
> > > > their naming, right?
>
> > > Ideally. This is a practise called 'writing self documenting code'.
> > > You should be able to tell from the names and layout of classes and
> > > namespaces what they're for and how they're used, but it's not always
> > > the case. Many functions have little one-line descriptions which will
> > > show up in tooltips as you type, but class definitions do not.
> > > It took me a while to get used to the way the Rhino SDK operates.
>
> > > > There are alot of classes I should say.  Will you
> > > > be able to recommend a good way for me to learn coding?
>
> > > Try, try, try
> > >         - after V. I. Lenin-
>
> > > Look at examples, ask specific questions and keep trying.
>
> > > --
> > > David Rutten
> > > [email protected]
> > > Robert McNeel & Associates

Reply via email to