compas-dev / compas

Core packages of the COMPAS framework.
https://compas.dev/compas/
MIT License
311 stars 106 forks source link

Error when de-serializing a Cylinder RhinoNurbsSurface #1094

Closed chenkasirer closed 1 year ago

chenkasirer commented 1 year ago

Getting an attribute error when de-serializing a RhinoNurbsSurface with a cylinder shape. The error is a result of the following method returning None

# compas_rhino.geometry.surface.nurbs.py - line 64
rhino_surface = Rhino.Geometry.NurbsSurface.Create(3, True, u_degree + 1, v_degree + 1, len(points[0]), len(points))

To Reproduce

  1. Create a Rhino.Geometry.Cylinder
  2. Convert cylinder to a NURBS surface
  3. Serialize and de-serialize using compas_rhino.geometry.RhinoNurbsSurface
from Rhino.Geometry import Circle, Cylinder, Plane, Vector3d, Point3d

from compas_rhino.geometry import RhinoNurbsSurface

r = 1.4
p = Point3d(0, 0, 0)
x_axis = Vector3d(1, 0, 0)
yz_plane = Plane(p, x_axis)
yz_circle = Circle(yz_plane, r)

cx = Cylinder(yz_circle, 4 * r)
surface = cx.ToNurbsSurface()
data = RhinoNurbsSurface.from_rhino(surface).data
RhinoNurbsSurface.from_data(data)

The following error occurs:

Message: 'NoneType' object has no attribute 'KnotsU'

Traceback:
  line 85, in rhino_surface_from_parameters, "C:\Users\usename\AppData\Roaming\McNeel\Rhinoceros\7.0\scripts\compas_rhino\geometry\surfaces\nurbs.py"
  line 321, in from_parameters, "C:\Users\username\AppData\Roaming\McNeel\Rhinoceros\7.0\scripts\compas_rhino\geometry\surfaces\nurbs.py"
  line 201, in from_data, "C:\Users\username\AppData\Roaming\McNeel\Rhinoceros\7.0\scripts\compas_rhino\geometry\surfaces\nurbs.py"
  line 15, in <module>, "C:\Users\username\Downloads\brep\cylinder.py"

Expected behavior De-serialization should succeed.

Screenshots image

chenkasirer commented 1 year ago

Solved in https://github.com/compas-dev/compas/pull/1101