I am trying to deconstruct the hbjson to extract programs and constructions, but I cannot find any component that allows retrieving such information from room objects.
As far as I know, such information should be present in the hbjson file, as their names can be visualised through the appropriate visualisation components.
Does anyone know if it is possible to accomplish this?
Thanks @charlie.brooker, it works!
I adjusted the code to get program types for each room instead of just the first one:
programs = []
for room in x.rooms:
programs.append(room.properties.energy.program_type)
a = programs
This method only works if the input is the entire model. Do you know what changes I should make to use individual rooms as input? This could be useful for other codes with faces as well.
If youâre inputting rooms then x becomes âroomsâ instead of a model. So in this case you should need an even simpler bit of code removing for loop that goes through each room like so:
a = x.properties.energy.program_type
I think if you give this a list of rooms you should get a list of program_types out, without the need for appending a list, but I could be wrong.
Likewise if you make the x input faces then you can access the face properties like so
Really glad to see you using the LBT Python SDK since thatâs the ultimate answer to getting any attribute that you want for a Honeybee object (even those not exposed on the visualization components). Itâs also the most efficient way to get the attribute.
I just wanted to add something in case there are some users watching this topic who are not yet at the level of using the LBT Python SDK. You can also use the HB Color Room Attributes and the HB Color Face Attributes components to get the attributes assigned to any Honeybee Room, Face or Aperture/Door. And you can see that the components return the actual object, which can be deconstructed with other components (not just the name of the attribute):
@chris .Just bumping this thread â is there a way to get almosts a topological representation of a honeybee zone model?
E.g. For each zone (node) you have a list of the zones (nodes) it is connected to, and the edges represent the surface/face they share with all the face attributes, u-values etc?
Maybe there is a different thread already talking about this
I tried this technique with latest HB tools and I only get the string name of the program object⌠I canât decompose it as shown in the screenshotâŚ
If I had to guess, the issue is more likely that you are passing in the name of a Program which is not part of the default âbuilt-inâ collection?
As shown above, passing a string to the âDecomposeâ works fine, since that component searches the built-in Program collection for the name. But, if your program is not in the built-in collection, it will not be able to find it, and will raise an error. In that case, you would need to pass in the actual ProgramType object, not a string of the Programâs name.
Yeah I am using a custom construction⌠I wasnât sure if only built in constructions could be referenced and now you have clarified, thank you!
As an alternative I built out a python routine to extract the program as suggested earlier in this thread. One note on this - I tried to use the basic python component but it doesnât recognize the honeybee commands. Instead I tried the IronPython component and that has been working.
I tried to use the basic python component but it doesnât recognize the honeybee commands.
Interesting⌠@chris had mentioned that the LBT libraries should be accessible from the new Python components, as well as the old GhPython ones:
â⌠Lastly, Iâll add that the latest Pollination installers add the Ladybug Tools core libraries to the Python paths of the Rhino 8 Script Editor. So, if you use the latest Pollination installer, you should not have any more import errors if you try pasting code from LBTâs GHPython components into a new ScriptEditor component. This means that you can technically use the LBT core libraries in the Rhino 8 script editor if you want.â Scritping in R8, ironpython2 and python 3? - #4 by chris
Iâm curious which part didnât work in the new editor for you?
Hereâs a side by side of the code snippet with Py3 component and IronPython component
This is my first time using any python components in grasshopper so not sure what might be happening. Reading through old forum posts I see lots of references to âghpythonâ and I thought I was supposed to use that component but I canât find it anywhere⌠tried to use rhino package manager, looked on food4rhino, doesnât seem to exist anymore? Anyway I tried IronPython based on some unrelated forum suggestion and it worked
Yes it is definitely confusing with all the different python components and environments now. Happy to provide a little background if it is helpful:
Pre-Rhino 8 there was something call the GhPython component, which allowed you to write and execute python code using the IronPython interpreter. This is what all the existing Honeybee-components use.
Now, in Rhino-8, there is a new IronPython component, and a new Python3 component. But the âoldâ GhPython component still exists - it is just âhiddenâ by default though. So to access it you have to type #GhPython in Grasshopper to get access to it (note the â#â symbol).
So while it is true you can import and use the LBT python libraries in the different editors (GhPyhon, IronPython, Python3), you cannot pass actual python âobjectsâ (in this case the âroomâ) between the different editors.
You can think of the different editors as existing independently and in parallel to one another. They donât know about each other, and canât really talk to one another well. While it is technically possible to pass some simple objects between them, it is complicated and not recommended.
So since the Honeybee-room is made in the âoldâ GhPython one, you can not pass it to the ânewâ Python3 one to pull out the program_type attribute. Since it was made in. GhPython, it has to stay in GhPython.