Data Recorder Resetting Python Code

Hello everyone,

I am working on a custom undo cluster and I was wondering if I can make a GHPython component that resets the data recorder’s stored data. What I have in mind is to have 2 inputs connect into the GHPython component. First one a boolean value and the second one is the GUID of the Data Rec component. When a True value is received from the first input, the code will execute and reset the stored data in the Data Rec component.

I have seen some videos about setting sliders to different values with python code but I have no idea how to reset the data on the Data Rec component.

Any idea is welcome! Thanks for reading!

Hello again,

I found this code online which returns the GUID of the component that is connected to the input of the GHPython component that has this code.

    for input in ghenv.Component.Params.Input:
        print input
        for source in input.Sources:
            a = str(source.InstanceGuid)

Can I somehow get the GUID of the Data Recorder component using this code and then somehow using another bit of code reset the values in that particular Data Recorder component?
What I have in mind looks a bit like the screenshot. When I pressed the button I want the Data Recorder component to lose all its existing data. Is it possible? What else would you suggest?

DataRecorderReset

Thanks a lot.

Hi @Erdem,

Instead of trying to reset the obscure DataRecorder component - which is kept under closed wraps -, you could come up with your own Pythonic recorder that you would have total control over?

The data recorder could for instance be a custom class that gets stored in the sticky dictionary and reloaded from there every time the canvas refreshes/recomputes. You could simply delete it if you want to get rid of data. I’m sure somebody might have tried something like this before.

1 Like

Hello @diff-arch,

That’s a great idea!! I’ll work on it, thanks heaps.

You’re welcome. If you search the forum, there are lots of similar examples.

Will do, thanks again. :slight_smile:

Hi

I have been looking for a similar method to resetting the recorder’s output with a gh button, I managed to make it work with this python codes

I have two data recorder which I renamed both, that will be pickcked up by obj.NickName

3 Likes

As suggested by @diff-arch above, you can likely simplify/better manage things by also recording the data using GHPython. Here’s some examples demonstrating the basic ingredients you’d need:

Edit: Ah, sorry. You were posting a solution, need more coffee :yawning_face:

Thank you for this script. I do want to use this but unfortunately I do get an error:

Runtime error (ArgumentTypeException): ExpireDownStreamObjects() takes no arguments (1 given)

Traceback:
  line 31, in script

It is possible to fix this issue? I am using Rhino7 SR36 on a Windows machine.

Let me check, pretty sure it worked for me and I was using it for a while, but that was a year ago. Was using it on Rhino7 though, are you on R8?

I attached the gh code but I had to comment out the bits on ExpireDownStreamObjects(), but I swear it was working before, but looks like it can work without it too :rofl:

Let me if this is works for you.
GH_ResetRecorderWithPy.gh (8.2 KB)

Thank you for your effort, still not working. I do use the latest Rhino7SR37 on Windows11 machine.

This time no errors on the Python script but the DataRecorder itself shows a warning message saying: 1. Floating parameter Cycle failed to collect data

What happens when you click on the button again after clicking one of the reset buttons?

Weird things. It is not clearing the data in the panels only after pressing the Button again. If I connect the newly created empty panel at the end of the video to an existing panel, will inherit the data from the original panels.

The number of plugins you install… Amazing!!! :grinning: :grinning:

I don’t have enough screen space to display all of them. :grinning:


Works if you ignore the warning

I do found some scripts that works very well, unfortunately they do reset all DataRecorders from the document.

It is possible to adapt them to clear the data only in some specified ones?

ResetDataRecorders_c.gh (7.3 KB)

P.S. Found a solution that works:

        if reset_Cycle:
            obj.ClearData()
            obj.DestroyRecordedData()
            obj.ExpireSolution(True)

Thanks for sharing, so ExpireSolution is what I needed! Cheers

So if you change my original code to this then it will work.
image

the obj.Name == 'Cycle' and obj.Name == 'RecData' is where the code isolates to a particular data recoder by checking it’s name.

In my gh script, I have two data recoders named like this, so the py code checks and isolate which recorder to reset based on its name
image

So, in your gh script, you will need to do the same, ie: rename the data recorder as well as the py script, hope that make sense

1 Like

Yes, thank you for the explanation, that I figure-out by myself.