Grasshopper

algorithmic modeling for Rhino

Iam tottaly lame at scripting (learning), please tell me how to wait for each iteration of While loop to print (interval of 1000 ms).

System.Threading.Thread.Sleep(1000) causes Rhino to get a "lag" for all the iterations to get passed


Thanks !

Views: 2627

Replies to This Discussion

Hi Mateusz,

 

which "iteration"?

 

Thread.Sleep(int) will suspend the current thread for N milliseconds, meaning nothing whatsoever happens in this interval. 

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

i.e. :

 

Dim x as integer = 1

 

While x <= 10

x = x + 1

 

Print(CStr(x))

'I Want to print every x with interval of 1000 ms.

'So the list of values will update every second.

 

End While

 

While should be executed every second not as fast as its possible.

So list of values will look like : "1", after one second "1,2", after 2 seconds "1,2,3" etc.

Well, in that case Thread.Sleep(1000) is exactly what you need. Or do you want other stuff to continue happening in between?

 

If so, this is quite difficult. I could get into quite a long rant about timers and multi-task time-slices and threads and race-conditions and invokes, but if you want to make something which causes a new solution 1 second after the previous solution completed, you should have a look at GH_Document.ScheduleSolution (see attached).

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Attachments:
Ok, my fault. I want to do it in Grasshopper Script Editor, so it might be different ;]

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2025   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service