Grasshopper

algorithmic modeling for Rhino

(RhinoCommon) How to convert "one dimensional array of curve" to curve?

I've got a problem. The error of my VB component shows "Value of type '1-dimensional array of Rhino.Geometry.Curve' cannot be converted to 'Rhino.Geometry.Curve'."

My code is here: (I tried to get all the edge curves of a list of planar breps, and then join them as closed curves )


  Private Sub RunScript(ByVal x As List(Of Brep), ByRef A As Object) 

    Dim cl As New List(Of Curve)
    For i As int16=0 To x.Count() - 1
      Dim br As Brep :   br = x(i) 

      Dim enve As curve
      Dim ev As IEnumerable()

      For j As int16=0 To br.Edges.Count() - 1

        Dim l As curve
        l = br.Edges.Item(j)

        'enve = curve.JoinCurves(l)
        ReDim ev(j):ev(j) = l

      Next

      enve = curve.JoinCurves(ev)
      cl.Add(enve)

    Next
    A = cl


  End Sub 


In Rhinocommon file, I found the "joincurve" method is like this:
Public Shared Function JoinCurves ( _        inputCurves As IEnumerable(Of Curve) _) As Curve()

What is IEnumerable? How to convert it to curve? Help me!

Views: 1985

Replies to This Discussion

Hi Jinge,

IEnumerable(Of T) is an interface that defines the most basic type of collection possible. The only thing you can do with an IEnumerable is For Each you way across it. Practically all array, list and collection classes in DotNET implement IEnumerable, so if a function wants an IEnumerable(Of T), you can supply a List(Of T), an array of T(), several types of Collection(Of T)s etc. etc.

All you need to do is:

Dim edges As New List(Of Curve)
For i As Int32 = 0 To x.Edges.Count - 1
   edges.Add(x.Edges(i))
Next
A = Curve.JoinCurves(edges)


--
David Rutten
david@mcneel.com
Poprad, Slovakia
David, Sorry for the wrong place to post and thanks for the moving.

But I believe I tried to use list, neither list nor array did work for this method. I can't find my previous file now. But I'm working on a file using " brep.joinbreps()". I just tried both list and array, which don't work. I end up to use BRP1(as brep).join(BRP2):BRP1(as brep).join(BRP2):BRP1(as brep).join(BRP3).......which is very complicated.

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