sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Layers Order

    Scheduled Pinned Locked Moved Developers' Forum
    13 Posts 7 Posters 526 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.
    • M Offline
      MartinRinehart
      last edited by

      Does anyone have a clue re the order of layers in the Layers window?

      The order of layers in the model.layers array is the order in which they were entered. The order of windows in the Layer window, which I would like to match in my plugin, is?

      Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

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

        Alphabetical with numbers first (havent tested capitals yet), although layer 0 is always at the start.

        http://remusrendering.wordpress.com/

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

          Beware that non-EN SUppers might not call layer=nil 'Layer0', so we need to trap for that too...
          We sort the layer_names alphabetically and add them onto an array starting with the default_layer_name or whatever it's called ?

          
          layer_names=[]
          model.layers.each{|layer|
            layer_names<<layer.name
          }
          layer_names=layer_names-[default_layer_name]
          ### it will always start with the 'default_layer-name'
          ### - even if it's not 'Layer0' - so...
          default_layer_name=layer_names[0]
          layer_names=layer_names-[default_layer_name]
          layer_names.sort!
          layer_names=[default_layer_name]+layer_names
          ### now have aAyer0 [or whatever] and the rest in alphabetical order...
          ###
          ### to add layer_names to dialog...
          dialog_layers=layer_names.join("|")
          ###
          ### to find layer picked by name
          if layer_name=default_layer_name
            layer_to_use=nil
          else
            layer_to_use=nil
            model.layers.each{|layer|
              if layer.name==layer_name
                layer_to_use=layer
                break ### we got it
              end#if
            }
          end#if
          ### etc etc
          
          

          TIG

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

            Sorting will fail for any user that uses non-English characters (outside the ASCII range) as they will be multi-byte characters.

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

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

              @tig said:

              We sort the layer_names alphabetically and add them onto an array starting with the default_layer_name

              Your post and code are most helpful, but ...

              I'm looking at a little test model. It's layers, per the layer window, are:
              Layer0
              stairs
              ground_floor
              roof
              basement
              second_floor
              garage

              My mother was a librarian. She taught me about sorting. "basement", "garage", ...

              It's layers, per the Ruby Console, are:
              Layer0
              basement
              ground_floor
              garage
              second_floor
              stairs
              roof

              It's layers, per Entity Info dropdown are:
              Layer0
              (others, in alpha order)

              In my testing, I've become convinced that the Ruby Console array is ordered in the sequence the layers were entered.

              For the rest, I'm sure I don't know. I just tested File/New, (in Layers window click "+" and press Enter), 4 times. This is what the Layers window says:
              Layer0
              Layer4
              Layer2
              Layer3
              Layer1

              (Repeat above test. Order is now 0, 4, 1, 3, 2).

              Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

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

                Layers reported in model.layers are in the order they are made - that's why the default_layer is always first - it's in the model already !

                In the layer-browser they are listed default_layer first, them the rest in alphabetical order.

                My method sorts the list to be like that - irrespective of the actual name of the default_layer - assuming no accented characters in the names !

                If you want to order the list and know what the layers are called why not just make the layer_list like that by hard coding it ? Otherwise you need a complex look-up list to ensure that whatever layers there are are ordered as you want - e.g. by 'level'... Layers no in your system will be ordered tot he end... Of course calling them Level0, Level1, Level2 would do this too without the pain ! πŸ˜‰

                Confused about the list ordering ??? πŸ˜•

                TIG

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

                  @tig said:

                  In the layer-browser they are listed default_layer first, them the rest in alphabetical order.

                  Either we're not communicating or maybe my SU is broke. By "layer-browser" do you mean the window named "Layers"? The list in my Layers window is definitely not alphabetical.

                  Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

                  1 Reply Last reply Reply Quote 0
                  • Chris FullmerC Offline
                    Chris Fullmer
                    last edited by

                    1. Ruby Array:
                      layers_ruby.png
                      I am finding that the ruby array is in the order the array was created. Is that agreed?

                    2. Layer Toolbar:
                      Layer_Toolbar.png
                      This appears to always be in alphabetical order, with the Layer 0 always first.

                    3. Layer Browser/Inspector/Dialog:
                      layer_dialog_window.png
                      This can be sorted by layer name, color, on/off. So there is no single right way that it is ordered. And Sketchup appears to remember what method you were sorting by, from session to session. So if you ever hit sort by color, it will be on that next time you open SU.

                    Is that what others are seeing?

                    Chris

                    Lately you've been tan, suspicious for the winter.
                    All my Plugins I've written

                    1 Reply Last reply Reply Quote 0
                    • EdsonE Offline
                      Edson
                      last edited by

                      chris,

                      one more case in which the windows and mac versions differ. i do not see another way of sorting the layers than ascending/descending.


                      layers_dialog.png

                      edson mahfuz, architect| porto alegre β€’ brasil
                      http://www.mahfuz.arq.br

                      1 Reply Last reply Reply Quote 0
                      • chrisglasierC Offline
                        chrisglasier
                        last edited by

                        @chris fullmer said:

                        1. Ruby Array:

                        I am finding that the ruby array is in the order the array was created. Is that agreed?

                        Chris

                        Yes same with scenes, components and so on
                        Layers05.png

                        Chris

                        With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

                        1 Reply Last reply Reply Quote 0
                        • EdsonE Offline
                          Edson
                          last edited by

                          @tig said:

                          Can't you click on the column's top bar and sort by that e.g. click on Name, Visible, Color... The default layer Layer0 always stays at the top ahtever you click on but the other layers sort ascending/descending by either their name, visibility or color-value [rgb?]...

                          you can do it for Name and Visible, not for Color.

                          edson mahfuz, architect| porto alegre β€’ brasil
                          http://www.mahfuz.arq.br

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

                            @edson said:

                            chris,
                            one more case in which the windows and mac versions differ. I do not see another way of sorting the layers than ascending/descending.

                            Can't you click on the column's top bar and sort by that e.g. click on Name, Visible, Color... The default layer Layer0 always stays at the top whatever you click on but the other layers sort ascending/descending by either their name, visibility or color-value [rgb?]...

                            TIG

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

                              @chris fullmer said:

                              So if you ever hit sort by color, it will be on that next time you open SU.

                              Beautiful! No more confusion here, I was sorted by color (whatever that means). Now I'm sorted by name, as everyone has been saying.

                              Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

                              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