Custom preview on python component - minimal example?

I’m trying to understand how to preview geometry that is created in a class object, but is not explicitly output.

Here’s a simplified example of what I’m trying to do.
How can I get the cylinder to show on the first component, without outputting it?


Preview.gh (6.5 KB)

Hi Toni, I shared a bunch of content over here that goes through how to draw things with GHPython, that should help you get going I imagine:

@AndersDeleuran
Thank you for the link. Quite comprehensive package.

If I understood correctly (?), Rhino.Display.CustomDisplay only allows for curve/polyline objects, but works in procedural mode.
For 3D objects using eg. DrawViewportMeshes, would need to switch to SDK mode.

1 Like

Yup that’s correct. One could probably implement a display conduit in procedural mode as well, but the Grasshopper component SDK drawing methods are likely a lot simpler to implement. For a shaded cylinder, I think you would need to cast to brep and use these two methods:

Though there is also a wire drawing method specifically for cylinders.

2 Likes

Thanks for the link to the gitHub! It took me a couple of hours to understand the preview via python components but when I had your examples I immediately could follow along! Saving my day :pray:

1 Like

Ah that’s great to hear. Glad it was useful to you :slight_smile: