I’m currently working with Ladybug Tools and the Hops component. I have encountered a challenge related to the new vis_set Python object introduced in Ladybug Tools. My question is whether it’s possible to use this Python object as an output of the Hops component.
Currently, Hops doesn’t support direct Python object outputs, so I attempted to convert the Python object to a JSON string and pass it as a context print output. However, I’m encountering an error with the Hops component:
I believe this error might be related to the preview visualization set component or the process of converting the Python object to JSON, which might require access to Rhino Environment? Does the Hops component not have access to Rhino Environment? Is there a workaround to this?
I’m using Ladybug Tools version 1.6.0 for this definition. I have attached the relevant files, and I hope someone can help me resolve this issue.
Hi @Anuj_Mittal, I don’t know how Hops work but from the error message it looks like HOPS has tried to case the string to a geometry type that has resulted in no geometry (None) and then when it tries to access the Linetypes for that geometry it throws an error. Can you explicitly set the type of the output to a string?
thanks for the reply.
i think the issue is with args_list[0].to_vis_set(*args_list[1:]) in the process_vis_set(vis_set) function in the LB Preview Visualization Set.
Can you please help me find the to_vis_set method in the ladybug SDK? Does this look for Rhino environment? I assume that since Hops is running headless version of Rhino, it doesnt have access to an active document.
Again, I am not sure. Maybe @AndyPayne can help us here.
I’m afraid that I don’t know Ladybug tools very well so I don’t think I can help on that side. If you are trying to return some sort of custom data type… then I think @Mostapha suggestion to return a string of the data type representation (likely base64 encoded) would be the best possible solution. You would then likely need to have a separate component downstream of the Hops component that takes that string and then tries to deserialize it back into the data type you’re expecting. I hope that helps.
I think I get what you are trying to explain. I am trying exactly the same thing, which is to return a JSON object (string version of the data) via the context print output.
Where I am struggling is that, the process of converting the object to Json String in itself is using the Rhino Environment, it seems, which is why it is not able to find the attribute Linetype.
I am not sure what’s wrong, and if maybe combining ladybug tools with Hops is probably not the best idea, but it felt like this was such a good use case for Hops to maintain the correct versions of the scripts.
I hope I am able to explain what the problem seems to be.
@chris12 showed the way to go about it. Thanks a lot
I was having some difficulty locating the args_list = _vis_set.data and, as a result, I was resorting to using de_objectify_output(vis_set). I believe this was due to it being a part of the ladybug_rhino library, which led to it looking for a Rhino document.
In hindsight, I realize that I should have simply used _vis_set.data
Hi @AndyPayne - I’m in @Japhy’s RiR workshop and I just saw that the Linetypes component does not show any object unless one clicks on it in the Rhino UI.
It’s certainly a possibility. Basically, the query components are all read-only. They only return whatever objects it finds on the document. For linetypes, hatches, it was decided a long time ago to not auto-populate those tables in the document as they would add unnecessary bloat to the file (especially if the user has no plans to work with linetypes, hatches). So, in order to get the default linetypes and hatches to load you have to either open the hatches or linetypes panel in the UI, or open them through Tools->Options->Linetypes panel for example.
So the only way RHINO can update the linetype table is by opening that panel? There is no direct command to update the table?
I guess there is also no way to open a Rhino panel from Grasshopper? So basically my Grasshopper definition now needs to come with instructions to open a panel in Rhino first, otherwise it won’t work correctly?
You can either save a file that has the linetypes/hatches already loaded and have your users open that file at the start. Or, you can use the Query Linetypes/Hatches component and you can right-click on that and select “Add Default Linetypes”. This option will load all of the linetypes or hatches into the document.