algorithmic modeling for Rhino
I am strugling with something and I hope someone here can help. As a pretty seasoned grasshopper user I build a nice script generating glasses and Incorporated a UI with Human UI. I also, remarkably because I am a total noob, got Processing to take an Object (the glasses) and put them (somewhat) on my face in AR.
However this was from a baked and exported Obj. file. My ambition is to get a parametric version generated from grasshopper in my Processing file. If anyone has experience with this or could nudge me in the right direction I would be ever so grateful.
Could I stream the mesh attributes (faces, vertices) to a txt file and rebuild it in Processing?
yes you can.
I would use for that the spreadsheet writer component from gHowl. There might be better solutions out there though.
Could you point me at an example or something to follow in Processing for building up the mesh again. I am pretty clueless when it comes to processing
This is not really a processing forum, but there are plenty of resources you can find to process the data the way you want.
I know, but because there are probably a million ways to do this in Processing I thought there might be a way best for interaction with Grasshopper. Thats why I posted it here in the coding part of the grashopper forum.
Anyway, Thanks a lot for your help. I am going to look into to your suggestions
if you want to communicate between processing and grasshopper you should learn two things first:
Since Processing uses a java-dialect and Grasshopper can do c# you need to learn how to write and read files in java and c#. Both languages having very similar syntax, which allows you to nearly copy and paste statements. There are dozens of examples out there for both languages. Some keywords "System.IO", "Parse", "string.Format" etc...
When you write a file you could use a common file format for meshes like .stl, but I guess it would be easier to write Vertices, Faces and Normals out by yourself. This basically is nothing more than writing 3 lists of numbers out. However getting the information and interpreting the information in processing could be a bit more difficult as well, as long as you don't understand its library.
From the standpoint on difficulty its easy, but still its nothing to achieve within 10 mins.
thank man! great to hear the basics! Sorry If I am asking redundant questions but just to clarify. I stream the info (vertices, coordinates, faces) to a file (txt. or something) and I read that file in processing and build from there. And that will give me a dynamic solution, where processing will respond if grasshopper params change?
and I need to get all the syntax right, off course :D
AFAIK the gHowl component is dynamic. if that's the case you just need to figure out how to do the same for txt->processing. That should be possible but I don't know what the exact solution is.
Reading a txt file and reconstructing the data yourself would definitely be the way you want to go rather than just purely importing an .obj file exported from grasshopper (where in this case you might have to export/import/run manually for each instance)
That might be the path of least resistance, but can be slow depending on your use-case. You can export to an obj file (a text file format representing an vertex-face mesh) from a scripting component. This could be done either by writing your own exporter function that iterates the mesh vertices/faces and writes them line by line to a file using the obj formatting (should be pretty simple), or, by adding the mesh to Rhino document and then scripting the Rhino export command (remember to delete the mesh again). You can then import this obj file using the loadShape() function in Processing (if I recall correctly, otherwise I'm sure there are libraries for this, check the Processing forum to learn more on this).
Edit: Tom already answered a lot of this :)
this is a briliant idea, I have the loadShape function working at the moment. Great! Thanks to everyone for all the quick and insightful help!!!
I will let you know how it works out