Yep, copying will retain the ID, however when components are pasted (or otherwise imported) into an existing document, the ids will be mutated to avoid collisions. This happens by calling
Certain types of object need to be aware of when ids change (primarily groups, because they reference their contents using ID), so there’s a mechanism for getting that information. Make your component implement the
IGH_InstanceGuidDependent interface which necessitates you write the following method:
public void InstanceGuidsChanged(SortedDictionary<Guid, Guid> map)
The dictionary you’re given maps old ids (before the mutation) to new ids (after the mutation). So basically you see whether your old id appears as a key in the map, and then the value tells you what new id you’ve been given. If you need to track it down the other way around then you’ll have to enumerate over all the keyvalue pairs and check values. Slower, but equally exact.