Grasshopper

algorithmic modeling for Rhino

I started with a little simpler evolutionary system of agents randomly placed on a field of Cells (1*1 static squares that describe location for agents) and Zones (larger squares that can count how many Agents are within it after each iteration and their centroid attract Agents). So, I basically came up with a small .dll where I wrote classes for Agent, ZOne, Cell and SystemSetting. I reference this .dll into my VB component but then the majority of the functions and subs that describe this system interaction are written directly in this VB component. 

The system works fine, but I cannot achieve the effect of having the system to redraw after each iteration. For example :

'''////////////////////////////////////'''
Call InitializeEverything()


For i=0 to 19   'say, Iwant to run my system for 20 times

Call UpdateZones()  'updates attractor values of Zones
Call RelocateAgents() 'say, code that does all the evolutionary job

Dim agentSrf As New List (Of OnNurbsSurface)  'want to collect the surface_
representation of all agents and visualize it

For j= 0 to agents.count-1
agentSrf.Add(agents(i).MySurface() 'collect the Agent representations
Next

A=agentSrf
Next
'''////////////////////////////////////'''

So, in this case I will only see the surfaces of the agents after this last iteration. I was trying to use timer and target my VB component but I have my initialization function there as well so it just reruns everything from the very beginning. Or I tried to:

A=agentSrf
System.Threading.Thread.Sleep(5000)

but this didn't give me much either.

I'm sure that there is a relatively simple solution to that but I cannot find it.

Would you please give me your thoughts on that?

Thanks A lot,

Dima

Views: 539

Attachments:

Replies to This Discussion

No, there's no relatively simple solution at all. Grasshopper won't redraw until all components have completed computing. So doing stuff inside a loop in a VB component will never result in an animated preview.

Your two basic options are:

1) use a Timer to update the VB component, and make it smart enough so it can handle consecutive calls.

2) write code that runs outside of the RunScript() method, then you can place a call to NewSolution() on the active GH_Document inside every iteration. You'll need to know a fair bit about how the core of Grasshopper works.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thank you, I think I got a general picture of that. I will try to come up with something.

"You'll need to know a fair bit about how the core of Grasshopper works." - do you think there is some documentation available that you could point me to?

Again, thanks a lot!

Dima
There's nothing available now apart from the xml source comments. In fact, I'd rather add any additional docs into the comments, I like having things all in one place. We'll start distributing an SDK help file along with 0.7

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hey Dima,

any luck with the agent code ?

there is another discussion in which david gave an example of his suggestion above:
http://www.grasshopper3d.com/forum/topics/reflect-steps-in-a-loop?c...

let me know how its going, im trying to write something similar.
hi brendon,

yes, I finished that thing a while ago in the spring. You can see the results on my blog.
You can download the .dll and GH definition
Thanks for the link to the discussion

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service