Finding Curve Points

Dear friends,
I draw a curve in SU and now I need to use it in my ruby codes. One way is I measure x, y and z for each point and add it in ruby but it takes long time. Do you know better way? Is there any plugins than can do it for me? Also if possible I wish to show start point and endpoint of curve.

If i got it right…

def display_pts
  mod = Sketchup.active_model
  ent = mod.active_entities
  sel = mod.selection
  ordered_edges = ent.weld( sel.grep(Sketchup::Edge) )
  ordered_edges.each_with_index{|curve, i|
    curve_pts = curve.vertices.map{|v| v.position.to_a}
    puts
    puts "curve #{i} points: #{curve_pts}"
    start_p = ent.add_text "S#{i}", curve_pts.first
    end_p = ent.add_text "E#{i}", curve_pts.last
  }
  nil
end
display_pts

1 Like

Thank you so much.

If you have a reference to (any) one of the edges of the curve …

curve_pts = edge.curve.vertices.map(&:position)

(It is not necessary to convert each of the Geom::Poit3d points into an Array.)


To get the first point of a curve (from a reference to any of it’s edges) …

first_pt = edge.curve.first_edge.start

To get the last point of a curve (from a reference to any of it’s edges) …

last_pt = edge.curve.last_edge.end
1 Like