Custom Preview Display in Python(Grasshopper)


#1

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


(Dale Fugier) #2

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

IsPreviewCapable
ClippingBox
DrawViewportWires
DrawViewportMeshes

Does this help?


#3

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

(Steve Baer) #4

@piac, do you have any suggestions for this?


(Giulio Piacentino) #5

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


#6

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


#7

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)