Grasshopper

algorithmic modeling for Rhino

Hi,

I have a large definition in which I've moved all the input components over to one corner of the canvas. I focus in on that part of the definition so I can use it like a control panel while watching the output change in Rhino.

I'd like to be able to change the background color of different component groups in the 'control panel' based on certain conditions, much like components do on their own to indicate their state. In this case, the conditions I'm looking for are computed in an area of the canvas that is out of sight, and I'd like to be able to relay the result to the corresponding input group in the control panel via color.

Is there any way to change the background color of a component group on the fly?

Views: 2986

Replies to This Discussion

It can be done via a VB or C# script. But it'll probably be quite specific code. I attached a document with a VB component which assigns colours to all groups in the current document with a matching name.

If it cannot be opened on your version I can also post the code directly.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

 I attached a document

Are you sure?

I am now...

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Attachments:

The panel component from your newer version fails to deserialize itself.

I attached a working version for latest public release.

Attachments:

Interesting.

Is there a way to retrieve all groups present in a document as a list of strings?

Yes. Iterate over all objects in the GH_Document. Try and cast each one to a GH_Group. If the cast succeeds, append the group nickname to a list of strings.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks. Let´s see, if I can translate this into code in a free minute. 

At the moment rather for interest: You probaly could also retrieve some metadata like location, overlaps, area, number of included components, right?

Looking forward to see the GH 3.0 layout templates...

Number of included components yes. The rest is all computed on the fly when the group is drawn, so that information is harder to get. The attributes of the group do all the display stuff, but the Outline() method which returns the GraphicsPath that represents the shape of the group is private, not public.

However the algorithms that create the group shape are not particularly difficult as they use public methods in Grasshopper.GUI.GH_GDI_Util

  • GH_GDI_Util.Freeform_Blob
  • GH_GDI_Util.BoxUnion
  • GH_GDI_Util.FilletBoxOutline

However if you duplicate the logic for your own purposes you of course need to keep updating that logic whenever I add a new group type or change an existing type. Perhaps it's better if you try and invoke the private Outline() method via Reflection.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

I somehow missed your replies back when they were posted. Thanks to you both for your help!

Hello David, I wonder if this could be done with specific objects attributes instead of group names: For example, all sliders have blue color, all panels have grey color, etc. It would be quite tedious to make a group out of every slider and call the group "slider". So that all groups called sliders are blue...

Bumping

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service