Grasshopper

algorithmic modeling for Rhino

The following is a method for real time communication between Processing and Grasshopper. Although there are some of methods for doing so (spreadsheets, udp etc) this one is kind of simpler and easier, and its actual latency is minimal. We tried to use the least code/libraries and plug-ins possible, to send a 2d point array from P5, and reconstruct it in GH. In the same manner, one can send multiple different streams of data programmed in P5, and visualize them in Rhino. The reason for this is that -at least for me- its easier to program a behavior in P5 in the same way that is easier to associate and render geometry in GH.

We used OscP5 library and the Osc components from gHowl plug-in.

Follow the explanation written in the processing sketch. The GH diagram is based on gHowl examples.

Download links below (I am posting this as a discussion so that I can upload the files too)

Here’s a video of this:

(in the first sketch I translated P5's geometry to correspond to Rhino, the second has the normal Y values down geometry, so it looks mirrored. The first resets the values at click, in the second they get manipulated by the mouse. Both send the complete array every time "void draw" runs)

//thanks goes to my friend pk for his help

Views: 15485

Attachments:

Replies to This Discussion

Thank you for sharing this example!  Do you mind if I include it in the next packet of examples I post for gHowl? It is nice to have the points come in as clusters.

One thing, p55 and Rhino treat coordinates a bit differently.  Have you thought of correcting this for visualization?  I just ask cause you mention visualization in your description.  Perhaps fixing the coordinates would make for a more direct viz?  Just a thought.  Anyways, nice example!

Of course you can use it Luis.

in the video I show 2 sketches. The first one is the sketch I include. There i did draw these 2 lines, and did some PushMatrix (translate, scale(1,-1)) to make it look like the 4 windows of rhino. I explain that in the sketch file. One other thing is scale. I think most people use rhino in meters, but typical P5 coordinates are two digit at least, so one can put a scaling factor when passing the coordinates to GH. Something like:

string g+="{"+myPoint.x/scale+"," ...and so on

Did my answer cover you? or are we talking about different coordinate issues?

hi and thx for your help , i have a script on processing that its simulate somekinda substrate pattern i wanna make that pattern on grasshopper can you help me http://www.complexification.net/gallery/machines/substrate/ 
this is the site 

this is the code on processing 

Attachments:

you have to get the endpoints of each line and send them to grasshopper.

make a string that carries them , and make them in the form 

{x1,y1,0}*{x2,y2,0)/<next endpoint pair> etc..

then on grasshopper, split what you are getting with "/" to separate the string to pairs, and then with "*" to separate the points

finally make a curve with each pair of points. 

i'll see the sketch later, and tell you more precisely

i cannot open your attachment- access denied

Rar never works on Ning. Please attach files using Zip compression.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

sorry for that i didny khnow that , i,ve uploaded the zip file 

Attachments:

got it,

well you'll have to organize your points in lines (from the beginning to the end of the crack) if you want it to be tidy, otherwise you will have some hundred thousands of points in grasshopper > messy

calculate where the lines begin and where they break and send those points.

otherwise, if you want to send all the points make a new global string say

String forGH=""; //generate empty string

then under the line where you draw the crack <point (x1,y1)>

write forGH+="{"+str(x1)+","+str(y1_+",0}"+"&";

so forGH will be a giant string var, that has all your points in the form of {x1,y1,0}&{x2,y2,0)&.....

make a:

void keyPressed(){

if key='O'{

sendStringToGh();

}

}

void sendStringToGh(){

... something like

<new osc message.add (forGH);>

<oscmessage.send();>

}

this way when you press capital O on your keyboard it sends the string to GH

at grasshopper, get the data and feed them to a Split String component, with a panel that contains "&" the character that separates your points.

this will produce a list of points recognizable by GH. if you connect a point parameter their it will produce points, or you could add a circle, or sphere, with your points as centers.

see if it works this way. otherwise calculate the endpoints and send lines with a similar way. you will just need another separation character like

stringtoGH+=startpoint1 & endpoint1 * startpoint2 & endpoint2 *

hope it helps

constantinos

Hi, thank you for the code, it's a great help to start. But I wanted to ask, can you u send a 1D array with points instead of a 2D array?

And if possible how?

Thanks a million

Hi all,

Really interesting example. I tested the definition and it's working fine. 

I have a question: If I increase the number of points to send from P5 to GH seems the length of the message is longer than the maximum supported.

Is there any way to bypass this limit?

Thank you.

J

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service