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!
    ⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update

    Create layers by materials

    Scheduled Pinned Locked Moved Plugins
    18 Posts 7 Posters 5.3k Views 7 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.
    • massimoM Offline
      massimo Moderator
      last edited by

      @unknownuser said:

      PS. Dear Didier, I was not able to browse your site. Is it my fault or is it offline sometimes?

      http://forums.sketchucation.com/viewtopic.php?p=360023#p360023 πŸ˜‰

      1 Reply Last reply Reply Quote 0
      • Didier BurD Offline
        Didier Bur
        last edited by

        The site was down yesterday after the PC is was on burned out 😞
        I'm actually restoring the saved database copy of it...

        DB

        1 Reply Last reply Reply Quote 0
        • Z Offline
          zsotti
          last edited by

          Hi !

          What I have promised, my feedback:

          1 / TIG's script - surely my fault (I am a rookie in ruby scripting), copied the RB in plugins folder with the right file name, but I have not found the 'command' in any menu. I have tried to write a menu definition according other RB scripts but I did not succeed, sorry.

          2 / Didier's script - after his server came back to life I was shocked about how many scripts he has written. Congratulations! I have downloaded the right one and it does (in two steps) exactly what I need.

          Thank you for your support!
          Zsotti

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

            My script does not have a menu entry.
            It's usage as described is
            TIG.faces2materiallayers
            in the Ruby Console

            TIG

            1 Reply Last reply Reply Quote 0
            • R Offline
              rbg
              last edited by

              Hi there,

              is there a chance to make this script work for sketchup 2018?

              The Tig version doesnt work

              and the Didier makes the layers but doesnt put the faces in the layers.

              kind regards

              Richard

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

                Edit the ancient RB file [in a plain-text editor, like Notepad++ or BBedit] and change the line:
                def self
                to read:
                def self.faces2materiallayers
                It should then work...
                Then in the Ruby Console, to run it, you use:
                TIG.faces2materiallayers

                TIG

                1 Reply Last reply Reply Quote 0
                • R Offline
                  rbg
                  last edited by

                  Thanks for the quick reply TIG

                  I have tried your adjustment and then i get this error code:


                  TIG.faces2materiallayers
                  Error: #<NameError: undefined local variable or method mat' for TIG:Module> C:/Users/richard/AppData/Roaming/SketchUp/SketchUp 2018/SketchUp/Plugins/TIG-faces2materiallayers.rb:11:in block in faces2materiallayers'
                  C:/Users/richard/AppData/Roaming/SketchUp/SketchUp 2018/SketchUp/Plugins/TIG-faces2materiallayers.rb:8:in each' C:/Users/richard/AppData/Roaming/SketchUp/SketchUp 2018/SketchUp/Plugins/TIG-faces2materiallayers.rb:8:in faces2materiallayers'
                  <main>:in <main>' SketchUp:1:in eval'


                  do you have any suggestions?

                  kind regards

                  Richard

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

                    This is a very very ancient RB...
                    Try this alternative...

                    ### Copy/paste code into a file called
                    ### 'TIG-faces2materiallayers.rb' in the Plugins folder
                    module TIG
                    def self.faces2materiallayers()
                      model=Sketchup.active_model
                      model.active_entities.grep(Sketchup;;Face).each{|face|
                        next unless mat=face.material
                        name=mat.display_name
                        face.layer=model.layers.add(name)
                      }
                    end
                    end
                    ### Usage; TIG.faces2materiallayers
                    

                    I think it'll work...
                    However, assigning layers to geometry, like faces and edges, is usually a very bad idea !!!!
                    They should almost always be given Layer0.

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • M Offline
                      marcelp102
                      last edited by

                      Dear TIG, after entering TIG.faces2materiallayers in ruby scriptbox I only get []. Any help?

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

                        For the avoidance of doubt, you must paste the whole of the code into the Ruby Console.
                        Then to run it use TIG.faces2materiallayers
                        For it to work there must be faces in the current active entities context, and they must have materials assigned to their fronts.
                        Faces within groups/components are NOT considered, unless you first edit the container to change the active entities context...

                        If those conditions are met, then any faces should be reassigned to a Layer named after their [front] material, which is made if it does not exist.

                        To reiterate my earlier comments, moving raw geometry to a layer other than Layer0 is generally not a good idea...
                        But if you want to do it then this way should work...

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • A Offline
                          avanoppen
                          last edited by

                          Hi TIG,

                          I'm dying to try the script. Question though: since Sketchup introduced tags as a replacement for layers, how would the script change? Looking forward to your reply, Gus

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

                            It doesn't change much at all - under the hood the API still calls them 'layers'.
                            Very similar to the way it still sees 'scenes' as 'pages' - changed because Layout arrived...

                            TIG

                            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