Replacing Model in Rhino

Is there a more efficient way to make changes using python to the current model inside Rhino without using Grasshopper?

The below script works but I am looking for a quicker way that I could develop into a Pollination app:

from honeybee.model import Model

# Load the Honeybee Model from the JSON file
hbjson_path = r"path_to_model\model_name.hbjson"
model = Model.from_hbjson(hbjson_path)
#Make changes to the model below...

#write changes to file, reload hbjson into Rhino
1 Like

Hi @marentette,

You can use get_hbjson and send_hbjson functions from pollination_streamlit_io to get the model from Rhino and replace it in Rhino after the update. See the sample code here as an example:

Here is the live version of the app:

Here is a short preview. The app gets the model from Rhino, renames the faces, and then replaces the model in Rhino with the updated model.

One thing to keep in mind is that it looks like we don’t register these changes in the Rhino plugin. This means the Undo command won’t undo these changes. I would consider this a bug.

cc: @mingbo

Let me know if you have any other questions.

Thanks @mostapha for the example!

Having this as a transaction that you could roll back in the interface would be great. Is there pollination_streamlit_io documentation available?

Unfortunately, we haven’t kept up with the documentation as we changed it frequently. We used to have an app that was used for documentation but I made it private.

I can give you access to the app but probably the best way to help you is to do it on a case-by-case basis depending on what you are trying to do.

@antonellodinunzio, we should consider updating the app at some point now that the code is in a much more stable place.