Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
đź«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download
[WIP] CleverClay - Need help
-
I'm writing a script to change all materials to gray but leave transparency if any.
It works on non grouped geometry.
How to make it work on Grouped geometry as well?# CleverClay.rb # Version; 1.0 # Turns all materials Gray but keeps transparency if any # Jan Sandström www.pixero.com # Based on Thomthoms "Blackout" require 'sketchup.rb' #----------------------------------------------------------------------- is_this_file=File.basename(__FILE__) if not file_loaded?(is_this_file) UI.menu("Plugins").add_item("JS Clever Clay"){claymaker} end #----------------------------------------------------------------------- file_loaded(is_this_file) def claymaker # 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 Sketchup.active_model.start_operation("claymaker", true) else Sketchup.active_model.start_operation("claymaker") end model = Sketchup.active_model materials = model.materials entities = model.entities m = materials.add "ClayMat" m.color = [200, 200, 200] m.alpha = 1 entities.each { | e | if (e.material == nil) && (e.kind_of?(Sketchup;;Face)) e.material = "ClayMat" e.back_material = "ClayMat" if e.respond_to? "back_material" end if (e.kind_of?(Sketchup;;Face) && (e.material.alpha < 1 )) e.material.texture = nil e.material.color = [200, 200, 200] end if (e.kind_of?(Sketchup;;Face) && (e.material.alpha == 1 )) e.material = "ClayMat" e.back_material = "ClayMat" if e.respond_to? "back_material" end } Sketchup.active_model.commit_operation end -
# CleverClay.rb # Version; 1.0 # Turns all materials Gray but keeps transparency if any # Jan Sandström www.pixero.com # Based on Thomthoms "Blackout" require 'sketchup.rb' #----------------------------------------------------------------------- is_this_file=File.basename(__FILE__) if not file_loaded?(is_this_file) UI.menu("Plugins").add_item("JS Clever Clay"){claymaker} end #----------------------------------------------------------------------- file_loaded(is_this_file) def claymaker # 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 Sketchup.active_model.start_operation("claymaker", true) else Sketchup.active_model.start_operation("claymaker") end model = Sketchup.active_model materials = model.materials entities = model.entities m = materials.add "ClayMat" m.color = [200, 200, 200] m.alpha = 1 entities.each { | e | if (e.material == nil) && (e.kind_of?(Sketchup;;Face)) e.material = "ClayMat" e.back_material = "ClayMat" if e.respond_to? "back_material" end if (e.kind_of?(Sketchup;;Face) && (e.material.alpha < 1 )) e.material.texture = nil e.material.color = [200, 200, 200] end if (e.kind_of?(Sketchup;;Face) && (e.material.alpha == 1 )) e.material = "ClayMat" e.back_material = "ClayMat" if e.respond_to? "back_material" end } # Loop over all the definitions in the model model.definitions.each { |d| d.entities.each { |e| # do the same stuff you did to the model.entities here. } } Sketchup.active_model.commit_operation end -
Thanks!

Advertisement