Can I align Construction Points to an axis?

I wrote a small snippet of code.
If you select construction points and copy-paste the code snippet into the Ruby Console and hit Enter… it will create a curve according the cpoints z-cordinates order.
You can Undo it.
(No warranties, use your own risk as usual :wink: )

module Dezmo
module JoinCPointsZ
  extend self
  
  def join_cps(cps, ents)
    sort_by_z = cps.sort{|a, b| a.position.z <=> b.position.z}.map(&:position)
    ents.add_curve sort_by_z
  end
  
  def run
    model = Sketchup.active_model
    entities = model.active_entities
    sel = model.selection
    cps = sel.grep(Sketchup::ConstructionPoint)
    return "No ConstructionPoints selected" if cps.size < 2
    model.start_operation("Join CPoints by Z cords", true)
    join_cps(cps, entities)
    model.commit_operation
  end

end
end
Dezmo::JoinCPointsZ.run

joincpZ

2 Likes