• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Is there a way to select all with Default material?

Scheduled Pinned Locked Moved Plugins
11 Posts 6 Posters 1.5k 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.
  • B Offline
    brodie
    last edited by 27 Sept 2011, 19:32

    It's easy enough to select a material and pick "Select all with same material" but, of course, for whatever reason, this function doesn't work with SU's Default material. Is there a plugin that's rectified this?

    -Brodie

    steelblue http://www.steelbluellc.com

    1 Reply Last reply Reply Quote 0
    • S Offline
      sdmitch
      last edited by 27 Sept 2011, 21:24

      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
      • B Offline
        brodie
        last edited by 27 Sept 2011, 21:31

        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
        • T Offline
          TIG Moderator
          last edited by 27 Sept 2011, 22:17

          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
          • B Offline
            brodie
            last edited by 27 Sept 2011, 22:20

            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
            • T Offline
              thomthom
              last edited by 28 Sept 2011, 08:18

              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
              • T Offline
                TIG Moderator
                last edited by 28 Sept 2011, 09:25

                @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
                • B Offline
                  brodie
                  last edited by 28 Sept 2011, 13:14

                  Thanks, that did the trick

                  -Brodie

                  steelblue http://www.steelbluellc.com

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    deaneau
                    last edited by 11 Oct 2014, 17:14

                    @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 11 Oct 2014, 18:28

                      I followed the instructions and it works for me.

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        deaneau
                        last edited by 12 Oct 2014, 08:32

                        @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