Grasshopper

algorithmic modeling for Rhino

Is it possible to get access to the GH_Cluster object(s) that a cluster document belongs to from code written inside that cluster? I can get the parent document with GrasshopperDocument.Owner.OwnerDocument() but I'd really love to be able to talk to the cluster objects themselves.

Views: 817

Replies to This Discussion

Try casting Owner to a cluster object. Does that work? (sorry can't test myself at the moment).

Works beautifully! Thanks David. 

Andrew, did this work for you? I am trying something similar but no success. 

GH_Document thisDoc = OnPingDocument(); //the cluster document

GH_Document parentDoc = thisDoc.Owner.OwnerDocument(); //the document that owns the cluster

GH_Cluster clusterComponent = (GH_Cluster) parentDoc; // cannot convert GH_Document to GH_Cluster  error..

You have to cast the owner, not the owner document.


GH_Document thisDoc = OnPingDocument(); //the cluster document
GH_Document parentOwner = thisDoc.Owner; //the owner of the cluster
GH_Cluster clusterComponent = (GH_Cluster) parentOwner; // the cluster object

Ahhh, that makes sense. Thanks for the quick reply!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service