Grasshopper

algorithmic modeling for Rhino

Hello...a colleague is wondering how to do something in Python that I normally do in VB, which is to create a variable whose value persists in conjunction with an attached timer. A simple example would be a timer-related counter, that gets reset with a boolean but accumulates over time. Does anyone know to achieve the equivalent of something like this in Python:

Private Sub RunScript(ByVal R As Boolean, ByRef A As Object)

If R = True Then
Counter = 0
End If

Counter += 1

A = Counter

End Sub

'<Custom additional code>

Dim Counter As Int32

Views: 4393

Replies to This Discussion

Hello David,

Take a look at this discussion. I think Anders and myself have covered pretty much most of the functionality existing there.

ps. nice pics from Berlin on facebook.

 Best,

M

Thanks Marios...didn't see this one when I searched the site.  And double thanks...yes, the Symposium was fantastic. Tons of ideas and inspiration from people doing amazing things!

Nice!

Unfortunately I didn't have time to attend, next year probably.

I guess this officially makes it 1-0 to you Marios ;)

Anyhow, the scriptcontext.sticky is really useful for saving, updating and passing around data within one or more Python components, one or more GH definitions or even between GH and Rhino. Attached a fun little "sketching" example, note that there is absolutely no reason to have two components in this case..

Attachments:

heheheh!

Nope the score is still nil. I think that the clearest rule of our little game is to beat the other by a few seconds or minutes. Seeing something after a long time when the other has already answered doesn't meet this criterion.

either way I didn't actually provide a solution rather than referencing an old thread.

So let call it a tie.

:)

Agreed, can't believe I already forgot the rules ;)

Well, my question is a bit related to this discussion, so I will post it here. 

Do you guys know why my script runs quite slow even with timer set to 1ms, but whenever I rotate the camera in the Rhino viewport, script starts to run really fast and fluently ? I was suspecting nvidia gfx ,but I've turned it off (tried all options) and the problem still remains. I even tried without timer (if run = true then expiresolution), but it behaves the same as with timer.... Also, I've switched to integrated gfx and still the same. It's quite frustrating, I can see that for instance in Daniel Piker's videos kangaroo runs in real time, and same def is really sloppy on my pc.

http://www.grasshopper3d.com/video/refresh-rate-problem

In this video you can see the difference.. when I right-click the viewport, circles start to move much faster (the video is not that fluent cause of shitty desktop recorder).

The redraw of Rhino viewports can cause a significant delay in any iterative cycle. However while viewports are being rotated or zoomed or panned, Rhino switches to a faster display algorithm which is less accurate. This may account for what you are seeing.

--

David Rutten

david@mcneel.com

Tirol, Austria

Ha ! Thanks. Still - is there a way to put rhino in this state from grasshopper code? Maybe even with a bit cheating ?

Yeah I'm going to look into that for GH2.

--

David Rutten

david@mcneel.com

Tirol, Austria

Well didn't see that coming. Makes perfect sense.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service