1212from compas_rhino .conversions import vector_to_compas
1313from compas_rhino .conversions import plane_to_compas_frame
1414from compas_rhino .conversions import box_to_compas
15+ from compas_rhino .conversions import RhinoCurve
1516
1617import Rhino .Geometry
1718
@@ -226,11 +227,12 @@ def from_points(cls, points, u_degree=3, v_degree=3):
226227 -------
227228 :class:`compas.geometry.NurbsSurface`
228229 """
230+ points = list (zip (* points ))
229231 u_count = len (points [0 ])
230232 v_count = len (points )
231233 points [:] = [point_to_rhino (point ) for row in points for point in row ]
232234 surface = cls ()
233- surface .rhino_surface = Rhino .Geometry .NurbsSurface .CreateFromPoints (points , u_count , v_count , u_degree , v_degree )
235+ surface .rhino_surface = Rhino .Geometry .NurbsSurface .CreateFromPoints (points , v_count , u_count , u_degree , v_degree )
234236 return surface
235237
236238 @classmethod
@@ -281,9 +283,9 @@ def to_step(self, filepath, schema="AP203"):
281283 def points (self ):
282284 if self .rhino_surface :
283285 points = []
284- for i in range (self .rhino_surface .Points .CountV ):
286+ for i in range (self .rhino_surface .Points .CountU ):
285287 row = []
286- for j in range (self .rhino_surface .Points .CountU ):
288+ for j in range (self .rhino_surface .Points .CountV ):
287289 row .append (point_to_compas (self .rhino_surface .Points .GetControlPoint (i , j ).Location ))
288290 points .append (row )
289291 return points
@@ -292,9 +294,9 @@ def points(self):
292294 def weights (self ):
293295 if self .rhino_surface :
294296 weights = []
295- for i in range (self .rhino_surface .Points .CountV ):
297+ for i in range (self .rhino_surface .Points .CountU ):
296298 row = []
297- for j in range (self .rhino_surface .Points .CountU ):
299+ for j in range (self .rhino_surface .Points .CountV ):
298300 row .append (self .rhino_surface .Points .GetWeight (i , j ))
299301 weights .append (row )
300302 return weights
@@ -374,7 +376,8 @@ def u_isocurve(self, u):
374376 -------
375377 :class:`compas.geometry.NurbsCurve`
376378 """
377- raise NotImplementedError
379+ curve = self .rhino_surface .IsoCurve (1 , u )
380+ return RhinoCurve .from_geometry (curve ).to_compas ()
378381
379382 def v_isocurve (self , v ):
380383 """Compute the isoparametric curve at parameter v.
@@ -387,7 +390,8 @@ def v_isocurve(self, v):
387390 -------
388391 :class:`compas.geometry.NurbsCurve`
389392 """
390- raise NotImplementedError
393+ curve = self .rhino_surface .IsoCurve (0 , v )
394+ return RhinoCurve .from_geometry (curve ).to_compas ()
391395
392396 def boundary (self ):
393397 """Compute the boundary curves of the surface.
@@ -440,8 +444,9 @@ def frame_at(self, u, v):
440444 -------
441445 :class:`compas.geometry.Frame`
442446 """
443- plane = self .rhino_surface .FrameAt (u , v )
444- return plane_to_compas_frame (plane )
447+ result , plane = self .rhino_surface .FrameAt (u , v )
448+ if result :
449+ return plane_to_compas_frame (plane )
445450
446451 def closest_point (self , point , return_parameters = False ):
447452 """Compute the closest point on the curve to a given point.
0 commit comments