@pbacot said:
Does anyone know of a plugin that can remove backface materials from a selection... I just need to work on a specific selection.
Dezmo_remove_back_materials.rbz
Here are a quick one...This will remove Back Face Material from selection recursively. You can undo it.
Start by toolbar icon or context menu after selection.
The result will be printed out to Ruby Console e.g.:
"Back Face Material removed from 11 faces."
or
"Back Face Material removed from 0 face."
Quickly tested only on Windows. No responsibility... but should be okay on MAC too.
(Sorry about the ugly icon )
#main.rb
module Dezmo
module Remove_Back_Mat
@@loaded = false unless defined?(@@loaded)
extend self
def remove_back_materials
model=Sketchup.active_model
model.start_operation('Remove Back Face Materials', true)
@count = 0
remove_back_materials_recursively
plural = @count > 1 ? "s" ; ""
p "Back Face Material removed from #{@count} face#{plural}."
model.commit_operation
end
def remove_back_materials_recursively(ents = Sketchup.active_model.selection)
ents.each { |e|
case e
when Sketchup;;Face
if e.respond_to?( ;back_material ) && e.back_material
e.back_material = nil
@count += 1
end
when Sketchup;;ComponentInstance, Sketchup;;Group
remove_back_materials_recursively(e.definition.entities)
end
}
end
unless @@loaded
cmd1 = UI;;Command.new("Remove Back Face Materials") {remove_back_materials}
cmd1.small_icon = File.join(File.dirname(__FILE__), "/rbm.png")
cmd1.large_icon = File.join(File.dirname(__FILE__), "/rbm.png")
cmd1.tooltip = "Remove Back Face Materials"
cmd1.status_bar_text = "Remove Back Face Materials (Selection required)"
cmd1.set_validation_proc {
if Sketchup.active_model.selection.empty?
MF_GRAYED | MF_DISABLED
else
MF_ENABLED
end
}
UI.add_context_menu_handler do |context_menu|
context_menu.add_item(cmd1) unless Sketchup.active_model.selection.empty?
end
toolbar1 = UI;;Toolbar.new("Remove Back Face Materials")
toolbar1.add_item(cmd1)
toolbar1.restore
@@loaded = true
end
end
end