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

sel.each do |e|<br />

# First check if this is a face<br />

if e.typename == “Face”<br />

# Then extrude it<br />

e.pushpull rand(100)<br />

end<br />

end<br />

This time, we are not adding anything to the Entities collection (which is why there is<br />

no ent in the code). Instead, we are using what we have selected by employing Sketchup.<br />

active_model.selection. As shown in Figure 6.12, the faces extruded randomly.<br />

Figure 6.12: Randomly extruded faces<br />

As evident in the code, sometimes it makes sense to check the type of entity you have<br />

selected before you do anything to it (thereby preventing errors). This is done using the typename<br />

method, and some possible entity types are Face, Edge, ConstructionPoint, ComponentInstance,<br />

and Group.<br />

252<br />

Using Formulas for Patterned Panels<br />

Scripting geometry becomes especially effective (and beautiful) when we use a nonlinear<br />

formula to define size, position, color, and so forth. The next piece of code creates a rectangular<br />

grid of circles on the x-y plane (the ground) where the circle size is determined in two<br />

directions by a sine function.

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

Saved successfully!

Ooh no, something went wrong!