There are different error messages with Nurbs surface in different cases
import rhinoinside
import ghhops_server as hs
import math
rhinoinside.load()
import System
import Rhino
hops = hs.Hops(app=rhinoinside)
@hops.component(
"/wave",
name="wave",
description="create a wave",
inputs=[
hs.HopsInteger("X", "x", "number of points in X axis"),
hs.HopsInteger("Y", "y", "number of points in Y axis"),
hs.HopsNumber("Height", "h", "height of waves"),
hs.HopsNumber("amplitude", "a", "amplitude of the waves")
],
outputs=[
hs.HopsPoint("Points", "P", "List of points"),
hs.HopsSurface("Surface", "S", "A surface made up of a list of points")
]
)
def wave(x, y, height, amplitude):
points = System.Collections.Generic.List[Rhino.Geometry.Point3d]()
pts = []
for i in range(x):
for j in range(y):
pt = Rhino.Geometry.Point3d(float(i), float(j), math.sin(i * height) * math.sin(j * height) * amplitude)
points.Add(pt)
pts.append(pt)
surface = Rhino.Geometry.NurbsSurface.CreateFromPoints(pts, int(x), int(y), int(x), int(y))
return pts, surface
if __name__ == "__main__":
hops.start(debug=True)
points = System.Collections.Generic.List[Rhino.Geometry.Point3d]()
surface = Rhino.Geometry.NurbsSurface.CreateFromPoints(points, int(x), int(y), int(x), int(y))
return points, surface
give this error:
1. Solution exception:Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Rhino.Geometry.Point3d' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path '', line 1, position 1.
pts = []
surface = Rhino.Geometry.NurbsSurface.CreateFromPoints(points, int(x), int(y), int(x), int(y))
return pts, surface
give this error:
1. Solution exception:Unable to read CommonObject from base64 encoded string
pts = []
surface = Rhino.Geometry.NurbsSurface.CreateFromPoints(pts, int(x), int(y), int(x), int(y))
return pts, surface
give this error:
1. Exception occured in handler:
No method matches given arguments for CreateFromPoints: (<class 'list'>, <class 'int'>, <class 'int'>, <class 'int'>, <class 'int'>)
surface = Rhino.Geometry.NurbsSurface.CreateFromPoints(pts, int(x), int(y), int(x), int(y))