Grasshopper

algorithmic modeling for Rhino

 

Dear All,

 

For the File I/O tutorial from the GH Primer Second Addition (VB.net) I have a simple question.

When trying to loop through the text lines from the file and convert them to a double I am running into the issue with the .ToCharArray below.

I'm sure the issue is that this is a method from the previous .Net SDK.

Any insight on how split the characters by the "," and put it into the parts array?

 

 

  'Loop through lines
    For Each line As String In lines


      'Tokenize line into array of strings separated by ","
      Dim parts As String() = line.Split(",".ToCharArray() )    <------Error

 

      'Make sure that each line has exactly 3 values
      'If UBound(parts) <> 2 Then Continue For

 

      'Convert each coordinate from string to double
      Dim x As Double = Convert.ToDouble(parts(0))
      Dim y As Double = Convert.ToDouble(parts(1))
      Dim z As Double = Convert.ToDouble(parts(2))

 

      pts.Add(New Point3d(x, y, z))

 

    Next

 

 

As always many thanks

Views: 1030

Replies to This Discussion

Hi Madu,

ToCharArray() is a method on the .NET String class and has nothing to do with either the old or the new Rhino SDK. I'm not quite sure why it isn't working, but you can try defining the character array like this:

Dim parts As String() = line.Split(New Char() {","c})

--
David Rutten
david@mcneel.com
Seattle, WA
Hi David,

Thanks for the reply and understood about the .net string class.
I have fixed the code and the points output from the text file number sequences.

Just a side minor thing, in the vb.net script component this (new Char() {","}) shows a syntax error. However in Visual Studio it seems to be fine.

Many thanks


Attachments:
Yeah the library we use to format and highlight the VB and C# code isn't very good. I'm not sure yet what we're going to do about this.

--
David Rutten
david@mcneel.com
Seattle, WA
Got it.
None the less its exciting to follow the blog, community, and application day by day/ version by version to watch what its becoming. Out of curiosity why write GH in C# and not VB.Net? or C++ being that rhino uses it? You foresee .Net sticking around with GH/Rhino? Sorry to many questions, too much coffee and you tube vb tutorials.. time to sleep now...
Cheers
Grasshopper is mostly written in VB.NET which was the only high-level language I knew when I started the project. If I had to start today I'd probably pick C#, not because I like the language better but because it would be easier to collaborate with other people inside mcneel.

Grasshopper is 90% an interface application and only 10% geometry/io code. Nothing beats .NET when it comes to interface development in my opinion.

I foresee .NET sticking around everywhere, for a very long time to come. Microsoft is very active in pushing C# as a replacement for C++ and they're being successful. Especially now that Mono is available for Linux, Mac and many hand-held platforms. I like the languages that come with .NET a lot, I think the core framework is a work of art.

--
David Rutten
david@mcneel.com
Seattle, WA
awesome very well put.
Cheers
Hi David,

I've been thinking alot about your last reply where you mentioned:

"Grasshopper is 90% an inerface application and only 10% geometry/ io code"

In theory GH running as an application could (with a bit of work) be customized to run with a program like Catia or Digital Project. Being that they both utilize visual basic language. It serves as an interesting discussion because the two platforms both make up for each others pit falls. Catia/DP - Data managment capability but ridgid design capabilites and GH - Associative modeling Parametric Capabilities but not so good assembly managment modeling, bim blah. Could also be interesting to think about. When you a coffee break and free minute I'd be interested to hear your thoughts.

Cheers

P.S. not to say to ditch rhino, but potential of expanding the platforms and communication between them. Rhino, GH, DP, Catia...ect
Hi Madu,

I went through an SDK switch a few months ago when I recoded Grasshopper to work on RhinoCommon. So it's definitely possible to port Grasshopper to some other platform with only about 2 months of work. Of course even though RhinoCommon has a very different layout from Rhino_DotNET, the functional overlap is almost perfect which would not be the case if I had to port to a different application.

McNeel has a number of plugins that run on Rhino and AutoCAD, but those are all sold products. The only way we can justify Grasshopper development costs is because we are selling more Rhino (we hope) because of it. How could we justify a Grasshopper-for-Catia port?

--
David Rutten
david@mcneel.com
Seattle, WA
Hi David,

Thanks for the reply.
Good point and interesting.
Well as for the justification side you probably couldn’t from McNeel ends at this stage.
That would leave only the other gents over at Dessault but more likely GT to invest in a recoding period or McNeel finding potential in making a type of Port of “sold product”.
Which isn’t something so farfetched.
As lots of architectural firms are utilizing rhino in conjunction with Revit or DP as part of their office workflow and as an option to have this extra communication and controls would be quite powerful, something surely would be worth forking up for.
However overlooking the political end GH is only at the beginning of what I’m sure will be an exciting journey for the years to come so could be a thought to keep on the backburner…

David,

 

your comment about GH being 90% interface and 10% geometry raises a question in my mind. I am wondering if Grasshopper's geometry calculation functions come from within rhino or work completely independently. The reason I ask is that I think it would be very appealing to be able to develop geometry producing definitions withing GH and Rhino but be able to spin off little self contained apps that could take in data, do calcs, and spit geometry files out the other side!

 

Matt

It's mostly Rhino. Curves and Surfaces, Breps and Meshes, Vectors and Planes, without Rhino none of this would work.

 

The only geometric stuff I do myself is Spatial-Trees, Delaunay, Voronoi and Metaballs, which are then translated into Rhino data types when they're finished.

 

--

David Rutten

david@mcneel.com

Leusden, NL

Yeah. That's what I initially thought. But when you mentioned the geometry manipulation done by GH I was curious if I was wrong about that!

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