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

t2 = Geom::Transformation.rotation instance.bounds.center,<br />

[0,0,1],<br />

angle.degrees<br />

instance.transform! t2<br />

}<br />

end<br />

}<br />

There are a few more parameters in this code than we had before (brick spacing in both<br />

directions, number of bricks, and opening angle), but this gives you the flexibility to experiment<br />

<strong>with</strong> them and generate variations in the results.<br />

In the code, we first check that the selected item is actually a ComponentInstance. Next,<br />

we iterate through each horizontal and vertical brick placement. In this iteration, we use a<br />

translation transformation to place the brick and then we apply a rotation to the new component<br />

instance. This allows us to rotate the brick “in place.”<br />

Figure 6.18 shows a rendering of a generated wall.<br />

Figure 6.17: Single selected brick and generated wall<br />

Figure 6.18: Rendering of generated wall<br />

Placing Components on Faces<br />

262<br />

In this example, we take a component (a simple circle) and copy it<br />

onto the center of each selected face of some existing geometry.<br />

To make the code work, prepare the component first: Create a<br />

circle and turn it into a component using <strong>SketchUp</strong>’s standard<br />

tools. Edit the component so that the circle is centered on the<br />

component’s coordinate system, as shown here.<br />

Create any shape you like that has faces. In my example, I<br />

created a shell using the Extrude Edges by Edges tool from the<br />

Extrusion Tools plugin (see Chapter 4). Figure 6.19 shows both<br />

the single component and all ungrouped faces selected and<br />

ready for the code to do its magic.

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

Saved successfully!

Ooh no, something went wrong!