19.12.2016 Views

Architectural_Design_with_SketchUp

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Architectural</strong> <strong>Design</strong> <strong>with</strong> <strong>SketchUp</strong><br />

Length Units in <strong>SketchUp</strong><br />

Because <strong>SketchUp</strong> works <strong>with</strong> actual dimensions for lengths, locations, and so on, it is important<br />

to understand how to use them in Ruby Scripts, too.<br />

Many examples in this book use plain numbers such as [10,10,10]. Since <strong>SketchUp</strong>’s<br />

default unit is the inch (independent of which local version you are using!), these numbers<br />

default to inches. Therefore, “10” automatically means “10 inches” in the software.<br />

If you are using a combination of feet and inches or are working <strong>with</strong> a different unit<br />

system altogether (e.g., using meters in the metric or SI system), you must enter units differently.<br />

One method is to give <strong>SketchUp</strong> the length, including its unit, as a string. Fortunately,<br />

there is a built-in method (of the Length object) to_l, which attempts to convert any length<br />

to <strong>SketchUp</strong>’s internal default unit. Here are some examples:<br />

new_length = “1m”.to_l<br />

=> 39.3700787401575<br />

new_length = “2’6”.to_l<br />

=> 30.0<br />

Alternatively, you can use some of the methods of the Numeric object. The following is<br />

a complete list of all of its methods:<br />

Numeric (Parent: Object)<br />

.cm .degrees .feet .inch .km<br />

.m .mile .mm .radians .to_cm .to_feet<br />

.to_inch .to_km .to_l .to_m .to_mile<br />

.to_mm .to_yard .yard<br />

Examples of this approach are as follows:<br />

2.cm+4.inch<br />

=> 4.78740157480315<br />

(24).to_feet<br />

=> 2.0<br />

Links to Further Reading<br />

The following list features books and websites that you can use as further reference for both<br />

the language Ruby and <strong>SketchUp</strong>’s Ruby API. Keep this list handy as a reference.<br />

For Ruby:<br />

NN<br />

Clinton, Jason D. Ruby Phrasebook. Boston: Pearson Education, 2009.<br />

NN<br />

Fitzgerald, Michael. Ruby Pocket Reference. Sebastopol, CA: O’Reilly Media, 2007.<br />

NN<br />

www.ruby-lang.org/en—The main website for the Ruby language.<br />

244

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!