• Login
sketchucation logo sketchucation
  • Login
ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

[REQ] Component 'Name' Stripper

Scheduled Pinned Locked Moved Plugins
11 Posts 3 Posters 286 Views
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.
  • B Offline
    bmike
    last edited by 15 Mar 2012, 22:39

    Looking for a plugin that strips components of their 'Names'.
    These names can often be the same (when the definition is unique), and when working with other people's files I often have to clean up before I export to various materials lists.

    I tried TT Cleanup - but it didn't change anything.
    I ended up opening the drawing on my old laptop and was able to window all components and do a space bar / delete in the 'Name' field in the entity information window. Oddly, this works on PC, but doesn't seem to work on Mac...

    mike beganyi design + consulting llc

    1 Reply Last reply Reply Quote 0
    • S Offline
      sdmitch
      last edited by 16 Mar 2012, 13:56

      bmike, no plugin needed just a single statement entered in the Ruby Console will do the trick.

      Sketchup.active_model.entities.each{|e| e.name='' if e.is_a?(Sketchup;;ComponentInstance)}
      
      

      Will remove any Name assigned to a component instance. The Definition Name can be changed but not erased.

      Nothing is worthless, it can always be used as a bad example.

      http://sdmitch.blogspot.com/

      1 Reply Last reply Reply Quote 0
      • B Offline
        bmike
        last edited by 16 Mar 2012, 18:12

        @sdmitch said:

        bmike, no plugin needed just a single statement entered in the Ruby Console will do the trick.

        Sketchup.active_model.entities.each{|e| e.name='' if e.is_a?(Sketchup;;ComponentInstance)}
        > 
        

        Will remove any Name assigned to a component instance. The Definition Name can be changed but not erased.

        Thanks, will give it a go!
        I don't want to mess with the definition name - but I get into trouble when someone sends me a drawing with 100 'Posts' in it, an 80 of them are different from each other. Exports out to materials lists wrong.

        Is there a way to 'plugin'ize this so that I can pull it down from a menu, as opposed to keeping a bit of text handy?

        mike beganyi design + consulting llc

        1 Reply Last reply Reply Quote 0
        • S Offline
          sdmitch
          last edited by 17 Mar 2012, 00:02

          Copy this code and paste into a pure text editor program,ie Notepad, and save
          it to the Sketchup Plugins folder. Execute it by choosing Name Stripper from
          the plugins menu.

          #
          require 'Sketchup'
          #
          if not file_loaded?(File.basename(__FILE__))
            UI.menu('Plugins').add_item('Name Stripper') { Component_Name_Stripper.doit }
            file_loaded(File.basename(__FILE__))
          end
          #
          module Component_Name_Stripper
            def self.doit
              Sketchup.active_model.entities.each{|e| e.name='' if e.is_a?(Sketchup;;ComponentInstance)}
            end
          end
          
          

          Nothing is worthless, it can always be used as a bad example.

          http://sdmitch.blogspot.com/

          1 Reply Last reply Reply Quote 0
          • B Offline
            bmike
            last edited by 17 Mar 2012, 12:54

            Thank you!

            I'll give it a go. Was just thinking about taking apart another .rb so I could tinker with it.

            mike beganyi design + consulting llc

            1 Reply Last reply Reply Quote 0
            • B Offline
              bmike
              last edited by 18 Mar 2012, 19:58

              Did that, and this is what I get:

              Error Loading File namestripper.rb
              undefined method ` ' for main;Object
              

              mike beganyi design + consulting llc

              1 Reply Last reply Reply Quote 0
              • T Offline
                TIG Moderator
                last edited by 18 Mar 2012, 20:21

                Looks like you have a ` rather than a ' somewhere in the code 😕
                You must use a plain-text editor - like Notepad.exe.
                It can't be a wordprocessor because that will/could 'format' text breaking the tight syntax required by Ruby...
                Simple select all of the code and copy its text from the code-pane and paste into the empty file...

                TIG

                1 Reply Last reply Reply Quote 0
                • B Offline
                  bmike
                  last edited by 18 Mar 2012, 22:39

                  Hmm. Pasted it into TextEdit on the Mac. Will try something else.

                  mike beganyi design + consulting llc

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    TIG Moderator
                    last edited by 18 Mar 2012, 22:46

                    Here's the code in a .rb - compare it with yours...
                    Test both in turn in the Plugins folder, with a restart...


                    namestripper.rb

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • B Offline
                      bmike
                      last edited by 19 Mar 2012, 15:40

                      Thanks Tig!

                      Here's what I get when I pated them both into TextEdit on the Mac:

                      TIG;
                      
                      require 'Sketchup'
                      if not file_loaded?(File.basename(__FILE__))
                          UI.menu('Plugins').add_item('Name Stripper') { Component_Name_Stripper.doit }
                          file_loaded(File.basename(__FILE__))
                      end
                      module Component_Name_Stripper
                          def self.doit
                              Sketchup.active_model.entities.each{|e| e.name='' if e.is_a?(Sketchup;;ComponentInstance)}
                          end
                      end
                      
                      
                      Original;
                      
                      #
                      require 'Sketchup'
                      #
                      if not file_loaded?(File.basename(__FILE__))
                        UI.menu('Plugins').add_item('Name Stripper') { Component_Name_Stripper.doit }
                        file_loaded(File.basename(__FILE__))
                      end
                      #
                      module Component_Name_Stripper
                        def self.doit
                          Sketchup.active_model.entities.each{|e| e.name='' if e.is_a?(Sketchup;;ComponentInstance)}
                        end
                      end
                      

                      mike beganyi design + consulting llc

                      1 Reply Last reply Reply Quote 0
                      • B Offline
                        bmike
                        last edited by 19 Mar 2012, 15:45

                        Your copy is working fine directly placed in my Plugins folder... so, Thanks!

                        mike beganyi design + consulting llc

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        1 / 1
                        • First post
                          1/11
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement