Grasshopper

generative modeling for Rhino

# Recursion Error in Rhinocommon VB.Net

Dear All,

I am in the process of translating some of the example exercises from the GH Primer (second edition) from the old .NET to the new VB.Net Rhinocommon.  Most of them I have managed to transition except for the recursion example.  If anyone has a chance and wouldn't mind sharing their feedback I would greatly appreciate the help.

Thank you and pleasure to join the GH community!

Tags: Rhinocommon, VB.NET

Views: 212

Attachments:

### Replies to This Discussion

the Line type in the Rhino SDK is a value type (just like Integer, Boolean etc.). Simply assigning it to another variable or function will thus already create a copy of it. There's no need to specifically construct a new one like this:

`Dim newLine As New Line(oldLine)`

You can just say

`Dim newLine As Line = oldLine`

I attached the fixed script (also added a translation to the recursion).

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

I have been practicing rewriting the def a few times and it has become quite clear on the concept of recursion. Seem quite powerfull and will be handy down the road.

A very basic question I have now is in regards to dealing with NurbsCurve methods and classes.
In the attached definition, I am attempting to create an ellipse and rotate it. However it seems that I am having some syntax issues. To rotate a line you would typically write:

"Line.Transform(Transform.Rotate(..,...,...)" to run the operation.

With a NurbsCurve (i.e. Ellipse) you would do:

"Curve.ToNurbsCurve.Rotate(R * i, New Vector3D(0, 1, 0), New Point3D(0, 0, 0))"?

Perhaps I'm just conceptually trying to also understand the big picture on how to understand the differenent classes in Rhinocommon and the members that each one holds.. If you wouldn't mind shedding some light when you get a chance I would greatly appreciate it! Hope your enjoying Seattle and Happy Halloween!

Attachments:

Ellipse is indeed an odd class to be working with. It only supports some very basic transformations. You can always rotate an ellipse though. When you call:

`C.ToNurbsCurve.Rotate(....`

two things happen:

1. The Ellipse creates a new NurbsCurve that has the same shape.
2. This new NurbsCurve is rotated.

What you don't do is store the result of these two operations.

Once you convert an Ellipse to a NurbsCurve, any changes made to that NurbsCurve will not feed back to the Ellipse.

I attached a modified version of your file with two approaches to this (both in the same script). In the first approach I convert ellipses to nurbs-curves, then rotate the curves, in the second approach I rotate the Plane of the ellipse. The outcome is the same.

--
David Rutten
david@mcneel.com
Seattle, WA
Attachments:
Fantastic, thank you david.

So in example one you set the ellipse to a nurbs curve using "ell.ToNurbsCurve().
Essentially the "ToNurbsCurve" creates a nurbs representation of the shape and enables you to use the NurbsCurve Methods (i.e. Rotate).

Starting to understand rhinocommon is now getting exciting, cheers
Hi David,

The attached ghx vb.net component I am doing the following operations:
-creating a grid of points
-creating a plane and rotating it on each point
-creating an ellipse and assigning it to each plane
-then attempting to extrude a surface using the following:

Surface.CreateExtrusion(eL(g), Vector3d.ZAxis)

It seems that there would be a few ways to go about it after looking through the RhinoCommon SDK site. You could do a curve extrusion operation, a surface extrusion operation, or a AddExtrusion to the rhino object (ellipse). When you get a moment any insight would be greatly appreciated as it appears my current approach has a bit of kinks.

Many thanks

Attachments:
Hi guys...

I've been using GH for a while and now I'm trying to get into the script world...
I get some basic concepts and kinda understand the above script, but just when I thought everythng was great between VB and me, I try to apply this script to a curve but... The red VB component of dead appears...

I tried to do it just changing the "lines" by "curves", declaring C as curve instead of as line, and I even tried using C.ToNurbsCurve.Translation and same with Rotation but... No result...

Can I get a little help plz...

Thanks!!