generative modeling for Rhino
I started to play with custom data types and added some preview attribute to one of them using GH_PreviewMeshArgs. My question is quite simple: how can we modify these attributes based on the selected / unselected status of the component that is using this data type? (because it seems that no other material than the default GH material is answering to this).
If someone has a clue...
If Attributes.Selected() = True Then ...
And in case someone is searching for the equivalent of the "Enabled" toggle:
If MyBase.Locked() = true Then...
sorry, I didn't realize this is what you were looking for. You're right, to check whether 'you' are selected:
If (Attributes IsNot Nothing) AndAlso (Attributes.Selected) Then
To check whether you are enabled:
If (Not Locked) Then
And ultimately to check whether you are hidden:
If (Hidden) Then
Do note that just because you are hidden it doesn't necessarily mean you shouldn't draw yourself. If the PreviewSelectedObjectsOnly mode is on and you are selected then you should draw yourself regardless of hidden state. Typically Grasshopper will figure out whether you need to draw and only call the DrawViewportXXXX() methods when needed.
Thank you for the tip for PreviewSelectedObjectsOnly David!