Smoothing edges when creating faces in a loop

You can save yourself some tedium …

pt0 = [
  [ax, ay, az],
  [bx, by, bz],
  [cx, cy, cz]
]

face = entities.add_face(pt0)

The Edge#faces method returns an Array and it’s #size method returns the number of elements in the array.

So the full expression is a boolean test whether the edge is shared between 2 or more faces.

The subpart edge.faces.size is known as call chaining where multiple methods are called, each upon the result of the previous method call.

FYI, the SketchUp API Array documentation only lists the extra methods that the API adds to the Ruby Core Array class. For all the core methods, you need to refer to core Ruby docs …

  • Array
  • Enumerable is mixed into most all other collection classes, both core and of the SketchUp API
2 Likes