Grasshopper

algorithmic modeling for Rhino

Hi All.
I have been trying to find something related with my issue but I don't seem to get any light on this thing.

I am looking for a way to make a scripting component not only output the final state of the script but every intermediate state. For instance:

x as double = 1.0
y as double = 2.0
z as double = 3.0
pt as point

for i as integer = 0 to 100

pt = (i*x,i*y,i*z)

next

A = pt

If I do this, my vb component only outputs a point in (100,200,300)

How should I proceed, what should I add to my definition, if I wanted my component to show the point evolving trough i=0, i=1, i=2 ....i=100.

I have searched regarding "continuous redrawing, timer, solution update.." but I couldn't find anything dealing exactly with this.

Thank you very much!

Views: 567

Replies to This Discussion

Hi Roberto,

don't worry, it's nothing as complicated as timers or updates. All you need to do is store all your points as you make them, rather than overwriting the same pt value over and over again:

Dim x As Double = 1.0
Dim y As Double = 2.0
Dim z As Double = 3.0
Dim pts as New List(Of On3dPoint)

For i As Integer = 0 to 100
pts.Add(New On3dPoint(i*x,i*y,i*z))
Next

A = pts

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thank You David, but I guess I used an extremely simple example. In your code I would see a list of points, 100 to be precise, but what I look for is to see the point moving as i changes.

What I am willing to do is to get my components to reflect/output intermediate states in a converging process. I have a solver that seeks for a equilibrium state through a number of iterations and I would like that process to be shown in the viewport.

The most inmediate example of what I want to achieve can be seen in Daniel Pinker's videos of Kangaroo plugin where not only the final relaxed state is shown but also some the strings or meshes movement towards that state. I have broken my head to find a way to reproduce this but I didn't succeed.

That is why I thought of timers and engines and updates..

Blame it on me but I don't fully understand the way GH updates a solution.

Thank you very much!
Ooooo...kay. That's a whole different sack of eggs. Grasshopper assumes that the network of components results in a single solution. So the way it works is; it computes that solution, then displays the results in the viewport and takes a breather until the next solution is required.

If you want to do what Daniel has done, you somehow need to either short-circuit this process or take charge of it.

Basically, you do need a timer to refresh the solution (as we are now dealing with the concept of intermediate solutions rather than just final solutions (think "Spanish Inquisition" rather than "Holocaust")), and you need to somehow persist your data between solutions.

That last bit is the crux. You need to store your data outside the RunScript function, so that it doesn't get erased between solutions. You can use static (Shared in VB) members for this, or you could choose to store your intermediate data on a file somewhere.

Then, whenever the RunScript function is called, you need to operate on this static data, and update the output.

I attached a small example of this. You have to supply a bunch of points, then the VB script will move the Shared coordinates closer to the actual points.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Attachments:
Great!!! Very clear! I think now I wil be able to do it!
Thank you very much David, I will post the results!
I love it when a plan comes together.

Looking forward to the results.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
(think "Spanish Inquisition" rather than "Holocaust")

I really mostly read your replies for this kind of comment!

by the way roberto, check out Giulio's C# tools... he has some tools for doing what you are talking about.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service