by CadFather » Mon Aug 20, 2012 2:47 pm
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
Last edited by CadFather on Mon Aug 20, 2012 3:17 pm, edited 3 times in total.
-

CadFather
- PluginStore Author

-
- Posts: 1032
- Joined: Fri Nov 16, 2007 11:03 am
- Location: London, Milano, Sicily
- Name: CadFather
- Operating system: Windows
- SketchUp version: 2014
- License type: Pro
- SketchUp use: landscape architecture
- Level of SketchUp: Advanced
-
by thomthom » Mon Aug 20, 2012 3:00 pm
Requires at least SU8M1: Sketchup.active_model.materials.each_with_index { |m,i| m.name = "mat#{'%03d' % i}" }
-

thomthom
- PluginStore Author

-
- Posts: 19495
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by CadFather » Mon Aug 20, 2012 3:05 pm
Good Gracious! thanks master thom, i am as grateful as i am shocked!  EDIT: and i caught that! 
-

CadFather
- PluginStore Author

-
- Posts: 1032
- Joined: Fri Nov 16, 2007 11:03 am
- Location: London, Milano, Sicily
- Name: CadFather
- Operating system: Windows
- SketchUp version: 2014
- License type: Pro
- SketchUp use: landscape architecture
- Level of SketchUp: Advanced
-
by thomthom » Mon Aug 20, 2012 3:08 pm
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
-

thomthom
- PluginStore Author

-
- Posts: 19495
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by greatoe » Sun Aug 26, 2012 1:00 am
Does this plugin work on a Mac?
-
greatoe
-
- Posts: 58
- Joined: Sun Aug 24, 2008 7:15 pm
- Operating system: Mac
- SketchUp version: 2019
- License type: Pro
- SketchUp use: interior design
- Level of SketchUp: Advanced
by TIG » Sun Aug 26, 2012 9:41 am
It should... try it...
TIG
-

TIG
- Global Moderator
-
- Posts: 20305
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 2021
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by bagatelo » Wed Aug 29, 2012 12:52 am
thomthom wrote: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
-

bagatelo
-
- Posts: 278
- Joined: Wed Apr 16, 2008 4:55 pm
- Location: São José, Santa Catarina, Brasil
- Name: Alex Henrique
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: interior design
- Level of SketchUp: Advanced
-
by bagatelo » Mon Oct 01, 2012 1:32 pm
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
-

bagatelo
-
- Posts: 278
- Joined: Wed Apr 16, 2008 4:55 pm
- Location: São José, Santa Catarina, Brasil
- Name: Alex Henrique
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: interior design
- Level of SketchUp: Advanced
-
by thomthom » Mon Oct 01, 2012 1:40 pm
bagatelo wrote: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.
-

thomthom
- PluginStore Author

-
- Posts: 19495
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by bagatelo » Mon Oct 01, 2012 1:56 pm
thomthom wrote: 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
-

bagatelo
-
- Posts: 278
- Joined: Wed Apr 16, 2008 4:55 pm
- Location: São José, Santa Catarina, Brasil
- Name: Alex Henrique
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: interior design
- Level of SketchUp: Advanced
-
by thomthom » Mon Oct 01, 2012 2:08 pm
bagatelo wrote:thomthom wrote: 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.
-

thomthom
- PluginStore Author

-
- Posts: 19495
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by bagatelo » Sat Oct 06, 2012 2:19 pm
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
-

bagatelo
-
- Posts: 278
- Joined: Wed Apr 16, 2008 4:55 pm
- Location: São José, Santa Catarina, Brasil
- Name: Alex Henrique
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: interior design
- Level of SketchUp: Advanced
-
by bagatelo » Fri Oct 12, 2012 1:56 pm
thomthom wrote: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
-

bagatelo
-
- Posts: 278
- Joined: Wed Apr 16, 2008 4:55 pm
- Location: São José, Santa Catarina, Brasil
- Name: Alex Henrique
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: interior design
- Level of SketchUp: Advanced
-
by TIG » Fri Oct 12, 2012 2:08 pm
bagatelo wrote:thomthom wrote: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
-

TIG
- Global Moderator
-
- Posts: 20305
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 2021
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by bagatelo » Fri Oct 12, 2012 3:50 pm
TIG wrote:bagatelo wrote:thomthom wrote: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
-

bagatelo
-
- Posts: 278
- Joined: Wed Apr 16, 2008 4:55 pm
- Location: São José, Santa Catarina, Brasil
- Name: Alex Henrique
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: interior design
- Level of SketchUp: Advanced
-
by TIG » Fri Oct 12, 2012 4:09 pm
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
-

TIG
- Global Moderator
-
- Posts: 20305
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 2021
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by TIG » Fri Oct 12, 2012 4:12 pm
...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
-

TIG
- Global Moderator
-
- Posts: 20305
- Joined: Mon Nov 12, 2007 7:24 pm
- Location: Northumbria UK
- Name: TIG
- Operating system: Windows
- SketchUp version: 2021
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by bagatelo » Fri Oct 12, 2012 4:33 pm
TIG wrote:...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
-

bagatelo
-
- Posts: 278
- Joined: Wed Apr 16, 2008 4:55 pm
- Location: São José, Santa Catarina, Brasil
- Name: Alex Henrique
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: interior design
- Level of SketchUp: Advanced
-
by shannakae » Tue Feb 26, 2013 12:58 am
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???
-

shannakae
- Premium Member

-
- Posts: 127
- Joined: Thu Jan 31, 2013 3:43 pm
- Location: Cary, NC
- Name: Shanna Middleton
- Operating system: Windows
- SketchUp version: 8
- License type: Free/Make
- SketchUp use: interior design
- Level of SketchUp: Intermediate
-
by jolran » Tue Feb 26, 2013 1:55 am
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: viewtopic.php?t=17587or this ? viewtopic.php?t=48933Take care.
-

jolran
- PluginStore Author

-
- Posts: 1037
- Joined: Sun Oct 26, 2008 9:23 pm
- Location: Sweden
- Name: jolran
- Operating system: Windows
- SketchUp version: 8
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Intermediate
by shannakae » Tue Feb 26, 2013 2:17 am
jolran wrote: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: viewtopic.php?t=17587or this ? viewtopic.php?t=48933Take care.
Thanks, i will look those up. I do know about purge un-used (but I did just learn about it the other day so you are not so far off  )Thanks! I will look up the two topics and see if there is something there that works for me... I was looking at the open or create a collection section... and was going to explore how that might work for what I am trying to do...
-

shannakae
- Premium Member

-
- Posts: 127
- Joined: Thu Jan 31, 2013 3:43 pm
- Location: Cary, NC
- Name: Shanna Middleton
- Operating system: Windows
- SketchUp version: 8
- License type: Free/Make
- SketchUp use: interior design
- Level of SketchUp: Intermediate
-
by bagatelo » Thu Jun 27, 2013 5:07 pm
bagatelo wrote:TIG wrote:...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
I want to add a shurtcut for this function. Can you make a plugin for me, please? 
While the cat's away, the mice will play
-

bagatelo
-
- Posts: 278
- Joined: Wed Apr 16, 2008 4:55 pm
- Location: São José, Santa Catarina, Brasil
- Name: Alex Henrique
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: interior design
- Level of SketchUp: Advanced
-
by CadFather » Fri Jun 28, 2013 12:33 am
- Code: Select all
def matrename
Sketchup.active_model.start_operation('Rename Materials',true); Sketchup.active_model.materials.each_with_index { |m,i| m.name = "- #{'%03d' % i}"; p m.name };Sketchup.active_model.commit_operation end
if( not file_loaded? "TT_materials_renamer.rb" ) UI.menu("View").add_item("Materials Rename") { matrename.new } file_loaded("TT_materials_renamer.rb") end
-

CadFather
- PluginStore Author

-
- Posts: 1032
- Joined: Fri Nov 16, 2007 11:03 am
- Location: London, Milano, Sicily
- Name: CadFather
- Operating system: Windows
- SketchUp version: 2014
- License type: Pro
- SketchUp use: landscape architecture
- Level of SketchUp: Advanced
-
by bagatelo » Thu Jul 11, 2013 6:29 pm
CadFather wrote:- Code: Select all
def matrename
Sketchup.active_model.start_operation('Rename Materials',true); Sketchup.active_model.materials.each_with_index { |m,i| m.name = "- #{'%03d' % i}"; p m.name };Sketchup.active_model.commit_operation end
if( not file_loaded? "TT_materials_renamer.rb" ) UI.menu("View").add_item("Materials Rename") { matrename.new } file_loaded("TT_materials_renamer.rb") end
Great! Thanks! One thing that would be really interesting would be that this script index materials application in areas with higher per square meter first. Thus, a material that was on all the walls would be in first place. A material that was in small areas (a decorative object for example) would be the end of the numbering.
While the cat's away, the mice will play
-

bagatelo
-
- Posts: 278
- Joined: Wed Apr 16, 2008 4:55 pm
- Location: São José, Santa Catarina, Brasil
- Name: Alex Henrique
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: interior design
- Level of SketchUp: Advanced
-
by harvey1 » Fri Jul 12, 2013 1:52 am
Is it possible for this plugin to allow one to rename individual materials. For example, let's say my model is imported into SU as Material 1, and I'd like to rename it Window, and Material 2 to be renamed Door, etc.
-
harvey1
-
- Posts: 6
- Joined: Mon Dec 03, 2012 3:46 am
- Name: Jeff
- Operating system: Windows
- SketchUp version: 8
- License type: Free/Make
- SketchUp use: hobby
- Level of SketchUp: Beginner
by Pherim » Thu Nov 07, 2013 4:53 pm
This plugin appears to be buggy for me... it seems to be applied as soon as Sketchup has started, so when I open a file by double-clicking it in explorer, the materials get renamed immediately. The same happens when I activate the plugin via the Sketchucation Plugin Store. Will leave it deactivated until the cause is found...
-
Pherim
-
- Posts: 173
- Joined: Sat Jun 12, 2010 8:40 am
- Location: Germany
- Name: Pherim
- Operating system: Windows
- SketchUp version: 2016
- License type: Free/Make
- SketchUp use: hobby
- Level of SketchUp: Advanced
by JBJDesigns » Sun Feb 16, 2014 4:49 pm
Currently, I have this plug-in disabled (i.e., "tt_materials_renamer.rb" to "tt.materials.renamer.rbDISABLE"). Is there a way to turn this option on or off as needed. Many of my projects are uploaded into Vue 10 Esprit for rendering. I've been "building" a database of materials from SU. When the files are automatically renamed to "mat00", "mat01", etc., it's near impossible to determine whether the material has been saved to it's converted ".mat" format. Your help is appreciated. Jo Ann 
...you send them to school, you give them books, and they eat the pages...
-

JBJDesigns
- Premium Member

-
- Posts: 53
- Joined: Fri Feb 22, 2013 4:56 pm
- Name: Jo Ann Elliott
- Operating system: Windows
- SketchUp version: 2014
- License type: Free/Make
- SketchUp use: architecture
- Level of SketchUp: Intermediate
by rv1974 » Wed May 07, 2014 12:52 pm
Beware: It runs silently in background on the file opening! I managed to spoil a couple of files with this one It should be written on the top.
-
rv1974
-
- Posts: 1467
- Joined: Tue Nov 13, 2007 11:38 am
- Name: rv1974
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
by Ad Machine » 5 minutes ago
-
Ad Machine
- Robot
-
- Posts: 2012
-
Return to Plugins
|