Limit Bake and then break

I added a ‘Reset’ input to the Python bake component I wrote three years ago:

Seems to work, though I’m far from an expert at Python.

bake_once_2023Mar6a
bake_once_2023Mar6a.gh (5.4 KB)

# Instantiate/reset persisent "okBake" variable
if "okBake" not in globals() or reset:
    okBake = True

if active and okBake: #change the scriptcontext
    scriptcontext.doc = Rhino.RhinoDoc.ActiveDoc
    try:
        if type(geo) is System.Guid:
            g = ghdoc.Objects.Find(geo)
            if g and hasattr(g, 'Geometry'):
                bakeGeo(g.Geometry, g.Attributes, layer, rM, mSrc)
                okBake = False

P.S. This will cause problems in the way I typically use the Bake component when I use multiple ‘bakes’ for a variety of geometry and layers. Only the first one will work.