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 )
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:
Your responses have been very helpful! Thanks.
Could you kindly advise on how to send an entire Rhino document to the evaluate definition?
In the image below, I hope to send a rhino document to the “RH_IN:rhinoFile” node.
The samples on Github first parses through the objects, and then sends extracted data to definition. I prefer to control this logic in Grasshopper instead.
My current setback is that the “RH_IN:rhinoFile” node is unable to accept the document that I’m feeding it. I’ve tried encoding and JSON.stringify() the rhino document, but I am still unsuccessful. You may reference my 2 failed attempts below.
I have a similar problem. Since the thread is already some time old, I wanted to inquire whether there is anything new.
I have a computer server running that is passed a Grasshopper definition using Python. The Grasshopper definition is then supposed to process 3dm files automatically (the files have always the same structure).
Currently, I am trying to open the .3dm files using the rhino3dm library and pass the geometries to Compute like in the samples on Github.
However, I fail because these geometries are diverse (points, curves, and breps). In Grasshopper, I seem to be bound to use e.g. “Curve” components as RH_IN:xxx, for for curves.
Could the AppServer solve this problem or do you have another idea?
Of course, that was my first idea too. However, no geometry is passed to the grasshopper definition at all, and no error message is returned. That’s why I thought that the geometry component is not a valid input.
Maybe I’m missing the point of the question, but in general, rhino.compute runs a headless version of Rhino which means there is no existing document to pull geometry from. If you want to include geometry (and you’re using Hops) then I would recommend using the Get Geometry component (Params/Util). This component (when used in Hops) will serialize the geometry that gets passed into the input as a JSON string… which compute will then deserialize and rebuild as actual geometry. So, that is typically the way this would get handled. Does that help? Or did I misunderstand the question. Can you provide a simplified example of where things are failing for you?