Grasshopper

algorithmic modeling for Rhino

how to create a IEnumerable collection in python while loft using RhinoCommon?

I want to loft a surf from 2 curves in python and I found that Rhino.Geometry.Brep.CreateFromLoft()method seems work for me. this is the code:

import rhinoscriptsyntax as rs

# the Rhino Common SDK access
import Rhino
import Rhino.Geometry as rg

# scriptcontext
import scriptcontext as sc

from System.Collections.Generic import IEnumerable
#######################################

c = rs.coercecurve(crvs)
print(c)
print type(c)

# define Corner None style
CurveOffsetNoneStyle = 0
loftTypeNormal = 0

working_plane = rg.Plane.WorldXY
d = 2000
tol = 0.0001

c.PointAtStart
c.PointAtEnd

# create outside and inside offset curves
c_l = c.Offset(working_plane, d, tol, CurveOffsetNoneStyle)
c_r = c.Offset(working_plane, -d, tol, CurveOffsetNoneStyle)
base_crvs = [c_l, c_r]

a = rg.Brep.CreateFromLoft(curves=base_crvs, start=None, end=None, loftType=loftTypeNormal, closed=True)
# what the fuck IEnumerable?????

when running in grasshopper I got an error:


Runtime error (ArgumentTypeException): expected IEnumerable[Curve], got list
Traceback:
line 33, in script

so How to create a IEnumerable list for CreateFromLoft()to use in python?? looks like it's a c# collection I somehow I tried to search usage from msdn but seems too greek for me. many thanks!!!!

Views: 2585

Attachments:

Replies to This Discussion

I think c_l = c.Offset returns a collection of curves, not a single curve. So your base_crvs = [c_l, c_r] is actually a collection of two collections of curves. Offset expects a collection containing curves.

thanks for your reply, I've solve it with your help!!!!!

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