algorithmic modeling for Rhino
Hey people,
I was wondering if a can obtain a color of the components surounding group, for the use with a 'customPreview'Component.
Searching for some similar topics I found this; to change the color of a (UI-Group)
http://www.grasshopper3d.com/forum/topics/change-component-group-co...
Starting from the approach to find a 'GH_Group' in the current 'GH_Document.Objects()',
I try to find the component of interest in one of the groups (watched*).
[Have a look at method 'private bool GetGroupColor()...']
"
Here is the components source (SOURCE at bitbucket)
Gh-Definition in attached.
"
But there is some strange behaviour.
- So if I copy a group containg an instance of the component, there is an error wich I did not managed to debug; so a color can not be calculated.
- Anytime the color of a watched* group is changed, an error is written to RhinoConsole:
An error occured in the display pipeline @ 23:08:21(692ms)
Anybody has a tip how to fix this stuff, or an idea where the behaviour could come from.
Or is this the wrong approach to do such a stuff...
I guess it can be a good way to colorcode preview against defintion (visual-appareance).
Aloha Mark
Tags:
FORGOT:
GHA
|
\/
I'll need to see some actual code I can compile and debug.
There is no event associated with a group colour change, except the canvas redraw events (but there are a lot of those, so using them to check for group colour changes would seem like overkill).
Furthermore you need to decide what colour to output and whether or not to expire your groupcolourharvester before a solution starts, which means probably handling the GH_Document.SolutionStart event, checking whether or not a group contains the object, checking whether the group colour is different from before, and if it is expiring your component.
Hey David,
The link to bitbucket does not work? There is the actual code.
(if not, attached solution as .zip)
It compiles just fine on my machine (visual studio 2015 enterprise).
Actually Im doing something similar u described. Going the 'overkill'-way of calculating, overriding 'DrawViewportWires'
public override void DrawViewportWires(IGH_PreviewArgs args)
{
if (!InConstructor && GetGroupColor())
ExpireSolution(true);
}
Im going to try the other approach u described.
Greets Mark
The attached approach works for me. I'm using the Canvas paint event (group colour changes do not cause rhino viewport redraws) and scheduling a solution. This gets around the problem of triggering new solutions in the middle of other processes.
Big thanks David,
This is fantastic.
I modified your code to be part of an abstract class wich can either be used to output the color, OR to be used in PreviewMode...
AbstractClass
overrides:
- bool SearchForColor()
- void GroupColorChanged(GH_Document document)
The Source on Bitbucket.
The .gha attached.
Greets
Mark
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by