I have been playing around with various AI programs to see what they can do. I though why not see if it can generate any code.
This is what I asked:
write ruby code to draw a 10’ x 10’ box in SketchUp. I did not specify any particular version of SketchUp. This is what it returned:
Define the dimensions of the box
width = 10.feet
height = 10.feet
depth = 0
Create a new group to contain the box
group = Sketchup.active_model.entities.add_group
Create the points for the corners of the box
points =
points[0] = [0, 0, depth]
points[1] = [width, 0, depth]
points[2] = [width, height, depth]
points[3] = [0, height, depth]
Create the face for the bottom of the box
face_bottom = group.entities.add_face(points)
face_bottom.reverse!
Extrude the face to create the box
face_bottom.pushpull(-depth)
Create the faces for the sides of the box
group.entities.add_face(points[0], points[1], points[2], points[3])
Refresh the view to display the box
Sketchup.active_model.active_view.refresh
Make sure you have SketchUp installed on your system and the Ruby console activated within SketchUp. Copy and paste the code into the Ruby console, and it will create a 10’ x 10’ box in the SketchUp modeling environment.
Create a new group to contain the box
group = Sketchup.active_model.entities.add_group
Create the points for the corners of the box
points =
points[0] = [0, 0, depth]
points[1] = [width, 0, depth]
points[2] = [width, height, depth]
points[3] = [0, height, depth]
Create the face for the bottom of the box
face_bottom = group.entities.add_face(points)
face_bottom.reverse!
Extrude the face to create the box
face_bottom.pushpull(-depth)
Create the faces for the sides of the box
group.entities.add_face(points[0], points[1], points[2], points[3])
Refresh the view to display the box
Sketchup.active_model.active_view.refresh
#Make sure you have SketchUp installed on your system and the Ruby console activated within SketchUp. Copy and paste the code into the Ruby console, and it will create a 10’ x 10’ box in the SketchUp modeling environment.
I ran it and it first said undefined variable depth
After reinstalling Ruby I got this error:
Code failed with an error: NameError: undefined local variable or method `response’ for main:Object
What is the AI program missing? How do I defined a local variable or method?
I don’t code myself in Ruby code, but I thought what AI was able to generate was sort of fascinating. Maby a little scary too.