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 />

TIP<br />

Whenever you define colors using RGB values, keep in mind that the maximum value for<br />

each of them is 255. Here are some sample colors:<br />

[0,0,0] # black<br />

[255,0,0] # red<br />

[255,255,0] # yellow<br />

[125,125,125] # a medium gray<br />

Figure 6.10: The newly created materials<br />

Creating a Small City<br />

Let’s try something similar now: Create boxes <strong>with</strong> a random height—and let’s call it a city.<br />

As you can see in the following code, we are just producing a 2D grid of boxes. This time,<br />

however, we are using feet as the dimension. And instead of giving all of the boxes the same<br />

height, we are now using Ruby’s rand method to randomize their height (between 100 and<br />

200 feet as you can see in Figure 6.11).<br />

# Creates a small random city<br />

ent = Sketchup.active_model.entities<br />

n = 10 # number of buildings<br />

s = 100.feet # spacing<br />

w = 60.feet # base width<br />

(0..n-1).each { |i|<br />

(0..n-1).each { |j|<br />

# add a face first<br />

250

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

Saved successfully!

Ooh no, something went wrong!