How to check if Rhino object is referenced?

Is there a way to query whether an object in Rhino is being referenced in Grasshopper or not?
Trying to find a shortcut to that annoying moment when you accidentally delete something that is referenced and don’t notice for half an hour.

There are a few ways this could be enabled (as I think currently there is nothing in rhino that makes it aware of an object being referenced in a gh def).

The approach I’d take is to write a Rhino script/plugin that was aware if gh is running, and if so, check if a def is open, and if so, check the component params for Rhino Object references. This would only tell you if an object is referenced in the open gh def. If you want to know if an object is a reference in any gh def, you’d need to add some data to the rhino object which stores this. This might get messy if an object has been copied in multiple rhino files, if it has been modified, etc.

There are some attempts to register the rhino file that corresponds with a definition. (Links coming).

@davidrutten, might have other suggestions, and opinions on whether this is an ok approach.

Would this not be possible entirely from inside Grasshopper?
to cross check an object id against all referenced objects in a definition? no need to venture out in to Rhino I think?

In fact, just having a component that selects all referenced objects in a definition would solve the problem…
Been poking around Human and Metahopper, but haven’t found such a thing so far though :confused:

Hello,

does this help?

instanceChecker.gh (4.8 KB)

There is no way now, but I agree it would be nice to have. By what sort of mechanism do you imagine this relationship manifests? Here are some ideas:

  • Referenced objects appear differently in Rhino (this is problematic because it adds gunk to the viewport all the time plus an object may be referenced by a gh file not currently loaded or active).
  • Referenced objects are associated with ‘history break’ warnings when deleted.
  • Referenced objects in GH always retain the most recent valid geometric representation just in case the object is deleted or unavailable. Basically GH would automatically internalise any referenced geometry and just use that copy when the original isn’t there. I like this solution, but it does mean that gh files potentially get very much bigger. Right now if you reference 1000 breps the gh file will store 1000 * 128-bits-per-guid / 8-bits-per-byte = 16kB of data. If all those breps are internalised the amount of bytes would probably be at least 1MB for even the simplest shapes and there really is no upper limit.
  • Referenced objects are cached in some other file for the duration of the current Rhino instance. This allows me to automatically internalise shapes after the fact without bloating the file, but the scope within which this works as a solution is much narrower.