Hello All,
I’m able to create a 5-second timebuffer in Ghpython, However, I need to run it on a separate thread but with no luck! Is this even possible? I’m trying to replicate the Time Buffer component from Anemone that doesn’t work for me as well.
import time
data = x
buffer = []
buffer. Append(data)
time. Sleep(n)
a = buffer. Pop(0)
now attempting to run it on another thread using the threading module, doesn’t work for me.
import threading
import time
def delay_data(data, n):
buffer = []
buffer.append(data)
time.sleep(n)
a = buffer.pop(0)
print(a)
t = threading.Thread(target=delay_data, args=(data, n))
# start the new thread
t.start()
Would something like this be what you’re after?
buffer.gh (5.4 KB)
def schedule_solution_callback(doc):
ghenv.Component.ExpireSolution(False)
doc = ghenv.Component.OnPingDocument()
doc.ScheduleSolution(int(s) * 1000, schedule_solution_callback)
modified from this older post
Edit: I might have been a bit late here
1 Like
not late at all I still work on my script, It works now, I will test it out tomorrow on my big script,
Big Thank you @antoinemaes
1 Like
I haven’t tried set it up to 0, but if I had to guess it would probably be pain
You might want to set a base case to avoid 0 second input !
If set it to 0 you will force close rhino. I figured it out and set up a condition where s value cannot be less than 1ms.
I’m tested on a complex script that I made to analyze Daylight and energy and generate charts … Then this trigger to take a viewport capture once the solution is expired.
Very handy and I’m going to include it in real practice today.
@antoinemaes , is there away to make it expire after one run? I’m trying to have this script to wait 5 seconds once my definition solution is complete so I can make sure the viewport display is updated then the script will Generate a “True Boolean” so I can use it to capture my viewport.
currently it works the way it Takes a viewport capture every five seconds forever!
@AndersDeleuran just posted something very similar to what you were looking for here
Here is a small adaptation of his script for your case
It also works with a Target of 1 (as “one True value after the Interval”)
buffer.gh (5.3 KB)
2 Likes
works beautifully!
Thank you @antoinemaes