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);
Advertisements

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.

Nudibranch | Add-on for Grasshopper3d

nudibranch_icon0001

Long time no see. Been very busy in the last couple of months…:( However I am particularly happy about this post. For the past month I had the chance to work on something that has been on my mind at least two years now. And finally the time has come when I manage to publicly release Nudibranch  a new Add-on for Grasshopper3d.

What is a Nudibranch????????? Specifically Glaucus Atlanticus..

The Nudibrach Add-in for Grasshopper3d is a set of components facilitating and automating Grasshopper’s capacity to generate distance-based value fields, in addition to moving particles through attractor defined vector-fields while creating animated simulations of these particles.

In particular, Nudibranch aims to automate the attractor development process (one or multiple), while covering most of the frequently used cases, without however intending to replace or render useless the basic understanding of how attractors operate. Furthermore, three animation components enable the real-time interaction between attractors and the affected data.

Since this is the first release of Nudibranch and it might still contain  bugs. Please use it “as is”, it does not come with warranties. Please give credit where credit is due according to the license file.

You can download Nudibranch from the  Food4Rhino website, along with other useful plug-ins.

A brief documentation and generic examples are also included in the download folder.

I plan to share my experiments with Nudibranch through this blog and via the Grasshopper community group. If you create an interesting design, or even better if you want to share some feedback and your thoughts on Nudibranch just drop a line. It will be really appreciated.

Finally I would like to thank Mateusz, Michael, Andrea, Angel, Arthur, Angel, Tudor for testing Nudibranch out and shared their valuable feedback…

Enjoy,

M.

nudibranchtestnudibranch001enudibranch0012enudibranch0y012e

Creative Commons License

Nudibranch Copyright (C) 2013 by Marios Tsiliakos is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.

Permissions beyond the scope of this license may be available at www.digitalsubstance.wordpress.com.