In a video on Kangaroo I noticed that the maker of the video (Daniel Christev) used a component named “Counter”, but from the video I cannot discern which plugin that component belonged to. The component is inserted in the video at this point in time (16:19, you will surely miss it because the video is very rapid, so back a few seconds a watch again) :
OK, I installed WIP and opened it (I couldn’t find the 0.9 version on the site).
I can see that the ExpireSolution spins the numbers as fast as it can, but what about the Timer? Nothing happens when I activate it with Toggle = True (while the gh Timer is activated).
How are the two meant to be used, and why are they different?
I’ve been caught out by this before @DavidRutten When text panels are disabled, they don’t change in appearance at all, so it can be hard to tell why things aren’t updating. It would be helpful if they changed colour like other components. In fact is there even any situation in which people would really need to disable a text panel?
I too have been caught by this one. That said, I do occasionally disable text panels, parameters etc. to prevent them expiring downstream components (mainly during development/debugging).
One has timer inside component, one a typical approach.
Second one does not show number, because panel is locked… just unlock it.
And if you have a component compiled in visual studio, there is a third option.
And then there is a forth timer option when you run timer in separate thread, this helps when you want to update component, and do not refresh grasshopper components.
I’m actually coding my own GH component so I’d be interested in how such a component should be different. For now I have the following code, which is essentially your code (I will enhance this with more functionality later) :
public RILGH_TimerIntegerCounter()
: base("Timer Integer Counter", "TimerCnt",
"A counter driven by the standard GrassHopper Timer.",
"RIL", "Utils")
{
Message = "Timer";
}
protected Boolean m_reset = false;
protected Boolean m_run = false;
protected int m_count = 0;
protected override void SolveInstance(IGH_DataAccess DA)
{
if ( !DA.GetData((int)InPrt.Reset, ref m_reset) || m_reset )
{
m_count = 0;
DA.SetData((int)OutPrt.Out, "Reset.");
}
else if ( DA.GetData((int)InPrt.Run, ref m_run) && (m_run) )
{
m_count++;
}
DA.SetData((int)OutPrt.Count, m_count);
}
I also didn’t quite understand how this fourth version works. I know I want to update the downstream components using my counters on each new value emitted AND optionally, also updating the Rhino Viewports (on each counter update). Is that what you mean?
No, which is why the option isn’t in the menu. However panels can be disabled using the wheel menu or the main menu.
I’ve added some code so that disabled panels are now drawn like this:
Note that the background colour of a panel can be user specified, so drawing a panel in any solid colour will never be able to tell you whether or not it means something.