const crvPoints = new rhino.Point3dList()
let len = cpoints.length
let zero = 0
for(let i = 0; i< len - 2; i+=2){
crvPoints.add(cpoints[i],cpoints[i+1],0)
}
crvPoints.add(cpoints[0],cpoints[1],0)
let epoint1 = (cpoints[len-2],cpoints[len-1],0)
let epoint = [];
let pt = "{\"X\":"+cpoints[len-2]+",\"Y\":"+cpoints[len-1]+"}";
epoint.push(pt);
const nCrv = rhino.Curve.create( false, 1, crvPoints)
const crvData = JSON.stringify( nCrv.encode() )
param1.append([0],[ crvData ])
param2.append([0],[ epoint1 ])
let trees = []
trees.push(param1)
//trees.push(param2)
console.log(trees)
RhinoCompute.Grasshopper.evaluateDefinition(definition, trees).then(result => {
console.log(result)
})
}
rhino3dm().then( async m => {
console.log('Loaded rhino3dm.')
rhino = m // global
RhinoCompute.url = "http://localhost:8081/" // Rhino.Compute server url
RhinoCompute.apiKey = "" // your Rhino.Compute server api key
// source a .ghx file in the same directory
let url = 'curve as input.gh'
let res = await fetch(url)
let buffer = await res.arrayBuffer()
definition = new Uint8Array(buffer)
})
I am not able to create a normal curve from a set of points in Javascript. Please suggest a solution for this.
Javascript?
What is a normal curve?
If you are just trying to make a polyline curve, then just Polyline, instead of a Point3dList
, can then use Polyline.toPolylineCurve()
to create your curve.
– Dale