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

    Make Layer0 Plugin

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 171 Views 2 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.
    • C Offline
      cedeon
      last edited by

      Hi Guys,
      Does anyone know a plugin that will iterate down a component or group tree and make all entities in the tree on 'Layer0'? I have had a look around but couldn't find what i was looking for.

      Most of my work is imported from Autocad (by others). I have tried different workflows to avoid the issue but i always seem to end up with components that have deep deep layered entities which screws with my layer management further down the line. I want to have a component that can be on a specific layers but have all the branches and entities within on layer0.

      If there is nothing around and no dev's are interested i might have a crack at this myself.. Does anyone else have a need for such a tool?

      Thanks.

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

        See http://forums.sketchucation.com/viewtopic.php?p=47033#p47033
        My 'Default Layer Geometry' - this puts all geometry - even within groups/components onto Layer0 - in a selection [use Edit>Select_All to get everything].
        However, it does not place groups/instances onto Layer0.
        BUT this one-liner will do that step for you

        Sketchup.active_model.definitions.each{|d|d.instances.each{|i|i.layer=nil}}
        

        Copy/Paste it into the Ruby Console + <enter> - BUT use with care!
        Remember to 'Purge' the unused Layers when you are done...
        I'll post a 'nuke-all' version asap...

        TIG

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

          Here's a short script that makes 'Layer0' the layer for absolutely everything [geometry, text, dims, groups, instances etc] that are in the model AND also 'everything' inside all nested groups and components too; it also purges all of the unused layers; and it is one-step undoable. just in case you change your mind after running it !

          module TIG
            UI.menu("Plugins").add_item("TIG.layer0_ALL"){self.layer0_ALL()}unless file_loaded?(File.basename(__FILE__))
            file_loaded(File.basename(__FILE__))
            def self.layer0_ALL()
              model=Sketchup.active_model
              model.start_operation("TIG.layer0_ALL")
                model.entities.each{|e|e.layer=nil}
                model.definitions.each{|d|d.entities.each{|e|e.layer=nil}}
                model.layers.purge_unused
              model.commit_operation
            end
          end
          

          Copy all of the code and paste it into a file called say ' TIG-layer0_ALL.rb' in the Plugins folder. It will add an item to the 'Plugins' menu ' TIG.layer0_ALL' [unless you add # in front of the two lines of 'menu making' code at the start of the def] or you can type TIG.layer0_ALL into the Ruby Console too...

          TIG

          1 Reply Last reply Reply Quote 0
          • C Offline
            cedeon
            last edited by

            This is awesome and exactly what i was looking for, thanks a lot! πŸ˜„

            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