sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    How to change the layer of a group (and ALL of its entities)

    Scheduled Pinned Locked Moved Newbie Forum
    sketchup
    8 Posts 3 Posters 554 Views 3 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.
    • gonashviliG Offline
      gonashvili
      last edited by

      I've noticed I spent more time tidying up [all my entities into appropriate layers], than actually working on something. Once I'm done tidying up, I forget what actually wanted to do!

      This is partially because of the fact that when I move a certain group to a different layer, the entities within the group stay on the initial layer, the one they were on before 'moving'. This slows me down immensely.

      Of course, at times, this 'feature' is useful, but is there a way to change the layer for the WHOLE content of the group/component into a new/different layer?

      Thank you for your time/reading!

      Cheers

      H.G.

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

        A quick manual way is to double click the group so all of the innards are the active entities.
        Edit>SelectAll[Ctrl+A]
        Then use Entity Info or the Layer toolbar's drop-down list to change their layer to whatever you wish... You might need/want to mine down into nested groups to change their contents too...

        To do it 'in code' use one of these one-liners, copy/pasted into the Ruby Console +<enter>.
        All Groups in the current selection have their contents put on the same layer as the group itself...

        m=Sketchup.active_model;m.start_operation('g');m.selection.grep(Sketchup;;Group).each{|g|g.make_unique if g.entities.parent.instances[1];g.entities.each{|e|e.layer=g.layer}};m.commit_operation
        

        Of course it's wise usually to leave 'raw geometry' on Layer0, so this second version only processes non-geometry, and leaves raw geometry alone...

        m=Sketchup.active_model;m.start_operation('g');m.selection.grep(Sketchup;;Group).each{|g|g.make_unique if g.entities.parent.instances[1];g.entities.each{|e|e.layer=g.layer unless e.is_a?(Sketchup;;Edge) || e.is_a?(Sketchup;;Face)}};m.commit_operation
        

        This one moves all raw geometry onto Layer0 and matches other objects to the group's layer

        m=Sketchup.active_model;m.start_operation('g');m.selection.grep(Sketchup;;Group).each{|g|g.make_unique if g.entities.parent.instances[1];g.entities.each{|e|if e.is_a?(Sketchup;;Edge) || e.is_a?(Sketchup;;Face);e.layer=nil;else;e.layer=g.layer;end}};m.commit_operation
        

        They are all one step undo-able.

        TIG

        1 Reply Last reply Reply Quote 0
        • gonashviliG Offline
          gonashvili
          last edited by

          Thanks so much for this!

          How would I define a key with that one-liner? Tried googling, but the post on RUBY ON WINDOWS gives me such a headache πŸ˜„

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

            You can't.
            It needs a command/menu entry which you can then shortcut to...
            This generic code does that:

            require("sketchup.rb")
            module HamletG
              def self.toolx()
                ### paste a one-liner here - without any initial ###
              end
              unless file_loaded?(__FILE__)
                UI.menu("Plugins").add_item("HamletG's toolx"){self.toolx()}
              end
              file_loaded(__FILE__)
            end
            

            Adjust 'toolx' for your tool's name [lowercase letters starting with a-z] - copy this into code a plain text file in the Plugins folder named 'HamletG-toolx.rb', where you need to adjust 'toolx' etc to match the tool's method... Set a shortcut to the new "Plugins" menu item after a restart... The "HamletG's toolx" in the menu item's title can of course say whatever you like...

            TIG

            1 Reply Last reply Reply Quote 0
            • gonashviliG Offline
              gonashvili
              last edited by

              Cheers, but there seems to be an error with those one liners :

              For instance the first one;

              {ruby}:

              m=Sketchup.active_model;m.start_operation('g');m.selection.grep(Sketchup::Group).each{|g|g.make_unique if g.instances[1];g.entities.each{|e|e.layer=g.layer}};m.commit_operation Error: #<NoMethodError: undefined methodinstances' for #Sketchup::Group:0xf739b78>
              (eval):155
              (eval):155:in each' (eval):155

              😞

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

                @gonashvili said:

                This is partially because of the fact that when I move a certain group to a different layer, the entities within the group stay on the initial layer, the one they were on before 'moving'. This slows me down immensely.

                From this comment it seems you might benefit from reading through the help files on the use of layers in SketchUp. Especially these passages:

                @unknownuser said:

                First things first: by default, a SketchUp model has one layer, Layer 0 (zero), which is the base layer. You can't delete or rename Layer 0, and you should always draw your individual entities on Layer 0 and leave them there.

                @unknownuser said:

                Always draw your entities on Layer 0 and leave them there.

                If you follow the "rules" about using layers in SketchUp and use them correctly you will find it doesn't slow you down at all.

                Etaoin Shrdlu

                %

                (THERE'S NO PLACE LIKE)

                G28 X0.0 Y0.0 Z0.0

                M30

                %

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

                  @gonashvili said:

                  Cheers, but there seems to be an error with those one liners...
                  😞
                  You are right - my typo ! Now it's corrected in my original post...

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • gonashviliG Offline
                    gonashvili
                    last edited by

                    Thank you so much. I'd buy you a coffee or something if I had any money right now πŸ˜„

                    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