DrawViewportWires from IGH_PreviewData : is data selected or not?


In a custom GH_Type …
GH_CDirectrix : GH_Goo<CDirectrix>, IGH_PreviewData

… I’m implementing a custom preview by overriding:
public void DrawViewportWires(GH_PreviewWireArgs args){}

How can I know If this method is called by a selected component (for instance a list item component) to customize the color of the display ?

I know how to do that within a parameter (Attributes.Selected) display but not in the type itself …


The object which owns the data decides whether it is selected and then send different preview arguments to the data. The data itself is not supposed to know about things more complicated than it, such as what sort of object contains it.

You could compare the preview arguments you got with the ones in the currently loaded GH_Document, but that would certainly not be 100% reliable.

If it’s just the colour you’re worried about, you shouldn’t. The colour given to you inside the arguments is all the info you need. If you want your preview to look different (for example drawing more information when selected) then you’re in for a hard time as Grasshopper doesn’t really allow you to find that out.

Ok thanks, I’ll drop my idea then !
But won’t it be possible in the future to pass a IsSelected prop to let us customized the display ?
I have in mind complex display and the green/red variants is to limited for my needs.

In the future yes, I plan to have various display modes that can be shared with the data, which would include both selected state as well as debug state which is supposed to draw lots of additional information.