sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    How do I do this?

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 4 Posters 362 Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R Offline
      redinhawaii
      last edited by

      I have basically figured out how to load a "ruby"
      but I do not know how to deal with this kind of text, it comes in not in a folder or an icon, so I got this text.
      what to do with it?

      tt_remove_material.rb

      #-----------------------------------------------------------------------------

      Version: 1.1.0

      Compatible: SketchUp 7

      #-----------------------------------------------------------------------------

      Removes a given material for a selection.

      #-----------------------------------------------------------------------------

      Changelog

      1.0.0 - 04.03.2009

      * Remove Material

      1.1.0 - 16.03.2009

      * Remove All Materials

      * Remove Edge Materials

      #-----------------------------------------------------------------------------

      Thomas Thomassen

      thomas[at]thomthom[dot]net

      #-----------------------------------------------------------------------------

      require 'sketchup.rb'

      #-----------------------------------------------------------------------------

      Add some menu items to access this

      if( not file_loaded?('tt_remove_material.rb') )
      plugins_menu = UI.menu('Plugins')
      sub = plugins_menu.add_submenu('Remove Materials')
      sub.add_item('Specific From Selection') { TT_Remove_Material::remove() }
      sub.add_item('From Entire Model') { TT_Remove_Material::remove_all() }
      sub.add_item('From All Edges') { TT_Remove_Material::remove_edge_materials() }
      end
      #-----------------------------------------------------------------------------
      file_loaded('tt_remove_material.rb')
      #-----------------------------------------------------------------------------

      module TT_Remove_Material

      def self.remove
      	# Variables
      	model = Sketchup.active_model
      	sel = model.selection
      	definitions = []
      	
      	# Prompt for material to remove
      	materials = []
      	model.materials.each { |m| materials.push(m.name) }
      	materials = materials.join('|')
      	
      	prompts = ['What material to remove?']
      	defaults = ['Enter name']
      
      	results = UI.inputbox(prompts, defaults, [materials], 'Remove material.')
      	
      	if results == nil
      		return
      	else
      		material = model.materials[ results[0] ]
      	end
      	
      	Helping_Hand.start_operation('Remove Material')
      	
      	# Iterate entities
      	sel.each { |e|
      		if e.kind_of?(Sketchup::ComponentInstance) || e.kind_of?(Sketchup::Group)
      			parent = e.definition if e.kind_of?(Sketchup::ComponentInstance)
      			parent = e.entities.parent if e.kind_of?(Sketchup::Group)
      			
      			next if definitions.include?(parent)
      			
      			parent.entities.each { |ents|
      				# Remove material
      				ents.material = nil if ents.material == material
      				if ents.kind_of?(Sketchup::Face)
      					ents.back_material = nil if ents.back_material == material
      				end
      			}
      			definitions.push(parent)
      		else
      			e.material = nil if e.material == material
      			if e.kind_of?(Sketchup::Face)
      				e.back_material = nil if e.back_material == material
      			end
      		end
      	}
      	
      	model.commit_operation
      end
      
      
      def self.remove_all
      	# Variables
      	model = Sketchup.active_model
      	
      	Helping_Hand.start_operation('Remove All Materials')
      	
      	# Iterate entities
      	model.entities.each { |e|
      		e.material = nil
      		if e.kind_of?(Sketchup::Face)
      			e.back_material = nil
      		end
      	}
      	model.definitions.each { |d|
      		d.entities.each { |e|
      			e.material = nil
      			if e.kind_of?(Sketchup::Face)
      				e.back_material = nil
      			end
      		}
      	}
      	
      	model.commit_operation
      end
      
      
      def self.remove_edge_materials
      	# Variables
      	model = Sketchup.active_model
      	
      	Helping_Hand.start_operation('Remove Edge Materials')
      	
      	# Iterate entities
      	model.entities.each { |e|
      		if e.kind_of?(Sketchup::Edge)
      			e.material = nil
      		end
      	}
      	model.definitions.each { |d|
      		d.entities.each { |e|
      			if e.kind_of?(Sketchup::Edge)
      				e.material = nil
      			end
      		}
      	}
      	
      	model.commit_operation
      end
      
      
      ### HELPER METHODS ### ---------------------------------------------------
      
      module Helping_Hand
      	def self.start_operation(name)
      		model = Sketchup.active_model
      		# Make use of the SU7 speed boost with start_operation while
      		# making sure it works in SU6.
      		if Sketchup.version.split(".")[0].to_i >= 7
      			model.start_operation(name, true)
      		else
      			model.start_operation(name)
      		end
      	end
      end # module Helping_Hand
      

      end

      1 Reply Last reply Reply Quote 0
      • jeff hammondJ Offline
        jeff hammond
        last edited by

        sometimes the rubies come in like that when downloading (that's the actual writing)

        try right clicking on the link and choose 'download linked file'..

        you'll get a file whos icon will look like a .txt file...
        example of a ruby icon on mac

        drop that into:
        macintosh HD/library/application support/google sketchup 7/sketchup/plugins

        restart sketchup and the ruby will load

        dotdotdot

        1 Reply Last reply Reply Quote 0
        • R Offline
          redinhawaii
          last edited by

          Thanks again Guys,
          I spent most of the day trying to sort this out, 9:51pm, finally seem to have something I can send my engineer that works.
          I did not have a "download linked file" options, tried a few things, and finally out of frustration tried, once again to drag if from the downloads folder to the suggested location, I got a "not authorized to modify SU" notice or something like that...but after giving my password, it seemed to have worked.
          thanks for your insights and perspectives.

          I do hope this is not a "typical SU' situation.

          aloha
          red

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            What browser do you use?
            If you end up with the pure text of a ruby, you can, from the browser, so a Save As, and save it into your plugin folder. But make note of what the file name should be.

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • mitcorbM Offline
              mitcorb
              last edited by

              When I download a plugin, whether .zip or .rb, while in Firefox, I right click on the target, a context menu pops up with "Save link as.." option. I default the destination to desktop so that I can distribute to both SU6 and SU7. Occasionally, I have seen where it transfers as a .php or a .txt--why? I don't know. I just dump these and retry the transfer.

              I take the slow, deliberate approach in my aimless wandering.

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                You get .php some times because the link goes to a PHP script which redirects you to the download. When that happens you have to link the link instead of Save As.

                Thomas Thomassen — SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement