Grasshopper

algorithmic modeling for Rhino

hi everyone

i'm confused with a problem in rhino4

for example:

 

Dim Brp As Brep()

brp = Brep.CreateFromLoft(Pl_s, point3d.Unset, point3d.Unset, LoftType.Normal, False)

 

in the code above , Pl_s is a list of NurbsCurve(which was convert from Polyline with this method  .toNurbsCurve)

 

in rhino5 it works well.

but in rhino4, grasshopper will say, you cannot convert type  "System.Collections.Generic.List'1[Rhino.Geometry.NurbsCurve]"

to type""System.Collections.Generic.IEnumerable'1[Rhino.Geometry.Curve]"

 

how can i solve this problem in rhino4?

Views: 974

Replies to This Discussion

I think the problem might be that in Rhino5 you get to use the new .NET 4.0 features which are smart enough to realise a List(Of NurbsCurve) is a List(Of Curve). But I'm not sure about that.

 

Anyway, to create a List(Of Curve) from a List(Of NurbsCurve), you'll need to do something like:

 

Dim curveList As New List(Of Curve)(nurbsCurveList.Count)

For Each nurbsCurve in nurbsCurveList

  curveList.Add(nurbsCurve)

Next

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks a lot!

you are so kind.

I will try it .:P

David,

I have a similar problem with a list of Rhino objects (Arc, Line, NurbsCurve) that I am trying to Join using Curve.Join() method. That method takes only a List of Curve objects and mine are Arcs, NurbsCurves etc. Is there a way in Python to convert those to generic Curves? 

Thank you,

Hi Konrad,

All these classes: ArcCurve, CurveProxy, LineCurve, NurbsCurve, PolyCurve, PolylineCurve are derived from Curve class, meaning each one of those can be used to access Curve methods (JoinCurves in this case) or properties.

So for example you can convert an arc into ArcCurve: Rhino.Geometry.ArcCurve(arc);

Line into LineCurve: Rhino.Geometry.LineCurve(line)...

Still, the easiest way would be to convert all your curve like types into NurbsCurve (example: arc.ToNurbsCurve(), line.ToNurbsCurve() ...) and then feed them to Curve.JoinCurves method.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service