Custom Preview Display in Python(Grasshopper)

Hi,

I’m writing a custom component(grasshopper) in python and I would like to display the geometry(lines) in different colours. I know it can be done but I don’t know where to start (maybe Rhino.Display.CustomDisplay) but I am not sure. I have searched in the grasshopper forum and had no luck.

Any ideas?

Thanks,

Miguel

If you want to participate in viewport drawing, override the following methods on GH_Component:

IsPreviewCapable
ClippingBox
DrawViewportWires
DrawViewportMeshes

Does this help?

Hello Dale,

thanks for your reply. To be honest, I wouldn’t know where to start. I was hoping that someone could make a very simple example(just with a line segment or a point) and I could try and take it from there.

I’m not sure if this post might be related. Dynamic Drawing of Lines Based on Chosen Points

Also found this thread: http://www.grasshopper3d.com/forum/topics/rhino-display-customdisplay-and-event-handling-using-python but most of the links are redirected to the old Rhino.Python forum.

I’ll keep trying, and see if I can figure it out.

  • M

@piac, do you have any suggestions for this?

Hi @Miguel

Just to make sure I understand the issue properly: are you writing a script in the Python scripting component and trying to change its behavior?

Can you tell me the goal of this?
Is it specifically to change the default appearance of the preview? Or do you also want to show other behaviors later?

Thanks,
Giulio

Hi Giulio,

I just want to change the default preview colour. I’m writing a components for network analysis, similar to space syntax.
http://www.spacesyntax.net and I would like to visualise the result with a gradient of colours.

Thanks,
Miguel

Hi Everyone,

@AndersDeleuran answered my question over at the grasshopper forum.

I’ll upload his answer here just in case the link breaks in the future.

Thanks,

Miguel

GHPython_DiscoSticks.gh(8.5 KB)

1 Like

Hello Miguel,

I download th scripy that you provided and it kind of works, but one thing occured to me is that when I delet the component, the previewed text was still displaied on the scrren. And it cant be removed.

How can I fix this problem?
Many thanks

Have a look here for one approach:

There is an example here, on how to override a preview method (DrawViewportWires) in SDK mode:

but somehow discourse is not showing the images anymore. I asked why. The code is still visible.

1 Like

Probably because of the server glitch we had awhile back. Various things got lost, a lot of images and linked files. Not sure how much of that is recoverable. if at all.