algorithmic modeling for Rhino
This question goes Along with my previous query which was sparked by some nice new examples in the recent GrasshopperSDK.chm.
I have a prototype c# script component which when triggered opens up a dialog with a Form. This form has some controls which are being populated with external data. I would like to create a custom component on which I'd like to place/render this form directly on the component face. I would like the functionality of expanding and contracting the component display like a text panel, param viewer, image sampler, graph, etc, but the content inside the form does not necessarily need to be scaled.
From the example, it seems I would need to override CreateAttributes to point to an Attributes class that I set up. Digging in the SDK I found GH_ResizableAttributes which seems like the class I would need to be deriving from for the resizing I am looking for. Besides this, there seem to be two methods to override in the Attributes which are Layout and Render.
At the most basic level, I'd like to attach a System.Windows.Form control to the component and I am assuming that if I were able to do this, it would be on the Layout method. Is this assumption correct, or am I getting ahead of myself? I guess what I would like to avoid in the first iteration of this test is to have to redraw the graphics for the Control and add the functionality that the Control already gives me.
Thanks,
luis
Tags:
Hi Luis,
you cannot put System.Windows.Forms objects inside a Component Attributes, you need to draw everything directly inside the graphics pipeline and handle mouse events through Grasshopper channels as well.
It is possible to render a Control or a Form to a bitmap, then draw the bitmap onto the canvas, but this sounds like the worst of both worlds.
What exactly are you looking to achieve? Is it just feedback or do you expect people to push buttons/drag sliders/enter text* as well?
The basic idea is to write a custom Attributes class and then override the layout, display and interaction methods. There's usually a lot of typing involved. If you derive from GH_ResizableAttributes then you'll get resizing functionality for free, but if your 'form' has a fixed layout, you don't actually want people to resize it.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
* The Number Slider uses a hack to allow on-canvas-text-input. It will put a System.Windows.Forms.TextBox on the canvas on a double click, but this textbox is removed when it loses focus.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2025 Created by Scott Davidson.
Powered by