=begin #----------------------------------------------------------------------- Copyright 2008, TIG (c) Permission to use, copy, modify, and distribute this software for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies. This software is provided "as is" and without any express or implied warranties, including, without limitation, the implied warranties of merchantability and fitness for a particular purpose. Name : ConsDeleteContext Author : TIG Usage : Deletes Construction (Guide) Lines or Points accessed through the Context menu and submenu: it either deletes 'All Active' or 'All in Selection' - mining down into any selected groups/components... One step un-doable... History: 1.0 First release 20081019 #----------------------------------------------------------------------- =end require 'sketchup.rb' ### def deleteAllGlines model = Sketchup.active_model entities = model.active_entities model.start_operation "delete active Glines" 8.times do |something| entities.each{|entity| entity.erase! if entity.valid? && entity.typename == "ConstructionLine" } end#do model.commit_operation end def deleteAllSelectedGlines def mineAllCls(ents) ents.each{|e| if e.valid? mineAllCls(e.entities) if e.typename == "Group" mineAllCls(e.definition.entities) if e.typename == "ComponentInstance" e.erase! if e.typename == "ConstructionLine" end } end#def model = Sketchup.active_model entities = model.selection.to_a model.start_operation "delete selected Glines" mineAllCls(entities) model.commit_operation end def deleteAllGpoints model = Sketchup.active_model entities = model.active_entities model.start_operation "delete active Gpoints" 8.times do |something| entities.each{|entity| entity.erase! if entity.valid? && entity.typename == "ConstructionPoint" } end#do model.commit_operation end def deleteAllSelectedGpoints def mineAllCps(ents) ents.each{|e| if e.valid? mineAllCps(e.entities) if e.typename == "Group" mineAllCps(e.definition.entities) if e.typename == "ComponentInstance" e.erase! if e.typename == "ConstructionPoint" end } end#def model = Sketchup.active_model entities = model.selection.to_a model.start_operation "delete selected Gpoints" mineAllCps(entities) model.commit_operation end #======================================================================= if not file_loaded?("ConsDeleteContext.rb") UI.add_context_menu_handler do|menu| menu.add_separator ### this adds a seperator line ### out if NOT wanted submenus=menu.add_submenu("Construction:Guide Tools...") ### adds the submenus submenu1=submenus.add_submenu("Lines...") ### adds the submenus for the items that follow submenu2=submenus.add_submenu("Points...") submenu1.add_item("Delete All Active") {deleteAllGlines} submenu1.add_item("Delete All in Selection") {deleteAllSelectedGlines} submenu2.add_item("Delete All Active") {deleteAllGpoints} submenu2.add_item("Delete All in Selection") {deleteAllSelectedGpoints} end end #----------------------------------------------------------------------- file_loaded("ConsDeleteContext.rb")