Hi, I was recording a video of my workflow before starting to code while also showing an extension I am currently working on.
And, at the 11:30 minute mark, you’ll see a BUG that happened after I used ‘undo’ for bringing back previously deleted entities. When I tried deleting them again it didn’t allow me and I could not select them properly either.
Below is the code of a module I am including on my extension for erasing selected entities.
I hope I can get some feedback on what I am doing wrong.
# frozen_string_literal: true
# ------------------------------------------------------------------------------
module Renderiza
module Grabby
# # #
module Eraser
# # #
def erase_selection
model = Sketchup.active_model
entities = model.active_entities
selection = model.selection
return unless selection.length >= 1
faces = selection.grep(Sketchup::Face)
if faces.length >= 1
face_edges = []
faces.each do |face|
face_edges << face
face_edges << face.edges
end
face_edges.flatten!
# ------------------------------------------ START
model.start_operation('Eraser', true)
group = model.entities.add_group(face_edges)
group.erase!
entities.erase_entities(selection)
model.commit_operation
# ------------------------------------------ END
else
entities.erase_entities(selection)
end
end
end
end
end
Thanks in advance and happy Mother’s day!