Export an Image from SketchUp with Ruby (Snippet)

Export an Image from SketchUp with Ruby (Snippet)

The resulting image The following is a handy little Ruby tool if you frequently need to export the current view as an image in SketchUp. It basically allows you to pre-set all of the export parameters (including an export location) and keeps all of those consistent. Of course, this is not too hard with SketchUp itself (because it remembers the last used location and image parameters), but this script allows you to keep those parameters consistent even if SketchUp "forgets" them occasionally (i.e. after you work with a file in a different location). I use this script mainly when I need to create consistent images from many files, on which I work over an extended period of time. For that purpose, I have it set up as a menu item. In the example below, the image is exported as a JPG (just change jpg to png if you prefer that file format) at a size of 3000 px (with a 16:9 aspect ratio)....
Read More
Patterned Panel + Bending Extension = Cool Candle Holder

Patterned Panel + Bending Extension = Cool Candle Holder

A rendering of the candle holder Now that the days are getting shorter, it may be a nice home decorating idea to create a decorative candle holder. Having the powers of SketchUp and computational design methods as well as 3D printing at our fingertips, it does, of course, make sense to create something more interesting than just a boring lampshade. This brief example uses the patterned panel exercise from Chapter 7 to create the basic geometry. Of course you can replace the sinusoidal wave pattern easily now with another beautiful function, or you could even have the cutout pattern generated based on colors in an image, which allows you to make it look like a logo, landscape, etc. Since the resulting shape needed to have the pattern cut into a curved surface, there were basically two approaches: 1) create a curved surface and place the geometry onto it by arranging it radially (and then subtracting it), or 2) creating the panels flat and...
Read More
Using Images for Scaling and Geometry Patterns in SketchUp (Ruby Snippet)

Using Images for Scaling and Geometry Patterns in SketchUp (Ruby Snippet)

See which image I used to scale these blocks? This post was actually inspired by a question in my 3D Basecamp presentation: Could we use images to create or modify geometry in SketchUp? As it turns out, this is actually quite easy since SketchUp version 2018. This year's version of SketchUp includes a new class in Ruby, the ImageRep. Contrary to the regular Image class (which you can use to work with images as entities in SketchUp), the ImageRep class goes further and allows you to look at images on a pixel by pixel basis. This is basically what we need to be able to read pixel color values and then use those to create or modify geometry. TIP:Want to use this without coding? This script is also in one of the tools of my Scale By Tools extension. Exploring the Code As you can see in the code snippet below, this is reasonably straightforward once one figures out the basic geometric behavior. The code...
Read More
Beautiful Functions in SketchUp (Ruby Snippet)

Beautiful Functions in SketchUp (Ruby Snippet)

A wave of scaled boxes Scripting geometry (as described in Chapter 7) can make things look very interesting (and quite beautiful) with a rather small amount of actual code. You can see this in the patterned panel example or in the pulled brick post. Both of those examples use a combination of sine and cosine functions to create a "wavy" pattern that nicely undulates shapes and geometry. There are other functions, however, some of which you likely remember from algebra and trigonometry classes. But even without delving too deeply into this, I thought it would be useful to have a reference for some interesting functions that may be of use. TIP:Want to use this without coding? This script is also in one of the tools of my Scale By Tools extension. The interactive examples shown below use the following grid of 1 inch cubes in SketchUp that were simply scaled vertically according to the lines of code that are included at the bottom...
Read More
Pulled Brick Design Options (Ruby Snippet)

Pulled Brick Design Options (Ruby Snippet)

I came across brick wall designs today where the architects were considering various options with pulled bricks. This design approach has been used before in many different ways but the basic principle is always the same: In a brick wall that is dominated by stretchers, you insert strategically placed headers which then protrude a little bit beyond the brick wall surface. This creates a very nice pattern with interesting shadows. The first image below shows such a design in a SketchUp model: A wall with evenly pulled bricks Given that in reality these are placed manually it may be reasonably easy (and therefore not too costly) to vary the extend of their extension beyond the surface and thereby create more interesting undulating patterns. One such pattern is shown below: And one with a sinusoidal pattern As it turns out, this is very easy to do by simply modifying some of the scripts from Chapter 7 and combining coding with a carefully created SketchUp model....
Read More