sketchucation logo sketchucation
    • Login
    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

    Is there a way to select all with Default material?

    Scheduled Pinned Locked Moved Plugins
    11 Posts 6 Posters 1.6k Views 6 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.
    • sdmitchS Offline
      sdmitch
      last edited by

      Brodie,

      Remember faces have a front and a back. One can have material applied and the other not. So open the Ruby Console and paste this into the input box

      Sketchup.active_model.entities.each{|e| Sketchup.active_model.selection.add e if e.is_a?(Sketchup;;Face) && e.material==nil && e.back_material==nil}
      

      This will select all faces that have default material on front and back.

      Nothing is worthless, it can always be used as a bad example.

      http://sdmitch.blogspot.com/

      1 Reply Last reply Reply Quote 0
      • brodieB Offline
        brodie
        last edited by

        When i do that nothing happens and it replies with this in the ruby console

        Error: #<NameError: undefined local variable or method `ent' for main:Object>
        (eval):2537

        Am I doing something wrong?

        -Brodie

        steelblue http://www.steelbluellc.com

        1 Reply Last reply Reply Quote 0
        • TIGT Offline
          TIG Moderator
          last edited by

          Here's a slightly modified version

          m=Sketchup.active_model;(s=m.selection).clear;m.active_entities.each{|e|s.add(e)if e.is_a?(Sketchup;;Face)&&!e.material&&!e.back_material}
          

          Copy the whole of the code into the Ruby Console and press <enter>.

          TIG

          1 Reply Last reply Reply Quote 0
          • brodieB Offline
            brodie
            last edited by

            That's the ticket. Can you give me a quick rundown on how I'd give that a shortcut key? I'm guessing it needs to be turned into a .rb but I'll bet there's a bit more code that needs to go into it than just that bit. Any tips?

            -Brodie

            steelblue http://www.steelbluellc.com

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

              Selection Toys let you do that.

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

              1 Reply Last reply Reply Quote 0
              • TIGT Offline
                TIG Moderator
                last edited by

                @unknownuser said:

                That's the ticket. Can you give me a quick rundown on how I'd give that a shortcut key? I'm guessing it needs to be turned into a .rb but I'll bet there's a bit more code that needs to go into it than just that bit. Any tips?
                -Brodie
                Copy/paste this code into a file called ' TIG-selectByDefaultMaterial.rb' in the ../Plugins/ folder

                module TIG
                  def self.selectByDefaultMaterial()
                    m=Sketchup.active_model
                    (s=m.selection).clear
                    m.active_entities.each{|e|s.add(e)if e.is_a?(Sketchup;;Face)&&!e.material&&!e.back_material}
                  end
                  UI.menu("Plugins").add_item("Select By Default Material"){self.selectByDefaultMaterial()}unless file_loaded?(File.basename(__FILE__))
                  file_loaded(File.basename(__FILE__))
                end
                
                

                Then the 'Select By Default Material' item in the Plugins menu can be assigned a shortcut after a restart... ๐Ÿ’š

                TIG

                1 Reply Last reply Reply Quote 0
                • brodieB Offline
                  brodie
                  last edited by

                  Thanks, that did the trick

                  -Brodie

                  steelblue http://www.steelbluellc.com

                  1 Reply Last reply Reply Quote 0
                  • deaneauD Offline
                    deaneau
                    last edited by

                    @tig said:

                    @unknownuser said:

                    That's the ticket. Can you give me a quick rundown on how I'd give that a shortcut key? I'm guessing it needs to be turned into a .rb but I'll bet there's a bit more code that needs to go into it than just that bit. Any tips?
                    -Brodie
                    Copy/paste this code into a file called ' TIG-selectByDefaultMaterial.rb' in the ../Plugins/ folder

                    module TIG
                    >   def self.selectByDefaultMaterial()
                    >     m=Sketchup.active_model
                    >     (s=m.selection).clear
                    >     m.active_entities.each{|e|s.add(e)if e.is_a?(Sketchup;;Face)&&!e.material&&!e.back_material}
                    >   end
                    >   UI.menu("Plugins").add_item("Select By Default Material"){self.selectByDefaultMaterial()}unless file_loaded?(File.basename(__FILE__))
                    >   file_loaded(File.basename(__FILE__))
                    > end
                    > 
                    

                    Then the 'Select By Default Material' item in the Plugins menu can be assigned a shortcut after a restart... ๐Ÿ’š

                    TIG is in Hollyday could an other developer tell me, why i canยดt seen this in the plugin menue?

                    thank you

                    MADE, BORN AND LIVING IN BERLIN
                    Big Thank You to all Programmers
                    Some German words are so long that they have a perspective. M.Twain

                    1 Reply Last reply Reply Quote 0
                    • BoxB Offline
                      Box
                      last edited by

                      I followed the instructions and it works for me.

                      1 Reply Last reply Reply Quote 0
                      • deaneauD Offline
                        deaneau
                        last edited by

                        @box said:

                        I followed the instructions and it works for me.
                        yippy i have fund

                        thanks

                        MADE, BORN AND LIVING IN BERLIN
                        Big Thank You to all Programmers
                        Some German words are so long that they have a perspective. M.Twain

                        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