Hello everyone!
I have encountered a strange issue in the handling of the response Json from rhino compute. I have a script where I return multiple values;
- a draco compressed mesh is passed out as RH_OUT:Mesh
- an array of rhino curves are passed out as RH_OUT:Curves
- a double is passed out as RH_OUT:Value.
I start by making a json from the response
const responseJson = await response.json()
and then I have a method that parses the return json into the different objects that it contains. Here is a simplified version:
rawAlternative.data.values.map((value, i) => {
const { ParamName, InnerTree } = value
if (ParamName == 'RH_OUT:Mesh') {
const meshString = JSON.parse(InnerTree['{0}'][0].data)
alternative.meshString = meshString }
else if (ParamName == 'RH_OUT:Curves') {
alternative.curves = InnerTree['{0;0}'] }
}
return alternative
}
Ok, so the problem that I’m having is that the mesh on the InnerTree sometimes appears on ‘{0}’ and sometimes on ‘{0;0}’ and I can’t figure out why this is. I understand that it has to do with grasshoppers way of handling datatrees, but I flatten everything before I pass it out with the RH_OUT: parameters so I don’t know why it is inconsistent. I always just output a single mesh in the RH_OUT: parameter.
Do you have any suggestions on this or know how rhino creates the InnerTree object from the RH_OUT: parameters?
Thanks!
BR
Erik