Grasshopper

algorithmic modeling for Rhino

Hi, sorry for posting this again, but I'm really freaked out by the IEnumerable thing.

I'm not a die hard programmer,  I learned all my knowledge about VB from rhino. In the old version Grasshopper I basically managed to deal with most geometries by the VB components. But now, in the rhino 5 common, a lot of method need the implementation of IEnumerable, like brep.joinbreps and curve.joincurves, and so on.
I checked the constructor of RhinoList, it shows rhinolist can implement IEnumerable.
Public Sub New ( _        collection As IEnumerable(Of T) _
)
But when I use list or array for syntax that requires IEnumerable (of Curve), IEnumerable(of Mesh) and so on, it just results in fault: '1-dimensional array of rhino.geometry cannot be converted to 'rhino.geometry'...


Help! I'm suffering this for two days....

'

Views: 1458

Replies to This Discussion

Check out the fourth post below yours (http://www.grasshopper3d.com/forum/topics/rhinocommon-how-to-conver...).

But from the error message it seems you are feeding a list of items but it's asking for a single one.
It was my post, too. And I tried David's suggestion it still doesn't work.

Public Shared Function JoinCurves ( _ inputCurves As IEnumerable(Of Curve) _) As Curve()

According to the syntax, it asks for a IEnumerable(of Objects), since I've told just to use list or array, I give it a list, and then the error code is like this. Maybe it really wants single object, but it is a "join" command, that's weird...
I think it's more apropiate then to reply to the previous thread instead of starting a new one.

Maybe the problem is not the input curves but that the function is returning an array of curves and you are feeding it into a single one?
Try the following, see if it works:
- Draw a number of touching (but separate) line segments.
- Reference them to a component
- Add a vb.net component with the following code:
a = curve.JoinCurves(x)
-Connect the referenced curves to the x input and change the input to 'list' and 'curve'.

Is the A output returning a polyline?
Vicente, I started this new one because my previous one did not focus on IEnumerable, I was asking about how to turn array into objects, then I found IEnumerable is more confusing for me. But anyway, you are right.

And your suggestion is a nice solution for debugging. But, the result, is null. I used my whole afternoon to research about IEnumerble. The class examples on MSDN is just too difficult for me, I just get to know it's a very efficient interface.

As for the join problem, I finally gave up. And I used a dumb one by one solution:

c as curve: c.join(l1,tolerance,boolean):c.join(l2,tolearnce, boolean)....
Oh, I suddenly find I'm so silly! I wasted two days on thinking about this. Today I opened one of my old VB.script component created by old GH, I find it's so efficient on the join problems. Maybe the IEnumerable thing s are better, but I can just use the legacy VB for new, since I have a very close deadline...

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service