[REQ] remove backface materials (selected)  Topic is solved

[REQ] remove backface materials (selected)

Postby pbacot » Wed Apr 21, 2021 8:23 pm

Does anyone know of a plugin that can remove backface materials from a selection. I use TT's Material tools which are excellent. But the actions seem to work on the whole model instead of selections, and removing materials from ALL backfaces is a problem when I just need to work on a specific selection.
0
MacOSX Mojave High Sierra SketchUp Pro v19 Twilight v2 Thea v2 PowerCADD
User avatar
pbacot 
Top SketchUcator
 

Re: [REQ] remove backface materials (selected)

Postby pilou » Wed Apr 21, 2021 9:01 pm

If you inverse Selection / Hide then Remove that works not ? (not tested)
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: [REQ] remove backface materials (selected)

Postby rv1974 » Thu Apr 22, 2021 10:05 am

put selection in separate file, run TT tools and paste it back- what's the problem?
0

rv1974 
 

Re: [REQ] remove backface materials (selected)

Postby Box » Thu Apr 22, 2021 10:55 am

If you are within a group you can use the Specific Material option to remove the backface material without effecting other backfaces.
Edit: actually you don't need to be in groups, Remove Specific works on selection not entire model.
0
User avatar
Box 
 

Re: [REQ] remove backface materials (selected)

Postby pbacot » Thu Apr 22, 2021 4:35 pm

Thanks going into every group is what I was hoping to avoid. If there's nothing out there, I can deal with it these different methods.
0
MacOSX Mojave High Sierra SketchUp Pro v19 Twilight v2 Thea v2 PowerCADD
User avatar
pbacot 
Top SketchUcator
 

Re: [REQ] remove backface materials (selected)

Postby Box » Fri Apr 23, 2021 12:57 am

You don't have to go into each group, if the material is only on the back faces you can select groups components and raw geometry and it will remove the chosen material from anywhere in the selection while leaving the rest of the model alone. If the material is both back and front then this wouldn't work.
1
User avatar
Box 
 

Re: [REQ] remove backface materials (selected)

Postby pbacot » Fri Apr 23, 2021 1:16 am

Now i see what you mean--that's a different approach to the same solution. Thanks!
0
MacOSX Mojave High Sierra SketchUp Pro v19 Twilight v2 Thea v2 PowerCADD
User avatar
pbacot 
Top SketchUcator
 

Re: [REQ] remove backface materials (selected)  Topic is solved

Postby dezmo » Fri Apr 23, 2021 11:25 am

pbacot wrote: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 :oops: )


rbfm1.gif



Code: Select all
#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
2
Man can do everything. Only a matter of time and money.

dezmo 
 

Re: [REQ] remove backface materials (selected)

Postby Box » Fri Apr 23, 2021 2:47 pm

Nice one Dezmo.
I really must learn to code one day.
2
User avatar
Box 
 

Re: [REQ] remove backface materials (selected)

Postby pbacot » Fri Apr 23, 2021 4:53 pm

Wow! Thanks so much for writing that! It works great! :thumb: :thumb: :thumb:
1
MacOSX Mojave High Sierra SketchUp Pro v19 Twilight v2 Thea v2 PowerCADD
User avatar
pbacot 
Top SketchUcator
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Plugins

cron

Who is online

Users browsing this forum: lovelyidawn, mahmoud zatari, mikaelafr, mmarcelov and 13 guests