Automated A.I. vector graphics export from Grasshopper3d

If you spend 12 or more hours on an airplane travelling somewhere, it’s time to write something on your blog.

ghtoAi

 

I had to provide a sequence of transformations for a design at work, that could be easily manipulated by a graphic designer (change line-weights, color etc). So instead of exporting the typical raster image format from the slider animate, I wrote a small C# routine that enable to export any GH created Curve/line/ 1 dimensional object to a native Adobe illustrator file.

Parameters include: incremental export, layer name, directory to save and file name. I trust that many people will find this code snippet quite useful, as I have encountered many times this wish for vector graphics export instead of flattened images.

Please find the code and an example at the usual page.

automated_AI

Enjoy,

M.

Ps. SourceCode below:


 private void RunScript(List<Curve> curves, int series, string name, string layername, string filepath, bool execute)
 {

 #region Authorship
 //[Aytomated AI Export] was written by Marios Tsiliakos on 06 / 11 / 2014 in grasshopper 0.9.0076
 //This definition is for the pubic domain feel free to use it , share it and modify it, by providing proper citing. The author, Marios Tsiliakos of digitalsubstance.wordpress.com , makes no warranty, expressed or implied, as to the usefulness of the software and documentation for any purpose.If this tool is used for commercial purposes please notify the author. This work is licensed under a Creative Commons Attribution-Share Alike 3.0
 //for more information visit digitalsubstance.wordpress.com.
 #endregion

 if (!execute)return;

 else
 {
 //check
 for (int i = 0; i < curves.Count;i++){
 if ((curves.Count == 0) || (curves[i] == null))
 {
 Print("No curves or valid curves provided");
 return;
 }
 }
 //create alist of guids
 List<Guid> mycurves = new List<Guid>();
 // layer to bake the objects to
 create_layer(layername);
 //create a directory to store the ai files
 create_dir(filepath);

 for(int i = 0; i < curves.Count; i++){
 //declare the objects attributes
 Rhino.DocObjects.ObjectAttributes attr = new Rhino.DocObjects.ObjectAttributes();
 //set attributes
 attr.LayerIndex = doc.Layers.Find(layername, true);

 Guid id = Guid.Empty;

 //bake the curves
 if(curves[i].ObjectType == Rhino.DocObjects.ObjectType.Curve)
 {
 id = doc.Objects.AddCurve((Curve) curves[i], attr);
 }

 // add the curves to the mycurve_guid list
 if(id.ToString().Length > 0) mycurves.Add(id);
 }
 // select the curves in Rhino to successfully export them
 for(int i = 0; i < mycurves.Count; i++)
 {
 doc.Objects.Select(mycurves[i], true);
 }
 //where to save
 string save_directory = filepath + ("\\" + name) + series.ToString("0000") + ".ai";
 //and export them
 Rhino.RhinoApp.RunScript("-_Export\n\"" + save_directory + "\"\n _Enter", false);
 //delete the curves after exporting them
 for(int i = 0; i < mycurves.Count; i++) doc.Objects.Delete(mycurves[i], true);

To SHARE or not to SHARE. A dilemma.

sharing

I am an enthusiastic supporter of the “open source” culture/trend/society. I also believe that I have proven this over the years, by providing code – procedural designs and making them available for free to the public as many others do in this small computational design community. Most of the times, help has been successful, others less successful. A common factor though, to all of these cases is that I have never asked anything in return.

And that’s simply because I DON’T WANT ANYTHING IN RETURN. Never asked, nor will ask for in the future. (Although I have made a little experiment, see below).

You have to understand that I also do this for ME, for my own entertainment, for FUN, for becoming better. YES, you are becoming better by solving other people design / coding issues. Surely it’s not possible to encounter many different riddles, niggling situations and dead ends in your daily work routine. But, if you pick up from a collective pool of problems coming from other colleagues, professionals and students, certainly you have access to a wider range and a plethora of similar or dissimilar case scenarios. All these, are making me capable of seeing more, solving more and eventually enriching my design, problem-solving or mathematics, or complex geometry, or whatever you want to call it.
Have I asked for help? Yes! And I will definitely do it again.

Who’s asking? From my experience roughly 70% of the questions originates from the academic context. The other 30% from the industry mainly disguised to look like dummy questions. I don’t mind them at all, they are usually clearer, less blobby and more interesting to tackle.

Why am I mumbling about sharing?  To be honest I am feeling quite frustrated lately. At first I didn’t care about people’s ungratefulness and lack of manners, but I guess as you are getting older your tolerance hasn’t got the analogous effect, more like the opposite I would argue.
Not only that, people have become demanding. “Send me this file, I need it” , “do it working like this” ect.

I understand that maybe sometimes there are difficulties in the verbal or written communication, not native English speakers for example, but I believe there is one word that everybody knows of. That word is “please“. It’s not begging, it’s not loosing face, it’s simply asking someone politely.

This word, combined with another famous one, “thank you” can be pretty powerful when used in the same or in consecutive sentences. Trust me. I know.

I had a chat a few months back with two friends, fellow developers of a very successful free software, on whether we should license software or not. The answer was NO. Not only because we like to share stuff for free, but also because we are not exactly software developers, rather than a fusion between designers and programmers.  They were though frustrated by the arrogance and rudeness of firms asking to use their software for commercial purposes, hence making money out of it, and then denying sharing the projects where this software was implemented, with the developers, that only wanted to put them together in a paper for a publication.

In a funny way, you are awesome while you give something, but when you ask the simplest thing in return, something worthless, the same people that you’ve helped turn their backs on you without second thoughts. How proper of them.

The little experiment mentioned earlier in this text, is a paypal donation button I added to my website about a year ago. “ if you like our stuff and want to keep digital [sub]stance up and running please consider donating“. Eleven donations so far, most of them by students, roughly 5 $ each. Compared to 600.000 unique views, 6000 downloads of Nudibranch on the food4rhino website, and a total of 25.000 downloads of the shared scripts and procedural concepts shared  on box.net.

I would like to thank these few people, not for their money, as I said I am not expecting to make any money out of this. But because they felt they had to give something back. Although for me, a simple thank you is more than enough. But even this is hard to get.

The simplest and the academically appropriate method of saying “thank you“, is referencing. Professors ask for it, journals ask for it, conferences as well, so why on earth you don’t properly reference, people?? It costs nothing and it displays your integrity. It also indicates that you have actually conducted some research, that you are not a supreme human being, but you used something, cut it out on your own requirements and hopefully advanced this something to a greater level of importance.

I asked my students at exparch earlier this year to go out, research, study and use something that they found online but by properly referencing it. I know it’s impossible to learn how to code in one month, but if you study something enough to understand it, you’ve made a small step towards this goal. I didn’t even ask for something new, I just asked to understand the process and comprehend the reality that you have to reference anything you present.

It’s not that professors can’t keep up with new developments, new processes and research of others, which architecture students present as their own. That’s impossible. The problem lies deeper, into the fact that architecture, design and their visual output is something ambiguous and difficult to enclose within copyright boundaries.
Code and procedural thought, is not however. That’s why in my own naive opinion any kind of so wannabe called generative, algorithmic, parametric blah blah blah processes and its output SHOULD BE PROPERLY REFERENCED.

Conclusion

Please pardon my long introduction to this set of rules that I decided I am going to implement from now on, while sharing stuff online or helping on demand.

1. Help someone that asks politely.
2. ALWAYS help out someone that thanks in advance (quite a powerful set of words this one)
3. If you are helping out a student, ask for a cc to their professor tutor in the e-mail.
4. Never ask for people to reference your work even though you know that they’ve used your tools. Just blacklist them and do not help them again. Whether you can find them or not, that’s another story.
5. Do not help someone that provides nothing as a starting point, at 90% of the cases they are just too lazy to do something on their own and expect from others to solve their problems. Only guide them with references.
6. ALWAYS help with something that you are interested into, or seems intriguing.
7. Do not spend more than 3 answers explaining the same thing. More than three is probably useless anyway, your work is done there.
8. Let people know about google and website embedded search options. (Saves a lot of time)
9. Don’t give out stuff, give out the process. This is helpful for the other, to learn by replicating your thoughts!
10. Create a grading system, I found websites such Stack Overflow are quite successful on how they provide help for their users. I believe such grading systems make everyone’s life much better.

FYI: Even though this text might seem kind of offensive, but no means it consists a declaration of me giving up on people’s eagerness to learn, and I will always consider this my driving motto.

Written on a train towards London on Cinqo de Mayo.

M.

Tree Iterator – Animate GH Data Trees

forest_hike_icon_500new

Dear “Diary”,

I know it has a while since I last wrote. But I recently had a great opportunity to apply part of my research to actual build geometry, and for that I am grateful.

In the meanwhile I thought i should share in the form of a .gha assembly a routine that I use frequently to animate data that get into my hands from grasshopper definitions that use Hoopsnake and Anemone(Lately). The main issue with these data sets is that while these two add-ons are running, due to their intrinsic characteristics, is kind of difficult to animate their wonderful iterative and recursive formations.

Canvas at 00;48;58

So, to be brief, what ever formation you create with these two looping tools, you can now easily post-animate it and iterate through the various steps of the solution.

The component is fairly simple to use. Data as input and a few toggles for different options of iterating. It can either work with a timer or by a slider. You will find it under the tab “Extra”

I will post the gha file and an example here and I will also include it in the Milkbox group of the Grasshopper3d forum.

Please bear in mind that this component is probably full of bugs, which I plan to resolve in the future.There is a slight change to include a stable version of this routine in the next version of Nudibranch. Please use it “as is”, it does not come with warranties. Please give credit where credit is due according to the CC license of this website.

Suggestion, comments, criticism are always welcome.