Geometry encoding for Compute

Could you show how you create this input data? I’ve got an error when I’m trying to pass Points using this method:

let x = new this._rhino.Point([-5, 5, 0]);
let dataD = {
      definition: "",
      inputs: { X: x.encode() },

    let jsonData = JSON.stringify(dataD);

    const request = {
      method: "POST",
      body: jsonData,
      headers: { "Content-Type": "application/json" },

When I create points as string like that:
'{"X":' + 80 + ',"Y":' + 200 + ',"Z":' + 0 + "}",
everything works fine…

Yes, that’s how you should be doing it.

Check out this sample:

Could you tell me how I should create more sophisticated objects like (for example) curve, polyline, polygon, etc. Is there any documentation about that?

Most of what we have online can be found here:

Yes, this repo help me a lot, but I didn’t find info how to sens for example curve to rhino.compute as RH_IN parametr using this convention like in example with Pointa.

Curves derive from the GeometryBase class and thus needs to be encoded to be sent to compute. Points and other structs are sent a bit differently. We’re still trying to work this out so it is less confusing. For a curve you could do:

const curvePoints = new rhino.Point3dList()
curvePoints.add( 0, 0, 0 )
curvePoints.add( 5, 5, 0)
curvePoints.add( 10, -5, 0 )
curvePoints.add( 15, 5, 0 )
curvePoints.add( 20, 0, 0 )

const nurbsCurve = rhino.NurbsCurve.create( false, 3, curvePoints )

//this is what you should send to compute
const curveDataToCompute = JSON.stringify( nurbsCurve.encode() )
console.log( curveDataToCompute )

Thanks for advice! But… I think I’m close, but still Rhino Compute is throwing an error

Data which I’m sending to Rhino:

Can you provide example code and definition to test? Also, how are you running compute?

This is a more complete example that is working for me:

Unfortunately I cannot show the definition file… but it turns out that your solution works! The problem is when I want to use the same code in a solution based on compute.appserver. So I will look for discrepancies in the coming days. Additionally, I had a problem on the Rhino Compute side, where I got an error:

Ok. It would have been good to know how you were calling compute. For appserver it would be similar:

Note: the is in /src/files