Grasshopper

algorithmic modeling for Rhino

I created a list of points, then try to get total numbers of the points. But can't get it.  Here is the testing code:

     Dim myPointsList As New List(Of On3dPoint)
      myPointsList.add(my_pt)
      print("number of pints in the list is ", myPointsList.Count())

This code return nothing except "number of pints in the list is".

The vb.net editor embedded inside GH is not very useful. Like this Count() function, it looks this isn't a function to return a number.  Where should I check if I want to find a function to return an number?

RhinoDotNet SDK? I checked other posts in this forum. It sounds this is a common q.  Although Rajja says the internal script editor is fine if one does alot of small testing like print(), I can't agree with her. At least I want to see a list of all functions and classes available to the beginner coder/architect like me. Sth like monkey should be very good.

Thanks for the help.

Views: 444

Replies to This Discussion

Hi cmrhm

first to your problem
__out.Add("number of points " + x.Count().ToString)

i agree with Raija the script editor is fine for small scripts and testing
but for huge complex scripts it is better to use VS
for help you have to search threw the SDK it is the only way

maybe you should also look for some programming books for the basics

best to]
Hi, to]:

Thanks for the help!

The code you suggest works but I want to know where I can find this Count() could call the function ToString. I just want to have a library explanation for the classes/functions we use in GH.

The intelligense didn't say anything about this. Pls see the attached.

__out.Add("number of points " + x.Count().ToString)
Attachments:
Hi cmrhm,

List(Of On3dPoint).Count is a property returning 1 in this case (it works, but generally property calls do not need parentheses). The result is not printed at the moment because there's no position to put the value into. This new formatting string should work:
Print("number of pints in the list is {0}", myPointsList.Count)
The {0} is the indicator that explains where this value should go into.
You can see examples of the generic List class here: http://msdn.microsoft.com/en-us/library/6sh2ey19%28VS.80%29.aspx . I hope this is somehow helpful.

About the list of all function and classes, that's a bit harder... there are extremely many of them, spread around the whole .Net Framework Class Library. You can see the start page of it here: http://msdn.microsoft.com/en-us/library/ms229335%28VS.80%29.aspx

Maybe you already know the next tip, but if you do not you will like it a lot: try pushing "ctrl + shift + space" inside a method, and it will show the contextual help.
I'm attaching two small examples of how it looks:



See this article about formatting: http://msdn.microsoft.com/en-us/library/26etazsy%28VS.80%29.aspx . The most important part is: put {0} where you want the first value, {1} for the second, {2}, etc...

Last question, about ToString: every single object (anything you can put into a variable) has a ToString() method in .Net.


I still agree that the editor could be improved - hopefully earlier rather than later - but it is still quite useful.

- Giulio
_________________
giulio@mcneel.com
McNeel Europe, Barcelona
Hi, Guilio:

It is very nice of you to give me such detailed explanation! I will have more Qs to follow within next several hours.

"About the list of all function and classes, that's a bit harder... there are extremely many of them, spread around the whole .Net Framework Class Library. You can see the start page of it here: http://msdn.microsoft.com/en-us/library/ms229335%28VS.80%29.aspx"

They didnt' list classes/functions regarding Rhino. Is there anything like the attached for VB.NET coder for GH?
Attachments:
Its not Microsoft's job to handle Rhino's documentation, so you won't find anything in there about Rhino's classes. There are two options here. The first is to download the Rhino dotNET SDK, which has a documentation (chm) file that has all the classes and methods that are used for Rhino. This is something you should really do. The second is to begin using Visual Studio Express for your scripts. This will be a little bit more complicated of a workflow, since you won't be using the editor in Rhino, but you will have access to the both the dotNET framework documentation and the Rhino dotNET documentation right there in VS and the editor is also ten times easier to work with.
Damien:

Thanks for clarifying this issue. I am testing SDK now. BTW, do you have a work flow to set up VS express for Rhino? Do I need to put some DLL into express folder to let them recognize classes/methods from Rhino?
The documentation of RhinoCommon, the SDK used in Grasshopper 0.7 and above, is here (the same, online)

The Rhino .Net SDK help file (for the older SDK) is here (samples).

Hope this is helpful,
- Giulio
__________________
giulio@mcneel.com
McNeel Europe, Barcelona
This is great, Giulio. Thanks!

I have installed SDK following "readme.txt".

Also, I followed the following link Rajja provided to try VS2010 express for Rhino Plugin. I actually just want to debug my VB.NET code for GH as you know.
http://wiki.mcneel.com/developer/dotnetexpresseditions

the attached shows I now using .NET SDK to check the classes/methods I am interested in
RhUtil::RhinoPointInPlanarClosedCurve (IOn3dPoint^, IOnCurve^), BTW, what is this ^?

Hi cmrhm,

the ^ symbol is a handle construct, something that will be less important in VB.Net. In this case, it is the equivalent in C++/CLI to ByRef in VB.Net or the ref keyword in C#. For more info, please see the "Handles" paragraph in the link above.

- Giulio
_____________
giulio@mcneel.com
McNeel Europe, Barcelona
I see, thx, Giulio.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service