GH Unit Conversion Script

06Aug11

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

 

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

Advertisements


No Responses Yet to “GH Unit Conversion Script”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: