How to stop specific outputs of a Grasshopper component from displaying results automatically

In this previous post, a way to stop a component from automatically displaying results on calculation was shown. This put the onus of previewing results directly onto the user. However, there may be a time when you wish for the user to view some results, but not all of them.

For example, maybe you have a component which has a primary function to colour the mesh and output that mesh result to Rhino. However, a secondary function of the component is to provide the points which make up the mesh (the mesh vertices) for debugging purposes (or whatever purpose really, that's up to you). If you have the component previewing the outputs, you'll end up with a mesh which is barely visible due to all the points drawn on top of it with red crossed denoting a GH point, similar to the one below. You can only see a mass of red, and it's only when you zoom in that the green of the mesh is visible.

Mesh points cover the majority of the mesh.

Mesh points cover the majority of the mesh.


You can see the mesh colour (green) only when zoomed in

You can see the mesh colour (green) only when zoomed in

If you have the component not previewing the outputs (i.e. if you use the method from the previous post), then no output will be visible to the user and they'll have to either turn on the preview (which could result in the situation above), or get a mesh component and drag the wire from the mesh output to the mesh component to view the mesh. In terms of usability, this isn't an ideal solution, as it's placing onus on the user to perform an additional step which, to the average user, would not be overly intuitive, and they may think your component is broken as a result.

Turning preview off for individual outputs

So what's our solution? Well, just as we can turn the preview off for the whole component, we can turn the preview off for individual outputs. Thus, we can display our mesh automatically to the user with the colours, but the mesh points can be hidden and only viewed by deliberate action from the user (for the debugging purposes (or other)).

To do this, we simply cast the registered output to be of the type IGH_PreviewObject and set the hidden property to true (as done here for the whole component). See the example below for an implementation of this.

If you want to hide multiple outputs, you could wrap this into a for loop (see below) to save you having to duplicate lines of code.

Turning the output off, gives us the ability to see our mesh normally (see below), without having to perform extra steps. In terms of usability, this is the favoured format, minimal effort is needed by the user but, for the more experienced users, extra functionality is provided should they need or want it.

Our green coloured mesh is now clearly visible.

Our green coloured mesh is now clearly visible.

Hopefully this helps you create components which only gives the necessary outputs by default and provides optional outputs to the users for additional functionality without immediately detracting from the original default output.

Leave a Reply

Your email address will not be published. Required fields are marked *