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.9: Boxes colored in the full spectrum<br />

As you can see, adding a color (a “material”) to a face is very easy, too. You just need<br />

to use one of the two related methods of the face object: material for the front side and<br />

back_material for the reverse side. As before, the reverse side (the blue side) is pointing in<br />

the direction of our extrusion, so we need to apply the material to that side.<br />

Materials can be applied as a reference to a material that is already installed in <strong>SketchUp</strong><br />

(check for these in the Materials window), as a color name, or—as in our case—as a color<br />

defined by RGB (red, green, blue) values. The following are all valid material assignments<br />

(assuming that mat1 is a material that was previously defined in your code):<br />

face.material = mat1<br />

face.material = “red”<br />

face.material = 0xff0000<br />

face.material = “#ff0000”<br />

face.material = Sketchup::Color.new(255, 0, 0)<br />

face.material = [1.0, 0.0, 0.0]<br />

face.material = [255, 0, 0]<br />

face.material = 255<br />

One thing that you will notice when you create and use a lot of different colors is that<br />

<strong>SketchUp</strong> will have to add all of them to the already defined materials, which might take<br />

some time. You can always review the result of your creation in the Materials window under<br />

In Model by clicking on the house symbol (see Figure 6.10).<br />

249

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

Saved successfully!

Ooh no, something went wrong!