Force Python to recompute if new file is loaded

I have found the following Python code, which gives you all the GUID of an opened file.

“”“Provides a scripting component.
Inputs:
x: The x script variable
y: The y script variable
Output:
a: The a output variable”""

author = “david.mavrov”
version = “2019.08.23”

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino as rc

sc.doc = rc.RhinoDoc.ActiveDoc

allObjects = rs.AllObjects()
print allObjects
AllObjects = [str(guid) for guid in allObjects]

However, every time I open a new file, or change the content in Rhino, I have to manually recompute. Any way to integrate this into the component itself?

GUID.gh (1.3 KB)

You could re-start the component itself internally, and you could check if the current opened rhino file (name) is changed.
But to check if there are any

it would be a lot complex. Maybe there is a rhinocommon function for this… i don’t know.

You can lazily add a geometry pipeline + list length to trigger the script to restart like this:
2019-08-26%2014_45_43-Window
(Note that x isn’t (shouldn’t) used at all)

I need the GUID of text objects. Otherwise that was my first go :slight_smile: I can also connect a timer to it, but that is just a workaround.