algorithmic modeling for Rhino
Hi there,
I have a custom component that overrides the two methods DocumentContextChanged and RemovedFromDocument. When I place this component inside a cluster which I then delete or change the context of, neither of these two methods are triggered. This makes sense in a way, because if I delete the cluster component (which contains my custom component), I am actually not deleting or changing my custom component. However, is there a way for me to link the actions performed on my cluster component to my custom component which resides inside? Basically I would like DocumentContextChanged to be triggered anytime my cluster component's DocumentContextChanged is triggered.
Thanks,
Emil
Tags:
Progress: I've managed to listen to the cluster component's events from my custom component. I wrote this method, which simply makes the custom component (and its' document) subscribe to some events in the cluster component (and its' document).
private void SubscribeToParentDocEvents() {
GH_Document thisDoc = OnPingDocument();
if(thisDoc != null){
GH_Document parentDoc = thisDoc.Owner.OwnerDocument();
if (parentDoc != null) { //parent is null if it doesn't belong to a cluster
parentDoc.ContextChanged += OnParentContextChanged;
}
IGH_DocumentOwner parentOwner = thisDoc.Owner;
GH_Cluster clusterComponent = (GH_Cluster)parentOwner;
clusterComponent.ObjectChanged += ClusterComponent_ObjectChanged;
clusterComponent.SolutionExpired += ClusterComponent_SolutionExpired;
clusterComponent.PingDocument += ClusterComponent_PingDocument;
}
}
However, I am still not able to find any events in clusterComponent which are triggered when AddedToDocument and RemovedFromDocument are called. If I could find that, I think it would solve my problem. Any input?
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by