Trying to install a ruby script posted on this forum to flatten a model to set Z = 0
Saved the script as a rbz file but on install get “Errors were encountered”
Not a ruby programmer, can anyone help?
Script is:
encoding: UTF-8
module SetZEqual0; end
module Author::MoveToGroundPlane
extend self
MENU_TEXT ||= “Move to Ground Plane”
@@loaded ||= false
@@disable_ui ||= false
def move_to_ground_plane(ents)
model = Sketchup.active_model
model.start_operation(MENU_TEXT,@@disable_ui)
ents.each do |ent|
ent.transform!([0,0,-ent.transformation.origin.z])
end
model.commit_operation
end
if !@@loaded
UI.add_context_menu_handler do |popup|
sel = Sketchup.active_model.selection
unless sel.empty?
ents = sel.grep(Sketchup::Group) + sel.grep(Sketchup::ComponentInstance)
unless ents.empty?
popup.add_item(MENU_TEXT) { move_to_ground_plane(ents) }
end
end
end # context menu handler registrar
@@loaded = true
end # run once at first load
end # extension module