How to pull the arc to make a small cut out

pushpull
ruby
cut

#1

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'

#2

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.


#3

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


#4

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)```

#5

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:
    http://ruby.sketchup.com/Sketchup/Entities.html#add_arc-instance_method
    and what methods are available for this object:
    http://ruby-doc.org/core-2.2.4/Array.html
    http://ruby.sketchup.com/Sketchup/Edge.html


#6

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


#7

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