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

    [Plugin] Material Renamer

    已排程 已置頂 已鎖定 已移動 Plugins
    29 貼文 12 Posters 28.7k 瀏覽 12 Watching
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • CadFatherC 離線
      CadFather
      最後由 CadFather 編輯

      is there any script that can change the name of all the materials? say into 'mat001', 'mat002' etc..?

      EDIT: here it is, courtesy of ThomThom 👍 (you'll find it under the edit menu)

      TT_materials_renamer.rb

      1 條回覆 最後回覆 回覆 引用 0
      • thomthomT 離線
        thomthom
        最後由 編輯

        Requires at least SU8M1:
        Sketchup.active_model.materials.each_with_index { |m,i| m.name = "mat#{'%03d' % i}" }

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

        1 條回覆 最後回覆 回覆 引用 0
        • CadFatherC 離線
          CadFather
          最後由 編輯

          Good Gracious! thanks master thom, i am as grateful as i am shocked! 😲 😄

          EDIT: and i caught that! 😎

          1 條回覆 最後回覆 回覆 引用 0
          • thomthomT 離線
            thomthom
            最後由 編輯

            Undo-able in one step:

            Sketchup.active_model.start_operation('Rename Materials',true); Sketchup.active_model.materials.each_with_index { |m,i| m.name = "mat#{'%03d' % i}"; p m.name };Sketchup.active_model.commit_operation

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

            1 條回覆 最後回覆 回覆 引用 0
            • G 離線
              greatoe
              最後由 編輯

              Does this plugin work on a Mac?

              1 條回覆 最後回覆 回覆 引用 0
              • TIGT 離線
                TIG Moderator
                最後由 編輯

                It should... try it...

                TIG

                1 條回覆 最後回覆 回覆 引用 0
                • bagateloB 離線
                  bagatelo
                  最後由 編輯

                  @thomthom said:

                  Undo-able in one step:

                  Sketchup.active_model.start_operation('Rename Materials',true); Sketchup.active_model.materials.each_with_index { |m,i| m.name = "mat#{'%03d' % i}"; p m.name };Sketchup.active_model.commit_operation

                  This lines works fine in the ruby console. But the plugin script not.
                  I loved!!!

                  While the cat's away, the mice will play

                  1 條回覆 最後回覆 回覆 引用 0
                  • bagateloB 離線
                    bagatelo
                    最後由 編輯

                    I have a large collection of materials. Many of these are repeated,
                    and the names are all messed up.
                    I wish I could organize my these materials, permanently.
                    It would be possible to create a function that creates a number X of planes or squares,
                    according to the amount of material in the scene, and apply each material
                    in each box? Or just put a material in each plan? Create plans
                    is very simple.
                    After we can use the plugin "Material consolidator" to eliminate repeated.

                    While the cat's away, the mice will play

                    1 條回覆 最後回覆 回覆 引用 0
                    • thomthomT 離線
                      thomthom
                      最後由 編輯

                      @bagatelo said:

                      I have a large collection of materials. Many of these are repeated,
                      and the names are all messed up.
                      I wish I could organize my these materials, permanently.
                      It would be possible to create a function that creates a number X of planes or squares,
                      according to the amount of material in the scene, and apply each material
                      in each box? Or just put a material in each plan? Create plans
                      is very simple.
                      After we can use the plugin "Material consolidator" to eliminate repeated.

                      CleanUp can merge material with identical properties.

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

                      1 條回覆 最後回覆 回覆 引用 0
                      • bagateloB 離線
                        bagatelo
                        最後由 編輯

                        @thomthom said:

                        CleanUp can merge material with identical properties.

                        But it works only in applied geometry or can works in the material editor also?

                        While the cat's away, the mice will play

                        1 條回覆 最後回覆 回覆 引用 0
                        • thomthomT 離線
                          thomthom
                          最後由 編輯

                          @bagatelo said:

                          @thomthom said:

                          CleanUp can merge material with identical properties.

                          But it works only in applied geometry or can works in the material editor also?

                          Materials in the current model.

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

                          1 條回覆 最後回覆 回覆 引用 0
                          • bagateloB 離線
                            bagatelo
                            最後由 編輯

                            It would be possible that the name of the material received something from RGB code and the level of opacity?

                            While the cat's away, the mice will play

                            1 條回覆 最後回覆 回覆 引用 0
                            • bagateloB 離線
                              bagatelo
                              最後由 編輯

                              @thomthom said:

                              Undo-able in one step:

                              Sketchup.active_model.start_operation('Rename Materials',true); Sketchup.active_model.materials.each_with_index { |m,i| m.name = "mat#{'%03d' % i}"; p m.name };Sketchup.active_model.commit_operation

                              Could you make a window that allowed us to enter the base name and the number of digits materials renamed?

                              While the cat's away, the mice will play

                              1 條回覆 最後回覆 回覆 引用 0
                              • TIGT 離線
                                TIG Moderator
                                最後由 編輯

                                @bagatelo said:

                                @thomthom said:

                                Undo-able in one step:

                                Sketchup.active_model.start_operation('Rename Materials',true); Sketchup.active_model.materials.each_with_index { |m,i| m.name = "mat#{'%03d' % i}"; p m.name };Sketchup.active_model.commit_operation

                                Could you make a window that allowed us to enter the base name and the number of digits materials renamed?
                                Just edit mat#{'%03d' % i} >>> "mat001" to be say my_mat#{'%06d' % i} >>> "my_mat000001"

                                TIG

                                1 條回覆 最後回覆 回覆 引用 0
                                • bagateloB 離線
                                  bagatelo
                                  最後由 編輯

                                  @tig said:

                                  @bagatelo said:

                                  @thomthom said:

                                  Undo-able in one step:

                                  Sketchup.active_model.start_operation('Rename Materials',true); Sketchup.active_model.materials.each_with_index { |m,i| m.name = "mat#{'%03d' % i}"; p m.name };Sketchup.active_model.commit_operation

                                  Could you make a window that allowed us to enter the base name and the number of digits materials renamed?
                                  Just edit mat#{'%03d' % i} >>> "mat001" to be say my_mat#{'%06d' % i} >>> "my_mat000001"

                                  I had seen it, just wanted to not have to edit these items. But that's okay.
                                  It would be possible to get the base name for the materials from file skp name automatically?

                                  While the cat's away, the mice will play

                                  1 條回覆 最後回覆 回覆 引用 0
                                  • TIGT 離線
                                    TIG Moderator
                                    最後由 編輯

                                    If you want to rename all of the materials by their RGBA then it's doable, just more awkward in a one-liner...
                                    mo=Sketchup.active_model;mo.start_operation('Rename Materials',true);ms=[];mo.materials.each_with_index{|m,i|n=m.color.red.to_s+'-'+m.color.green.to_s+'-'+m.color.blue.to_s+'-'+m.alpha.to_s;n=n+'#1' if ms.include?(n);(n.next!)while(ms.include?(n));ms<<n;m.name=n;p n};mo.commit_operation
                                    So you'll get "123-45-67-0.8". If two materials share exactly the same RGBA the second material will get a '#1' suffix to keep them uniquely named.

                                    TIG

                                    1 條回覆 最後回覆 回覆 引用 0
                                    • TIGT 離線
                                      TIG Moderator
                                      最後由 編輯

                                      @unknownuser said:

                                      ...it would be possible to get the base name for the materials from file skp name automatically?

                                      Yes, where the earlier code says
                                      m.name = "mat#{'%03d' % i}"
                                      change it to read
                                      m.name = "#{Sketchup.active_model.title}#{'%03d' % i}"

                                      TIG

                                      1 條回覆 最後回覆 回覆 引用 0
                                      • bagateloB 離線
                                        bagatelo
                                        最後由 編輯

                                        @tig said:

                                        @unknownuser said:

                                        ...it would be possible to get the base name for the materials from file skp name automatically?

                                        Yes, where the earlier code says
                                        m.name = "mat#{'%03d' % i}"
                                        change it to read
                                        m.name = "#{Sketchup.active_model.title}#{'%03d' % i}"

                                        GREAT!!! Thanks...

                                        Sketchup.active_model.start_operation('Rename Materials',true); Sketchup.active_model.materials.each_with_index { |m,i| m.name = "#{Sketchup.active_model.title}#{'%03d' % i}"; p m.name };Sketchup.active_model.commit_operation

                                        While the cat's away, the mice will play

                                        1 條回覆 最後回覆 回覆 引用 0
                                        • shannakaeS 離線
                                          shannakae
                                          最後由 編輯

                                          Not sure this has been brought up in this thread or in another, but I am looking for a way to organize my materials within each project. It would be so great to be able to organize them into folders or some sort of system that lets me group items together... I have a ton of materials in the project i am currently working on and have been trying to keep track of them by renaming them etc... but it becomes very daunting to look through them all. For example I downloaded a sketchup 3d file of books for my bookshelves in a family room I am designing... obviously I don't want to re paint all the books with colors in my model... and when I add the component into my model it also brings in all the new generic colors that further clutter up my materials library. It would be so great to create a folder or file system to group all the colors that are in the books together so that I don't get them mixed up with my other materials... needless to say it is a hot mess in my materials library. Please tell me someone has created a cool plugin for this or has a solution for me : ) Or am I missing something very obvious???


                                          materials_library.png

                                          1 條回覆 最後回覆 回覆 引用 0
                                          • jolranJ 離線
                                            jolran
                                            最後由 編輯

                                            @unknownuser said:

                                            and when I add the component into my model it also brings in all the new generic colors that further clutter up my materials library..

                                            I hate to ask. You do do know you can purge unused materials ?

                                            In case not. In the Materialpalette, click the house to get to modelmaterials.
                                            The icons furthest to the right(blueish) click and choose purge unused.

                                            Otherwise there is maybe this:

                                            http://sketchucation.com/forums/viewtopic.php?t=17587

                                            or this ?

                                            http://sketchucation.com/forums/viewtopic.php?t=48933

                                            Take care.

                                            1 條回覆 最後回覆 回覆 引用 0
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • 第一個貼文
                                              最後的貼文
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement