Ladybug Geometry version of Honeybee's dictutil?

Hi all,

I have quick question re: the Ladybug geometry .py libraries. I’m trying to use the LBT geometry objects, specifically de-serializing some LBT geometry dicts. I notice that there is an HB ‘dictutil’ module that seems to handle re-serializing most Honeybee object types cleanly, but I wonder if there is a similar one for Ladybug Geometry? I couldn’t find one - and it seems like inside the honeybee.dictutil.py there isn’t something something like this used? But thought I’d check before building my own?

Something where you just push a re-serialized dict at it, and it returns the correct LBT Geometry object based on the ‘type’ key?

just wondering. thanks!
@edpmay

Can’t you check the type and then use the from_dict method? Do you have so many types that you need to handle?

Yes definitely - I just thought maybe a more universal converter function might already exist someplace that I just hadn’t found yet. Not a problem at all thought. Thanks @mostapha !

@edpmay

Right, there’s no dictutil.py module for ladybug_geometry right now but I would support adding one if you find it useful. All of the ladybug_geometry dictionaries have a "type" key that could be used to identify the object type (it’s always the same name as the object class). So you could structure the ladybug geometry dictionary methods like all of the honeybee dictutil.py ones. If you end up making a module like this and sending a PR to the ladybug_geometry repo, I would be happy to review it and merge it into the official code base.

That’s great, thanks. Yes you bet: once I have something together I’ll add a PR for it.

best,
@edpmay

I just wanted to say thanks for sending the PR, @edpmay . Here’s the docs page for the dictutil module that you added:

https://www.ladybug.tools/ladybug-geometry/docs/ladybug_geometry.dictutil.html

1 Like

@chris That’s great! Glad it seems helpful.

thanks,
@edpmay

1 Like