mcneel / compute.rhino3d

REST geometry server based on RhinoCommon and headless Rhino
Other
301 stars 189 forks source link

LIST parameter not supported #316

Closed TugdualSarazin closed 3 years ago

TugdualSarazin commented 3 years ago

Except if I didn't understand how to use it, otherwise the LIST access parameter doesn't look like to be supported.

Grasshopper script: hopes_line_error

Flask server endpoint:

@hops.component(
    "/lines_3",
    name="Lines",
    inputs=[
        hs.HopsLine("Line", "L", access=hs.HopsParamAccess.LIST),
        hs.HopsNumber("i", "i"),
    ],
    outputs=[
        hs.HopsPoint("P", "P")
    ]
)
def lines(line:Polyline, i):
    print(line, i)
    return Point3d(0, 1, 0)

Json returned by the endpoint:

{
  "Description": null,
  "Inputs": [
    {"Name": "Line", "Nickname": "L", "Description": null, "ParamType": "Line", "ResultType": "Rhino.Geometry.Line", "AtLeast": 1}, 
    {"Name": "i", "Nickname": "i", "Description": null, "ParamType": "Number", "ResultType": "System.Double", "AtLeast": 1, "AtMost": 1}],
  "Outputs": [
    {"Name": "P", "Nickname": "P", "Description": "Point on curve at t", "ParamType": "Point", "ResultType": "Rhino.Geometry.Point3d", "AtLeast": 1, "AtMost": 1}
  ]
}
mcneel-build commented 3 years ago

Linked with COMPUTE-215

sbaer commented 3 years ago

Also reported at https://discourse.mcneel.com/t/hops-from-cpython-and-lists/120959

sbaer commented 3 years ago

Almost have a fix for this. If you specify list access, then the python function needs to be structured to work with a list. For the above example, the function could look something like

@hops.component(
    "/lines",
    name="Lines",
    inputs=[
        hs.HopsLine("Line", "L", access=hs.HopsParamAccess.LIST),
        hs.HopsNumber("i", "i"),
    ],
    outputs=[
        hs.HopsPoint("P", "P")
    ]
)
def lines(lines: rhino3dm.Line, i):
    points = [line.PointAt(i) for line in lines]
    return points
sbaer commented 3 years ago

ghhops-server 1.2.0 now on pypi : should fix this issue