sketchucation logo sketchucation
    • Login
    ⚠️ Attention | Having issues with Sketchucation Tools 5? Report Here

    [req]rename objects with name of the layer

    Scheduled Pinned Locked Moved Plugins
    16 Posts 3 Posters 6.4k 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.
    • renderizaR Offline
      renderiza
      last edited by

      Any suggestions for what should be the name of the plugin?
      Below are potential names...

      • Name by Layer
      • Rename by Layer
      • Entities Name by Layer
      • [Re]Name
      • Renamer

      [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

      1 Reply Last reply Reply Quote 0
      • bagateloB Offline
        bagatelo
        last edited by

        [Re] name
        I think you could create something that rename numerous things, such as materials, components, Layers, etc ...
        "Central [Re] name"
        http://sketchucation.com/forums/viewtopic.php?f=323&t=47234
        http://sketchucation.com/forums/viewtopic.php?f=323&t=53329

        While the cat's away, the mice will play

        1 Reply Last reply Reply Quote 0
        • renderizaR Offline
          renderiza
          last edited by

          @bagatelo said:

          [Re] name
          I think you could create something that rename numerous things, such as materials, components, Layers, etc ...
          "Central [Re] name"
          viewtopic.php?f=323&t=47234
          viewtopic.php?f=323&t=53329

          Really like that idea and the name "[Re]Name" is very fitting. But since that idea is more ambitious its advised to work our way there little by little.

          Maybe starting with renaming groups & components by layer for now and making that into an extension by itself with a different name than "[Re]Name".

          We can name the extension "Rename by Layer". Here is a Logo for the plugin...Any feedback is welcome.

          http://s17.postimg.org/m6twx3ekv/Logo_Default.png

          I started working on making the extension with web-dialog and plan to keep you posted on further progress...cheers!

          [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

          1 Reply Last reply Reply Quote 0
          • bagateloB Offline
            bagatelo
            last edited by

            Thanks for the work, friend.
            Very much appreciated.
            Your logo was very interesting.

            You could change the code to rename the definition name?
            The reason I asked this plugin is because I'm trying to use the plugin "Solid Quantify by TAK2HATA". It's a wonderful plugin, and I need something to easily modify the names of components. Note the attachment files.


            plugs.zip

            While the cat's away, the mice will play

            1 Reply Last reply Reply Quote 0
            • bagateloB Offline
              bagatelo
              last edited by

              Look what I have when I try to execute the last code...
              Cleared the editor
              Running the code...
              Done. Ruby says: Run aborted. Error: undefined method ‘bytesize’ for "1":String

              While the cat's away, the mice will play

              1 Reply Last reply Reply Quote 0
              • D Offline
                dedmin
                last edited by

                Great plugin! It would be useful to have "append layer name as prefix/suffix" to the component's name.

                1 Reply Last reply Reply Quote 0
                • renderizaR Offline
                  renderiza
                  last edited by

                  @dedmin said:

                  Great plugin! It would be useful to have "append layer name as prefix/suffix" to the component's name.

                  Great idea! I saw this just about when I published the first version to Plugin Store but maybe for next update your suggestion will be added.

                  Here are some links for the plugin;

                  Link Preview Image
                  SketchUp Plugins | PluginStore | SketchUcation

                  SketchUp Plugin and Extension Store by SketchUcation provides free downloads of hundreds of SketchUp extensions and plugins

                  favicon

                  (sketchucation.com)

                  http://sketchucation.com/forums/viewtopic.php?f=323&t=54165

                  Note: Something important that I noticed about definition names is that if you have 2 entities which are component instances they can't have different definition names.

                  For example;
                  Will not be named like below;
                  Layer: Door
                  component instance#1 definition name = Door - 001
                  component instance#2 definition name = Door - 002
                  component instance#3 definition name = Door - 003
                  component instance#4 definition name = Door - 004

                  They will be name like this;
                  component instance#1 definition name = Door - 004
                  component instance#2 definition name = Door - 004
                  component instance#3 definition name = Door - 004
                  component instance#4 definition name = Door - 004

                  Remember that its a rule that they must be the same. The numbers for definition name will only serve to display the total amount.

                  Cheers! 👍

                  [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    dedmin
                    last edited by

                    👍 👍 👍

                    1 Reply Last reply Reply Quote 0
                    • renderizaR Offline
                      renderiza
                      last edited by

                      @bagatelo said:

                      Look what I have when I try to execute the last code...
                      Cleared the editor
                      Running the code...
                      Done. Ruby says: Run aborted. Error: undefined method ‘bytesize’ for "1":String

                      This was an error on my part by using bytesize’ method which I will change to 'length' so it will work. Will try to update all the code example above to eliminate that issue.

                      I also published the plugin as an extension on Plugin Store as 'Rename by Layer' here is the link... http://sketchucation.com/resources/pluginstore?pln=RND_Renamer_v1.0.0

                      Also I made another topic here for future updates and stuff... http://sketchucation.com/forums/viewtopic.php?p=490834#p490834

                      Any feedback about the plugin will be great so I know that to fix on next update...Cheers! 👍

                      [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

                      1 Reply Last reply Reply Quote 0
                      • renderizaR Offline
                        renderiza
                        last edited by

                        I will eventually make an extension plugin with web-dialog that offers some options for the user. For now the code bellow displays the numbers like you suggested.

                        model = Sketchup.active_model
                        ents = model.active_entities   
                        groups = ents.grep(Sketchup;;Group)
                        components = ents.grep(Sketchup;;ComponentInstance)
                        num = 0
                        
                        groups.each do |group|
                          group.name = nil.to_s
                        end
                        
                        groups.each do |group|
                          if group.name == nil.to_s
                            num=0
                          end
                         
                          groups.each do |g|
                            if group.layer.name == g.layer.name
                              if g.name == nil.to_s
                                num+=1
                                bytenum = num.to_s.length
                                if bytenum  == 1
                                  zeros = "00"
                                end
                                if bytenum  == 2
                                  zeros = "0"
                                end
                                if bytenum  >= 3
                                  zeros = nil.to_s
                                end
                                g.name = group.layer.name.concat(" - #{zeros}#{num}")
                              end
                            end
                          end
                        end
                        
                        components.each do |component|
                          component.name = nil.to_s
                        end
                        
                        components.each do |component|
                          if component.name == nil.to_s
                            num=0
                          end
                         
                          components.each do |c|
                            if component.layer.name == c.layer.name
                              if c.name == nil.to_s
                                num+=1
                                bytenum = num.to_s.length
                                if bytenum == 1
                                  zeros = "00"
                                end
                                if bytenum == 2
                                  zeros = "0"
                                end
                                if bytenum >= 3
                                  zeros = nil.to_s
                                end
                                c.name = component.layer.name.concat(" - #{zeros}#{num}")
                              end
                            end
                          end
                        end
                        

                        Will keep you posted on further development...Cheers! 👍

                        @bagatelo said:

                        And I also like to know if we can do it in the whole model or only visible layers....

                        Right now it does it to all layer no matter if they are visible or not. But an option for only renaming visible layers could be done.

                        [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

                        1 Reply Last reply Reply Quote 0
                        • renderizaR Offline
                          renderiza
                          last edited by

                          @bagatelo said:

                          You could change the code to rename the definition name?

                          With the code below the definition name is created.

                          model = Sketchup.active_model
                          ents = model.active_entities   
                          groups = ents.grep(Sketchup;;Group)
                          components = ents.grep(Sketchup;;ComponentInstance)
                          num = 0
                          
                          groups.each do |group|
                            group.name = nil.to_s
                          end
                          
                          groups.each do |group|
                            if group.name == nil.to_s
                              num=0
                            end
                           
                            groups.each do |g|
                              if group.layer.name == g.layer.name
                                if g.name == nil.to_s
                                  num+=1
                                  bytenum = num.to_s.length
                                  if bytenum == 1
                                    zeros = "00"
                                  end
                                  if bytenum == 2
                                    zeros = "0"
                                  end
                                  if bytenum >= 3
                                    zeros = nil.to_s
                                  end
                                  g.name = group.layer.name.concat(" - #{zeros}#{num}")
                                end
                              end
                            end
                          end
                          
                          components.each do |component|
                            component.name = nil.to_s
                          end
                          
                          components.each do |component|
                            if component.name == nil.to_s
                              num=0
                            end
                           
                            components.each do |c|
                              if component.layer.name == c.layer.name
                                if c.name == nil.to_s
                                  num+=1
                                  bytenum = num.to_s.length
                                  if bytenum == 1
                                    zeros = "00"
                                  end
                                  if bytenum == 2
                                    zeros = "0"
                                  end
                                  if bytenum >= 3
                                    zeros = nil.to_s
                                  end
                                  #c.name = component.layer.name.concat(" - #{zeros}#{num}")
                                  c.definition.name = component.layer.name.concat(" - #{zeros}#{num}")
                                end
                              end
                            end
                          end
                          

                          @bagatelo said:

                          The reason I asked this plugin is because I'm trying to use the plugin "Solid Quantify by TAK2HATA". It's a wonderful plugin, and I need something to easily modify the names of components. Note the attachment files.

                          Will check it out indeed.

                          [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

                          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