Dynamic Display Mode Attributes Rhino / GH

hex-grids_dif_widths_dsI dug out an old C# code snippet to change the display widths of curves in the Rhino viewport, by dynamically altering the visual style attributes.

It was an answer for a question on the Grasshopper3d forum (see the thread here), so I thought of tidying up the code and posting it here (probably just to convince myself that I still have the time to be posting things).

Not much to say, just change how your curves look in the rhino viewport through Grasshopper. I am sure that someone might find it useful.

Code in Python below and the file as usual at the [Sub]Code page.

d_disp_snap01_DS

#[Dynamic Display Attributes] was written by Marios Tsiliakos on 21 / 06 / 2015 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 www.digitalsubstance.wordpress.com.

import Rhino.Display as rd

# create some empty arrays
display_modes  = []
display_modes_names  = []
#retrieve the list of Display modes on the document
display_modes =  rd.DisplayModeDescription.GetDisplayModes()
#find out their names
for i in range(len(display_modes)):
    display_modes_names.append(display_modes[i].EnglishName)

#pick the display style that you want
for j in range(len(display_modes)):
    if display_modes_names[j] == mode:
        disp_index = j
    else:
        continue
selected_mode = display_modes[disp_index]

if execute == True:
    selected_mode.DisplayAttributes.CurveThickness = width
    rd.DisplayModeDescription.UpdateDisplayMode(selected_mode)
    print("Changed the display option settings for visual style :  " + y)
else:
    selected_mode.DisplayAttributes.CurveThickness = 1
    rd.DisplayModeDescription.UpdateDisplayMode(selected_mode)
    print(y+ " Display style reset to default settings")

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.