Rhino 8 - Bake Viewport C# or Python Component

Hello,

I am leveraging the new Rhino 8 model viewport nodes in GH and so far so good in getting them to be dynamically created from a list of details.

If I manually right click and bake the viewport node or the model object node I get the expected results I am after.

What I am trying to create is just a very simple bake component that takes a boolean toggle in GH and bakes the model object/viewport(s) that I have created.

In testing Elefront, Human, Blickfeld, and other dynamic baking solutions do not appear to work with model viewports.

Any help is appreciated. I admittedly don’t know what I’m doing with python or C# but thinking it should be somewhat straightforward? I’m just not sure what I need to call for the bake exactly from Rhino.Common in regards to the viewport object type.

Any help is appreciated, thank you!

Here is some psuedo python code (generated from ChatGPT so I’m sure it’s not right at all?):

import Rhino
import scriptcontext as sc

class BakeObjectComponent(component):
    def __init__(self):
        super(BakeObjectComponent, self).__init__()
    
    def RunScript(self, obj, toggle):
        if toggle:
            # create a Rhino object based on the input geometry
            rhino_obj = sc.doc.Objects.Add(obj)
            # select the newly created object
            sc.doc.Objects.Select(rhino_obj)
            # update the Rhino viewport
            sc.doc.Views.Redraw()

Thank you all!

The bake component that will handle this will be added soon (i thought it was, so a matter of days i believe)

3 Likes

Amazing! Is there a tracking ID on this so I can stay on top of it?

Not that i’m aware of, but speaking of tracking; that will be a feature of the baker as well (re-baked objects retain their Rhino guid and subsequent dimensions, history, etc)

Wonderful! Does this mean we can potentially query history in a way where: if we dynamically bake something, it overwrites the previous object as expected but if a user has manually overridden something on the baked object (from within Rhino) there will be some kind of tracking/history of that change accessible from the grasshopper bake node?

My initial impression (i’ve only seen early demos) would be no, but can’t rule it out. The grasshopper change would overwrite the user change. You will have to chose who is in charge (Rhino or GH). There is a public demo next week, so I would expect it to be available then, if not soon after.

3 Likes

Understood, thanks for the info. I look forward to seeing more!

@Japhy any update or video of the public demo on the bake component?

Curious if it will be included in the next weekly WIP build or if I need to implement an alternative solution for now?

Thanks!

1 Like

This is exciting :star_struck:

Can someone tell me how to get Viewports into Rhino? This does not seem to work as expected.

Found out I can have them as additional windows, once I bake the component itself. I´d be even more convenient to export them as named views though. Any ideas?

Hi @phillip ,

I haven’t tested this recently but last year I was doing this a lot so I made a component for that purpose.

Here it is, let me know if it works!

202402402_Bake_Named_Views_01a.gh (4.5 KB)

2 Likes

Hi Michael, works great! Thanks a lot!

1 Like

Glad to hear it @phillip , you’re welcome!

Hi Phillip -
Thanks, Michael -

I’ve put that request on the list as RH-81517 Grasshopper: Create Named View
-wim

2 Likes