Interesting AI generated Ruby Code example

AutoLISP & Lisp ("stupid parenthesis land’) are a functional language (ie, every expression is a function call,) whereas Ruby is a more modern multi-paradigm dynamic object-oriented language. Really, take a few minutes to read some of the primers linked to in my resource list. (Warning, … you might become addicted to Ruby!)

Again, please correctly delimit the code block in the 1st post so we can at least read it as code.

Basically, the AI (I think) does not read the SketchUp application release notes nor the API release notes. This is indicated by it’s not putting a condition upon reversing the initial face created on the ground plane. In the recent 2021.1 release, SketchUp was changed to stop making faces on the ground plane facing down. Since, it now creates “butter-side up” faces, the face_bottom.reverse! statement should be conditional, ie:

face_bottom.reverse! unless face.normal.samedirection?(Z_AXIS)

Another glaring error is that the pushpull operation has already created the other sides of the box. So, the following comment and “side” face generation statement is erroneous.

Thirdly, the view.refresh method is strongly discouraged by the API documentation and also is not necessary to display the changes.

The most glaring error is that the AI did not wrap the code within an undo operation.


The code (as posted) looks weird. It looks like part of it was posted twice.
The points array and the group need only be created and push-pulled once