How to pull the arc to make a small cut out

Newbie here. I want to create a table top with an arc cut. I already successful create the top with the arc line. However i cant figureout how to push/pull the arc face to create the cutout

Here the code

#Draw Rectangular Top Cutout

ent = Sketchup.active_model.entities
main_face = ent.add_face [0,0,0], [0,1200.mm,0], [600.mm,1200.mm,0], [600.mm,0,0]
main_face.reverse!
main_face.pushpull 25.mm

#Draw cutout
cut = ent.add_arc [0,600.mm,25.mm], [0,-1,0], [0,0,1], 30.mm, 0, 180.degrees
cut.faces[1].pushpull -25.mm

Here the error message

Error: #<NoMethodError: undefined method `faces' for #<Array:0x00000010a18258>>
<main>:9:in `<main>'
SketchUp:1:in `eval'

add_arc returns an array of edges, not a singly edge or arc object. To get a face bound by the arc you need to get an edge, e.g. the first one in the array, and then use the faces method on that.

Btw, if you use parenthesis around the method arguments the code becomes much more readable.

Thank you eneroth.
How can i fix the code. I need to change the arc to faces 1st ?
I just start learning ruby.

As @eneroth3 says adding an arc does not create faces automatically.

The foolproof way is to make the 2d face with the cutout and then pushpull it…
Try something like this:

main_face = ents.add_face([0,0,0], [0,1200.mm,0], [600.mm,1200.mm,0], [600.mm,0,0])
main_face.reverse!
arc = ents.add_arc([0,600.mm,0], Y_AXIS.reverse, Z_AXIS, 30.mm, 0, 180.degrees)
arc[0].find_faces
faces = arc[0].faces
face_to_go = faces.delete(main_face)
edges = face_to_go.edges
face_to_go.erase!
edges.each{|e| e.erase! unless e.faces[0] }
arc[0].faces[0].pushpull(25.mm)```
1 Like

I see you are already well-served.

One addition, since you say you started with ruby: Learn to read error messages and solve them step by step.

  1. This error wants to say that cut is an object that does not have a method faces. So the previous method returned something different than you thought.

  2. Find out what object you have:
    cut.class
    gives Array,
    and
    cut.inspect
    gives
    [#<Sketchup::Edge:0x000000145d3b30>, #<Sketchup::Edge:0x000000145d3b08>, ...]

  3. Look up in the Ruby and SketchUp documentation what the original method actually returns:
    Class: Sketchup::Entities — SketchUp Ruby API Documentation
    and what methods are available for this object:
    Class: Array (Ruby 2.2.4)
    Class: Sketchup::Edge — SketchUp Ruby API Documentation

3 Likes

Thank you for all the answer. I’m using the “Automatic Sketch” as a reference.

The code i refer to from the book. Maybe this work because of the line instead of arc.

Create the box
ent = Sketchup.active_model.entities
main_face = ent.add_face [0,0,0], [6,0,0], [6,8,0], [0,8,0]
main_face.reverse!
main_face.pushpull 5

Draw a line across the upper-right corner
cut = ent.add_line [6,6,5], [4,8,5]

Remove the new face
cut.faces[1].pushpull -5

This topic was automatically closed after 91 days. New replies are no longer allowed.