How to distinguish one component is added by .gh or added by manual

as we know ,when open .gh file or add one component by manually , this 2 types all will
invoke AddedToDocument(GH_Document doc) ,so can someone tell me how to “distinguish” this 2 types “add”(open .gh or add manually), when in AddedToDocument( ) method?
Thank you!

This worked for me before:

public override void AddedToDocument(GH_Document document)
{
     if (document.Enabled)
          OnAddedToDocumentByUser(); // Handle your manual addition of component here
     base.AddedToDocument(document);
}
1 Like

Thankyou Ondrej,it works