GrassHopper component named "Counter" - From which plugin? [Solved]

grasshopper

#1

Hi all,

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) :

Fig.1. A screenshot for your convenience :

So, does anyone have any idea which plugin it belongs to?

// Rolf


(Wim Dekeyser) #2

That one belongs to Kangaroo.
http://rhino.github.io/components/kangaroo/counter.html


#3

Hm, strangely enough I don’t find it using the search box. I will have to browse the panels then.


[Edit]: Is it that only Kangaroo1 have it then (I have Kangaroo2, and no component with that name exist there). :frowning:

// Rolf


(Wim Dekeyser) #4

That’s from the 0.099 version of Kangaroo, yes. (Released 2015-Apr-29)


#5

Food4Rhino seems to have only a version from 2014-Apr-03. ;

bild

But I’ll try to install it anyway.

// Rolf


#6

Here is c# code if needed4_Timer.gh (26.0 KB)


#7

Wow, thank you for your generosity! There’s only one little problem - it is written in Gh1.0, I use Gh0.9 (Rhino 5) for current development.

bild

// Rolf


#8

Yeah because I opened on Wip, but should work on both.

Anyway original 0.90076 version could be dowloaded here:


#9

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?

// Rolf


(Daniel Piker) #10

I just looked at the component Petras posted - it seems the text panel is disabled when first opening the file. When it is enabled it works fine.


(Daniel Piker) #11

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?


#12

Ah… there it was! I just couldn’t understand what this was all about. :slight_smile:

Thank you for pointing this out.

Probably not. Perhaps this should be on the list for being fixed.

// Rolf


#13

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).


#14

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.


#15

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);
    }

Running them side by side with your components:


Edit:

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?

// Rolf


#16

Do not care about fourth one. For the component compiled in visual studio you have to use this setup:

    private bool Running; //Global variable

    protected override void AfterSolveInstance()
    {
        if (!this.Running)
        {
            return;
        }
        GH_Document gH_Document = base.OnPingDocument();
        if (gH_Document == null)
        {
            return;
        }
        GH_Document.GH_ScheduleDelegate gH_ScheduleDelegate = new GH_Document.GH_ScheduleDelegate(this.ScheduleCallback);
        gH_Document.ScheduleSolution(1, gH_ScheduleDelegate);
    }

    private void ScheduleCallback(GH_Document doc)
    {
        this.ExpireSolution(false);
    }

       protected override void SolveInstance(IGH_DataAccess DA)
       {
  .... do setup here to reset and restart counter
        }

#17

Thank you @Petras_Vestartas for sharing your insights. I have implemented your code and it seems to run OK in a simple test case.

// Rolf


(David Rutten) #18

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:


#19

Too garish and distracting IMHO. Better to make the background 50-60% transparent and maybe also desaturate the text. Anyone else have any thoughts?


(David Rutten) #20

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.