###--------------------------------------------------------------------- # Name: PurgeAll.rb # Description: Plugins > Purge... # Author: TIG (c) 20070225 # Usage: Pick "Purge...", or use a Shortcut Key to it. # It Purges all UNUSED Components, Layers, Materials, Styles. # Choose which type(s) to purge from the dialog (Yes/No). # It only works in v6+. # Type: Tool # Version: 1.0 2070225 First issue. # 1.1 20070225 v.6000277 alowed ! # 1.2 20070226 A 4 options dialog added, now Menu= Purge... # 1.3 20070226 'Make Report' option added. # 1.4 20070304 Glitch on 'default' options fixed [?]. ###--------------------------------------------------------------------- require 'sketchup.rb' ###--------------------------------------------------------------------- class PurgeAll ### v1.3 def PurgeAll::do ### show VCB and status info Sketchup::set_status_text(("Purge..." ),SB_PROMPT) Sketchup::set_status_text("",SB_VCB_LABEL) Sketchup::set_status_text("",SB_VCB_VALUE) ### if Sketchup.version_number < 6000277###v1.1 Sketchup::set_status_text(("Purge... ERROR..." ),SB_PROMPT) UI.beep UI.messagebox("Sorry, but 'Purge...'\nis for Version 6 + only. ") return nil end#if ### dialog ###v1.2 @compos="Yes" if not @compos @layers="Yes" if not @layers @maters="Yes" if not @maters @styles="Yes" if not @styles @report="Yes" if not @report prompts=["Purge Components: ","Purge Layers: ","Purge Materials","Purge Styles: ","Make Report: "] values=[@compos,@layers,@maters,@styles,@report] yn="Yes|No"###v1.4 popups=[yn,yn,yn,yn,yn] title="Purge Options" results=inputbox(prompts,values,popups,title) return nil if not results ### do processing of results @compos=results[0] @layers=results[1] @maters=results[2] @styles=results[3] @report=results[4] ### ###v1.2 model=Sketchup.active_model entities=model.entities definitions=model.definitions layers=model.layers materials=model.materials styles=model.styles model.start_operation "Purge..." ### if @compos=="Yes" ###v1.2 compos1=definitions.count definitions.purge_unused co=compos1-definitions.count cmsg="\nComponents:\t "+co.to_s else cmsg="\n..." end#if if @layers=="Yes" ###v1.2 layers1=layers.count layers.purge_unused la=layers1-layers.count lmsg="\nLayers:\t\t "+la.to_s else lmsg="\n..." end#if if @maters=="Yes" ###v1.2 materials1=materials.count materials.purge_unused ma=materials1-materials.count mmsg="\nMaterials:\t\t "+ma.to_s else mmsg="\n..." end#if if @styles=="Yes" ###v1.2 styles1=styles.count styles.purge_unused st=styles1-styles.count smsg="\nStyles:\t\t "+st.to_s+"\n" else smsg="\n...\n" end#if ### report v1.3 if @compos=="No" && @layers=="No" if @maters=="No" && @styles=="No" UI.messagebox("You have set NOTHING to Purge !\t") return nil end#if end#if if @report=="Yes" UI.messagebox("Purged:\n"+cmsg+lmsg+mmsg+smsg+"\t\t\t") end#if ### model.commit_operation###for undo end #def end #class ### ### menu bits if(not file_loaded?("PurgeAll.rb")) UI.menu("Plugins").add_item("Purge...") {PurgeAll.do} end file_loaded("PurgeAll.rb") ###