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.

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

As you can see in Figure 6.21, this little snippet can add quite a bit of realism, especially<br />

to natural objects like trees.<br />

Figure 6.21: Randomized rotation and scaling (left: before; right: after)<br />

To create this effect, the code first takes the entire Selection collection and iterates through<br />

each element using sel.each. It then checks that the current element is a ComponentInstance.<br />

You could apply this to all kinds of entities; however, transform! is a method that works only<br />

for the ComponentInstance object. You would have to modify the transformation slightly<br />

for other objects.<br />

Next, the code finds the center of the bounding box of the component as well as the<br />

center of its base. To find the base center, we needed to calculate the height of the box and<br />

then subtract half the height from the z value.<br />

Finally, we define two transformations, one for rotation and one for scaling, and combine<br />

them by multiplication. As you can see in the code, two variables allow you to modify the<br />

maximum rotation angle as well as the maximum size variation (as a ratio). Experiment <strong>with</strong><br />

these values until you get the results you are after.<br />

Attracted to Attractors<br />

The following examples show how you can modify geometry based on proximity to some<br />

other object (or any relationship you can think of, such as “height from ground”). This often<br />

yields very interesting designs and lets you express relationships visually in your designs.<br />

At the minimum, what is required to make these examples work is (1) some geometry<br />

that you intend to modify and (2) one or more objects that act as attractors, on which the<br />

modification is based. A good example of the first is a facade panel whose color or shape<br />

you intend to modify. It doesn’t have to be a face, though—you could instead use a group<br />

or a component instance.<br />

266

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

Saved successfully!

Ooh no, something went wrong!