19.12.2016 Views

Architectural_Design_with_SketchUp

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6 Creating Geometry Using Ruby Scripting<br />

Figure 6.23: Rendering of an entire building <strong>with</strong> attractor-based facade pattern<br />

Scaling Objects by Proximity<br />

Instead of coloring faces according to their proximity to an attractor, you could<br />

instead modify their geometry, for example, by scaling them. In this example,<br />

we take a wall that is made up of 4f × 4f slightly “bulging” wall panels and<br />

let the attractors adjust the panels’ thickness.<br />

The panels for this example are created from four edge lines using the<br />

Soap Skin & Bubble plugin. The component axis is placed at the back of the<br />

component definition, where the panels would be attached to a wall. (See<br />

Figure 6.24.)<br />

This code is very similar to the previous code, the difference being that<br />

we now use groups as attractors (two small boxes) and component instances<br />

as the objects that we modify. The only major change in the code is at the<br />

end, where we apply the scaling transformation. See Figure 6.25 for the Figure 6.24: 4f × 4f Wall panel component<br />

resulting paneled wall.<br />

Paste this code into the Ruby Code Editor, select the necessary objects in your <strong>SketchUp</strong><br />

model, and then click on Run:<br />

# Scale groups by proximity to component attractors<br />

sel = Sketchup.active_model.selection<br />

# Array <strong>with</strong> attractor center points<br />

attractors = []<br />

# Adjust this value to play <strong>with</strong> the scaling<br />

269

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

Saved successfully!

Ooh no, something went wrong!