Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sohaibargon opened this issue Jun 22, 2023 · 4 comments

Comments

@sohaibargon
Copy link

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
Copy link

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

@buckettt
Copy link

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

@sohaibargon
Copy link
Author

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants