Grasshopper

algorithmic modeling for Rhino

Hey all - 

 

While working on a project I came upon the need to do some unit conversion within GH, so I decided to write a script to handle this. I've attached it as a user object. It takes two strings, defining the input and output unit systems, in the form of "mm" or "in^2" or "yd^3" etc. It will then output the necessary conversion factor. It also optionally accepts a list of values, and will convert them for you if they are present. 

 

A word of caution: I have not tested this thoroughly, so it may produce some weird results - but so far it seems to work for me. If you catch a bug, please let me know! Also, please pay attention to the "out" stream - it will alert you to an error if there is a problem with your input. Even if there are errors, the component will produce numerical output, so if you blindly trust the results without checking the error output you may be working with erroneous values. 

 

Finally, if you take a look at the code, please don't judge too harshly! I am an entirely self-taught programmer, so I am sure my code is inefficient and messy and misses a lot of best practices. If you do see something that could be improved upon, let me know; I am always eager to learn.

 

Download it here: Unit%20Conversion.ghuser (or here: UnitConversion.gh)

 

cross posted at my blog: http://heumanndesigntech.wordpress.com

Views: 2447

Comment

You need to be a member of Grasshopper to add comments!

Comment by Andy Payne on August 8, 2011 at 4:37pm
Nice Script.
Comment by Ángel Linares on August 8, 2011 at 3:36pm

It wasn't my intention to create a heated discussion...but everytime I see people spending their time converting numbers I get mad.

 

Anyway really nice effort and plugin to GH. Without this kind of tools would be really complicate understand other people designs.

 

Best Regards.

Comment by Arthur Mamou-Mani on August 8, 2011 at 8:53am

Thanks Andrew,

Guess I missed this whole thread with the user object:

http://www.grasshopper3d.com/forum/topics/grasshopper-070030-available

Comment by Andrew Heumann on August 8, 2011 at 8:35am

Hey Arthur - 

 

Here are some images of the unit conversion script in action:

 

And as for the .ghuser file - it's what gets created every time you save a user object to your toolbar. If you go to file/special folders/user objects, you'll see where they get stored.

Comment by Arthur Mamou-Mani on August 8, 2011 at 8:20am

Thanks Andrew,

It's the first time I hear about a .ghuser file! It's great thoguh, how did you save it as such?

The unit conversion script is a very political one ! A little English/French flag might be necessary as logo :) http://www.youtube.com/watch?v=9V7zbWNznbs

Could you post a print screen of how to use it? 

Cheers,

Arthur

Comment by Andrew Heumann on August 8, 2011 at 8:06am
well gosh, who'd have thought an innocent script could provoke such a heated discussion! ;) And Arthur, the file is not a .ghx, it's a .ghuser - if you'd rather not add it to your user components I've also posted a link to a .gh version above.
Comment by Danny Boyes on August 8, 2011 at 5:31am
That and the fact that I'm ignoring the elephant in the room
Comment by Arthur Mamou-Mani on August 8, 2011 at 4:55am

Danny you're so very English blaming Liberia ;)

I think the expression "Imperial Unit" says it all !

 

Comment by Danny Boyes on August 8, 2011 at 3:56am

@Arthur, I would say it's not the Anglo-Saxons holding the metric system back. As you can see from the image below its Liberia in West Africa.

Countries by date of metrication. Colours red to green show the pattern of metrication from 1795 to 1998. Black identifies countries that have not adopted the metric system as the primary measurement system. White identifies countries that already used the metric system at the time they gained their independence.

Comment by Arthur Mamou-Mani on August 8, 2011 at 3:13am

Hi Andrew, Thanks so much for this very helpful tool which would deserve a plugin ! I changed the extension to ghx and opened it with GH 0050 but got the following error:

@Angel, I really agree with you and would love one currency too... But the metric system has one problem for the anglo-saxon: they believe it is french and moreover, imposed by Napoleon like being on the right side of the road...

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