Day 212 since no signs of life
Can we do this with hops?
Cheers,
Antoine
Day 212 since no signs of life
Can we do this with hops?
Cheers,
Antoine
Since I am also quite interested about Hops can you please describe more what is the issue and maybe schare the file
I cannot share this specific file, at least not for now…
But the question is general (dunno how to say that in English)
I’d simply like to have custom error messages on components with a CPython Hops.
If you need examples on how to use hops, I followed this example
Arriving late to the party but here are my twocents:
ghhops_server
python module.GH_Component.AddRuntimeMessage
ghhops_server
and enhance the C# Hops Component code in a way that it “listens” for errors thrown within the CPython Hops component or called using a specific function.If I ever have some free time on my hands I’ll probably try to get this started since I’m heavily missing a way to throw custom errors that give detailed info.
Don’t know if this helps…
Thanks for your reply !
I was hoping that something like you’re describing in point 4 was already hiding somewhere in hops…
For me, I can usually get away with prints combined with whatever hops gives me for an error… (even if it’s sometimes a guessing game)
But it would be a lot better for the user experience (people that will use the plugins), to have proper precise error messages, written by the person who made the components
Do you know if something like this is already available @stevebaer ?
If your component generates a warning or error in the remote process, they should get reported by the hops component. That’s what happens for GH definitions running on a remote Rhino. For CPython I’ll need to double check. If the JSON returned from CPython contains a warnings list it should get reported by Hops; I’m just not sure if we have helper functions for this in python.
Exceptions from python should get reported as errors in the Hops component.
For now we get the complete traceback of where the error triggered (within our cpython files or even within used libraries).
But what I’d like to know is if there is a way (when a certain error is triggered) to stop the hops function and return a custom error message to grasshopper that will be displayed in the red bubble (?)
Throw an exception with a custom message
I didn’t understood correctly the first part of your previous message, now I do and it works.
Thanks !
Is there a way to feed the output of hops an error and/or warning object without creating one within a component? I see there are error/warning properties in the response body. The reason being is that I have some component logic that is designed to catch geometry cases that don’t fit what the script is intended to do, and so rather than continuing and waiting for an error, I want to stop execution once the error is received and skip the rest and just return an error within the response body along with the custom error messsage.
{
"absolutetolerance": 0.0,
"angletolerance": 0.0,
"modelunits": "Millimeters",
"algo": "",
"pointer": null,
"cachesolve": false,
"recursionlevel": 0,
"values": [
{
"ParamName": "C",
"InnerTree": {
"{0}": [
{
"type": "Rhino.Geometry.Circle",
"data": "{\"Radius\":100.0,\"Plane\":{\"Origin\":{\"X\":0.0,\"Y\":0.0,\"Z\":0.0},\"XAxis\":{\"X\":1.0,\"Y\":0.0,\"Z\":0.0},\"YAxis\":{\"X\":0.0,\"Y\":0.0,\"Z\":1.0},\"ZAxis\":{\"X\":0.0,\"Y\":-1.0,\"Z\":0.0},\"Normal\":{\"X\":0.0,\"Y\":-1.0,\"Z\":0.0}},\"Center\":{\"X\":0.0,\"Y\":0.0,\"Z\":0.0},\"Normal\":{\"X\":0.0,\"Y\":-1.0,\"Z\":0.0}}"
}
]
}
}
],
"warnings": [],
"errors": []
}
Hey @AndyPayne / @stevebaer. I figured I would follow up on my above comment. Is this something that is doable in hops? Or is it something that is in the pipeline?
I’m not sure I follow, but that won’t stop me from making up an answer
You should be able to throw an exception from your python function running on ghhops-server to get an error message to show up in the hops component.
If that is not what you are asking about, please let me know.
Hey @stevebaer. I’ll give an example of what I am trying to do and put a flow chart of the current and desired process:
TL;DR: It would be good if there was a way to validate inputs based on definition requirements beyond the min/max, domain range and tree access settings within the get parameters for hops, and then be able to control the response body based on that validation.
Example
I have a definition that creates a series of points on a surface, using the evaluate surface command. It returns the point tree. I only ever want to have it work for strictly planar surfaces.
If feed it a surface argument, it is technically valid as per the evaluate surface component logic. What I need is a planar check before hand to see if the surface argument is planar or not. If it is, evaluate the rest of the definition and return the result. If not, return an empty result and populate the warning body of the response body.
The equivalent in code would be:
public ResponseBody MyFunction(Surface surface, List<ValueSet> valueSetList){
var responseBody = new ResponseBody();
if(surface.IsPlanar()){
values = new List<Point3d>();
vectors = new List<Vector3d>();
for(ValueSet valueSet in valueSetList){
surface.Evaluate(value_set.u, value_set.v, 1, values, vectors);
}
responseBody.Values = values;
else{
responseBody.Values = new DataTree();
responseBody.Warnings.Add("Surface is not planar");
}
return responseBody;
}
Here is a flow chart of the current and desired solution:
Is this question about CPython as the server being called by hops?
Probably not and probably should be a separate topic