# Name : Faces killer # Description : Deletes faces with material with or whitout texture # Author : Didier Bur # Usage : Plugins/Delete textured/non-textured faces # Date : 26.Sept.2oo6 # Type : tool # History: 1.0 (version 1.0. #----------------------------------------------------------------------------- # 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. #----------------------------------------------------------------------------- require 'sketchup.rb' # ----------------------------------------------------- Faces killer def del_tex_faces model=Sketchup.active_model materials = model.materials $text_mats = [] $ss = model.selection $ss.clear # User choice list = %w[Without_texture With_texture].join("|") dropdowns = [list] prompts = ["Delete faces "] values = ["Without_texture"] if not values results = inputbox prompts, values, dropdowns, "What kind of faces?" return if not results $del_what = results[0] # Get all materials using textures or not. materials.each do |m| case $del_what when "Without_texture" if m.texture == nil $text_mats.push m.name end when "With_texture" if m.texture != nil $text_mats.push m.name end end end (get_deletable_objects) #Deletes objects $tex_ents.each do |e| case e.typename when "Face" if e.deleted? == false e.erase! end when "Group" puts "Group" end end case $del_what when "Without_texture" UI.messagebox( $text_mats.length.to_s + " materials NOT using textures,\n" + $tex_ents.length.to_s + " faces deleted." ) when "With_texture" UI.messagebox( $text_mats.length.to_s + " materials using textures,\n" + $tex_ents.length.to_s + " faces deleted." ) end end # --------------------------------- Get all objects using or not textured materials def get_deletable_objects model=Sketchup.active_model $tex_ents = [] model.entities.each do |e| case e.typename when "Face" emat = e.material if emat and $text_mats.include? e.material.name $tex_ents.push e end when "Group" gents = e.entities gents.each do |f| fmat = f.material if fmat and $text_mats.include? f.material.name $tex_ents.push f end end #.each when "ComponentInstance" gents = e.definition.entities gents.each do |f| fmat = f.material if fmat and $text_mats.include? f.material.name $tex_ents.push f end end #.each end #case end #.each end # --------------------------------------------------------------------------- # Menu items: #---------------------------------------------------------------------------- if( not $del_tex_faces_menu_loaded ) UI.menu("Plugins").add_item("Delete textured or non-textured faces") { (del_tex_faces) } $del_tex_faces_menu_loaded = true end file_loaded("delete_non_textured_faces.rb")