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

# Place a copy at the center of the bounding box<br />

center = e.bounds.center<br />

t = Geom::Transformation.new (center, e.normal)<br />

new = ent.add_instance (comp, t)<br />

# Now scale objects by some criteria<br />

new.transform! Geom::Transformation.scaling center,<br />

center.z/100<br />

# Explode it so that we can remove the face afterwards<br />

new.explode<br />

}<br />

end<br />

When you run this code, it first looks through your selection and isolates the one<br />

ComponentInstance (the circle). Then it iterates through each face and places a new instance<br />

at the center of the face. It does this by finding the center point using the bounds.center<br />

method of the Entity object (which gives the center of the bounding box). The new instance<br />

is then placed <strong>with</strong> its orientation (its “normal” vector) aligned <strong>with</strong> the face’s normal vector<br />

(which describes the direction perpendicular to the face).<br />

A scaling transformation is applied to the circle, which varies the circle’s scale by how<br />

far away from the ground it is. This results in small circles (“openings”) at the base of the<br />

shell and the largest ones at the apex. As a last step, the component instance is exploded,<br />

which lets us remove the circle’s faces manually, leaving nice circular openings in the shell.<br />

The result is shown in Figure 6.20.<br />

Figure 6.20: Rendered view of canopy after removal of circle faces<br />

264

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

Saved successfully!

Ooh no, something went wrong!