mcneel / compute.rhino3d

REST geometry server based on RhinoCommon and headless Rhino
Other
284 stars 182 forks source link

rhino.compute throws an exception when evaluating grasshopper definition file (.ghx) #591

Open sohaibargon opened 1 year ago

sohaibargon commented 1 year ago

Hi there I am trying to convert a .dwg file into a .pdf file using Rhino-compute and Grasshopper in Node Js. I am using the compute-rhino3d npm package.

I am passing the path of a grasshopper definition file (.ghx) to rhinoCompute.Grasshopper.evaluateDefinition() function. But the rhino.compute throws the following exception.

System.Xml.XmlException: 'Data at the root level is invalid. Line 1, position 1.'

Here is my node js code.

`const rhinoCompute = require('compute-rhino3d'); rhinoCompute.url = 'http://localhost:8081/';

exports.rhino = async (req, res) => { console.log(req.body); try { const dwgFilePath = req.file.path; console.log(dwgFilePath); const definition = 'C:\Users\Sohaib\Documents\gh\Planometric_GH_tester_xml_version.ghx'; const outputPath = 'C:\Users\Sohaib\Documents'; const trees = [ { data: { FilePath: 'C:\Users\Sohaib\Documents\gh\file-1686857280276.dwg', }, }, { data: { outputPath } }, ]; // Convert the .dwg file to .pdf using Grasshopper and Rhino.Compute const result = await rhinoCompute.Grasshopper.evaluateDefinition( definition, trees ); // Send the converted .pdf file as a response res.send(result); } catch (error) { console.error(error); res.status(500).send('An error occurred during the conversion.'); } }; `

fahadmajeed commented 1 year ago

Anyone on this one? would really help a lot. Seems there is no similar issue on the web either.

buckettt commented 11 months ago

Do you have an output "RH_OUT:myresponse" type object in your file?

sohaibargon commented 11 months ago

Do you have an output "RH_OUT:myresponse" type object in your file?

I have a grasshopper file that generates a pdf of the given .dwg file. Now I am passing the grasshopper file through the Rhino App server. I am getting a different error this time, "System.Exceptions.PayAttentionException: 'Looks like you've missed something..."

From GrasshopperDefinition.cs file if (outputSchema.Values.Count < 1) throw new System.Exceptions.PayAttentionException("Looks like you've missed something..."); // TODO

        return outputSchema;
    }
buckettt commented 10 months ago

Try just putting a notional output in your script, I've had issues before trying to do something similar and not actually having an output.