Description
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.');
}
};
`