How to transform curve vertices?

We’ve been discussing this in the new API issue thread, where @Fredo6 has reminded us of the Curve#move_vertices method.

In your “g.skp” model, all the vertices belong to curves, so they can be moved with this pattern:

# Select the tube group, then ...
model = Sketchup.active_model
grp = model.selection[0]
vec = Geom::Vector3d.new(0, 0, 1.m)
tr  = Geom::Transformation.new(vec)
edges  = grp.entities.grep(Sketchup::Edge)
curves = edges.map(&:curve).compact.uniq
model.start_operation("Transform Entities",true)
  curves.each do |curve|
    vertices = curve.vertices
    points = vertices.map(&:position)
    destinations = points.map {|pt| pt.transform(tr) }
    curve.move_vertices(destinations)
  end
model.commit_operation
3 Likes