Hi, I just had a few questions about rhino compute. I am trying to render a mesh using a gh definition. For debugging purposes I would like the rhino compute server to respond with warnings if there are any warnings in the gh file. Is this natively supported? I attempted a workaround by creating a c# component that parses through each object and logs warnings into a panel component but I ran into the following issue. Is there another approach for grabbing these warnings from rhino compute? For context I was able to get error responses returned to me.
Errors and Warnings that are generated by components are automatically sent back as part of the JSON response. If you’re using Hops, those will surface on the Hops component themselves. For example, if I have a simple example which adds two numbers together, but I pass in a text value that isn’t a number, then it will give me the error that would be generated by the Addition component (i.e. Data conversion failed from Text to Number).
If you aren’t using Hops, those messages will still be available as part of the Warnings and Errors in the JSON Schema.
If you’re writing your own scripts, you can add warnings and error messages that will also be included in the JSON Schema by using the AddRuntimeMessage method like this:
AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "This is a warning message from my component.");
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "And this is an error message.");
And then when you go to solve the definition, the warnings and errors will be returned like this.
AddTwoNumbers.gh (5.8 KB)
Thank you so much for taking the time to reply! Are warnings natively supported or do I have to enable them?
In the following javascript code I am evaluating a grashopper definition that contains a warning, but an empty response object is returned that doesn’t contain warnings logs. It would be helpful for me to know which component caused the warning.
`const res = await RhinoCompute.Grasshopper.evaluateDefinition(definition, trees)`
Thanks again!
The errors and warnings should populate automatically. Perhaps there’s an issue with the EvaluateDefinition method rather than when it’s run through Hops. Can you try testing your file by using the Hops component and see if the errors/warnings are returned there?
I tried testing the file using the Hops component but I still can’t get the warnings to show up. However, I can see the errors, which is strange. Could it be the way I set up Rhino compute? Do I need to manually enable warning messages?
I’m not sure. No, you don’t have to enable anything (the errors and warnings are returned automatically as part of the JSON schema). Have you tried using Hops to evaluate your definition? Make sure the URL section of the Hops preferences is empty and when you launch Grasshopper (on Windows) then it will automatically start a standard instance of rhino.compute automatically for you. You may need to uncheck the “Hide console window on startup” in the Hops preferences if you want to view the console messages… but I’m curious if you’re able to see the warnings when you do it that way. Alternatively, you can upload your definition here and I can try to take a look.
Hi Andy, here is my .gh file
delaunay_warning_test.gh (6.2 KB)
that contains a warning, Do you see the warning when you evaluate this defintion using Rhino Compute?
If you get it working can you send the code so I can replicate it?
Thank you so much!
I don’t think this example file works the way you think after the latest release of Hops/Rhino.Compute. Basically, in the last release of Hops, I made it so that disabled parameters (ie. Context Get Point component) get skipped during the parsing phase… So, when I load your definition in Hops, there is no input (because it’s been disabled) and one output (called mesh).
However, I do get warnings to show up in the Hops component (which means they’re passed along as part of the JSON response). Basically, there are two warnings which are telling me that there are inputs in the definition that have failed to collect data (which makes sense because the point2 parameter is disabled and anything downstream is empty).





