Solutons Lounge

How to round the corners of a tabletop in SketchUp using a Ruby script? – Ruby API


There are serval problems:

These coordinates not in a same plane.
it should be

[0, 0, 0], [width, 0, 0], [width, height, 0], [0, height, 0]

Again a coordinates are wrong for the centre, first for simplicity, I would define like:
center1 = Geom::Point3d.new(radius, radius, 0)
The normal of the arc also wrong.

The #add_arc method Returns:

an array of Edge objects that define the arc.

You can not add a face to that, you need to give a Array of Sketchup::Vertex or Point3d

You can get the vertices of the curve, if you take the first edge of arc array, retrieve its curve and get its vertices.
Then you can map the vertices position and need to add an ORIGIN for start and end point of loop to be able to create a face.

model = Sketchup.active_model
entities = model.active_entities
model.start_operation('Create Wall and Arc', true)


width = 50.cm
height = 90.cm
thickness = 2.cm
radius = 2.cm

rect_face = entities.add_face([0, 0, 0], [width, 0, 0], [width, height, 0], [0, height, 0])
rect_face.pushpull(-thickness)

center1 = Geom::Point3d.new(radius, radius, 0)
arc = entities.add_arc(center1, X_AXIS.reverse, Z_AXIS, radius, 0.degrees, 90.degrees, 12)
vertices = arc.first.curve.vertices
arc_face_points = vertices.map(&:position).unshift(ORIGIN)<<ORIGIN
arc_face = entities.add_face(arc_face_points)

arc_face.pushpull(-thickness)

model.commit_operation



Source link

Exit mobile version