[Plugin] MaterialConsolidator

percentage level

Postby bagatelo » Mon Sep 26, 2011 4:15 am

I set keyboard shortcuts for all the plugins I use.

Since this script takes a long time to complete their tasks in some files, I get confused sometimes I use the shortcuts, and inadvertently I press the shortcut for this plugin. You could insert an option to be given a warning to accept or not if we want to do cleaning?

Another interesting option is the possibility of inserting a percentage level where materials are not identical, but similar would be united into one.

It's possible to rename all the materials in words capitalized?
If we could make a clean sweep in the names would also help.
Why? Try it:
http://www.den4b.com/?x=products&product=renamer
0
While the cat's away, the mice will play
User avatar
bagatelo 
 

Re: [Plugin] MaterialConsolidator v1.3 20110116

Postby TIG » Mon Sep 26, 2011 9:31 am

First things last... ;)

You cannot 'rename' materials via the Ruby API unless you have Sketchup >= v8M1 [OR my SKMtools installed] because material.name=string doesn't exist as a method otherwise. If the method is available then this one-liner will rename ALL materials in the model using CAPITAL letters - otherwise you'll get an error message!
Code: Select all
Sketchup.active_model.materials.each{|m|m.name=m.name.upcase}

The accuracy idea would apply to what exactly ? I expect Red, Green, Blue, Alpha :?:
At the moment the code has several tests of equivalence like
next if mat.color.red != m0.color.red
You can edit the code [using a plain text editor like Notepad/Notepad++ etc] to apply an accuracy thus, where you'll define the accuracy as say per=0.01 [i.e. we'll accept it as a match if it's within 1%]. You can either hardcode the 'per' or you could get this from an added dialog as the tool runs... [see below]
So now tweak the test[s]
Code: Select all
next if mat.color.red > m0.color.red*(1+per) or mat.color.red < m0.color.red*(1-per)
Repeat this for RGB and A...

To get the accuracy from a dialog add this at the start of the code on a new line immediately after 'initialize()'
Code: Select all
results=inputbox(["0.NNN: "],[0.01],"Material Consolidator Accuracy")
return nil unless results
per=results[0]
you then enter the required accuracy in the format 0.01 =1%, 0.1 =10%, 0.5 =50% etc.
Obviously if you use the dialog to set the accuracy you do not need a line that says per=... elsewhere in the code!
If you cancel the dialog the material-consolidation is aborted.

This accuracy dialog could act as your startup prompt... BUT if you don't implement it then add this line at the start of the code instead
Code: Select all
return nil if UI.messagebox("Consolidate All Materials ?",MB_YESNO,"")==7


:ugeek:
1
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] MaterialConsolidator v1.3 20110116

Postby irwanwr » Thu Dec 01, 2011 6:51 am

thank you for the plugin :)
0
User avatar
irwanwr 
 

Re: [Plugin] MaterialConsolidator v1.3 20110116

Postby Gabbiano » Sat Apr 07, 2012 3:42 pm

Really a great plugin! :berserk:
Thank you TIG!
0

Gabbiano 
 

Re: [Plugin] MaterialConsolidator v1.3 20110116

Postby hegemonicoMX » Thu Dec 05, 2013 8:30 pm

Came down in the best moment. I had a horrible mess in the materials of a collaborative model. ;) its a blessing
0

hegemonicoMX 
 

Re: [Plugin] MaterialConsolidator v1.3 20110116

Postby Ecuadorian » Sat Jan 11, 2014 10:17 pm

Hey, TIG. How about adding some "fuzzy" logic to this? I mean, sometimes you have very similar materials that have only slightly different properties. For example, half a dozen of glasses with only slightly different tints, or slightly different alpha values, and it would be useful to consolidate them.
0

Ecuadorian 
 

Re: [Plugin] MaterialConsolidator v1.3 20110116

Postby JClements » Sat Feb 14, 2015 9:14 pm

A mighty handy plugin. Thanks!
0
John | Illustrator | Beaverton, Oregon
User avatar
JClements 
Premium Member
Premium Member
 

Re: [Plugin] MaterialConsolidator v1.3 20110116

Postby bsfranza » Fri Jul 19, 2019 12:23 pm

is there somebody out there who can compile the above mentioned "accuracy" code addon into the plugin and share it with us :)?

would be awesome!!

thanks
0

bsfranza 
 

Re: [Plugin] MaterialConsolidator

Postby TIG » Mon Jul 22, 2019 1:56 pm

Here's v2.0 which includes optional 'tolerances' for RGBA values.
So you can now consolidate colors which are almost a match !
Use it with thought...
But it is one-step undo-able !

Download


Please read the updated usage notes in the first post: http://sketchucation.com/forums/viewtop ... 90#p295290
1
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] MaterialConsolidator

Postby db11 » Mon Jul 22, 2019 2:32 pm

Thanks TIG. This will be a very useful addition to an often-used plugin.
1

db11 
 

Re: [Plugin] MaterialConsolidator

Postby pbacot » Mon Jul 22, 2019 4:31 pm

Thank you!
0
MacOSX Mojave High Sierra SketchUp Pro v19 Twilight v2 Thea v2 PowerCADD
User avatar
pbacot 
Top SketchUcator
 

Re: [Plugin] MaterialConsolidator

Postby TIG » Mon Jul 22, 2019 4:54 pm

Sorry, for any inconvenience !
Here's v3.0

Download


It tweaks any options checking - to avoid unexpected results !
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] MaterialConsolidator

Postby bsfranza » Tue Jul 23, 2019 9:09 am

WOW super many muchas gracias :)
heavily appreciated!

edit:
of course one is never satisfied for long ...

plugin works as expected now, but its kind of slow on scenes with many many polygons and the report does not state the progress or if the plugin is still working or if the app is frozen and also there are some crucial options missing...

for example: work in only on entities in active context or vice versa, ignore entities and materials of active objects

dont know if anyone is aware of the age old plugin material maintance - this one is quite fast with what it does ..

maybe someone in the future can combine them and make a proper plugin, i personally would be happy to pay for something like that :)
0

bsfranza 
 

Re: [Plugin] MaterialConsolidator

Postby 1010 Gunner » Fri Nov 15, 2019 8:44 pm

Need help with installation or use of this plugin.
'materialconsolidator' shows in my extension manager although there is no version, author etc information.
It is not showing in the 'extensions' tab

What do I need to do to get it to work?
0

1010 Gunner 
 

Re: [Plugin] MaterialConsolidator

Postby Dave R » Sat Nov 16, 2019 12:20 am

1010 Gunner wrote:What do I need to do to get it to work?


First thing I'd do is look in the Tools Menu where the instructions say it will be located. See the first post.

Screenshot - 11_15_2019 , 5_17_48 PM.png


If it's not there, then we need to look at how you went about installing it.

What version of SketchUp are you using? Your profile indicates version 7 but it had no Extension Manager.
0
Etaoin Shrdlu


%

(THERE'S NO PLACE LIKE)

G28 X0.0 Y0.0 Z0.0

M30

%
User avatar
Dave R 
Global Moderator
 

Re: [Plugin] MaterialConsolidator

Postby 1010 Gunner » Sat Nov 16, 2019 12:22 am

That's it, thank you.
0

1010 Gunner 
 

Re: [Plugin] MaterialConsolidator

Postby SirFievel33 » Thu Jan 23, 2020 8:38 pm

Hey TIG, so I'm running your program on my 150MB file with many materials (~150) and components. It seems to 'freeze' on the "Making Nested Entities List." step. Takes up a lot of CPU processing power but not seeing any progress. I'm leaving it 'running' for a few hours to give it a chance to finish. If it's not frozen and working as intended, could I suggest making some form of a progress bar or status updates, maybe even a pause option. If it's not working as intended, well, consider yourself informed. :?
0

SirFievel33 
 

Re: [Plugin] MaterialConsolidator

Postby SirFievel33 » Thu Jan 23, 2020 8:44 pm

Returned to these error messages within Ruby Console (I'm using Sketchup Pro 2019)

Material Consolidator: Tolerances: R=15 G=15 B=15 A=0
Material Consolidator: Making Material Lists
Material Consolidator: Making Entities List
Material Consolidator: Making Nested Entities List
Material Consolidator: Consolidating Materials
Error: #<NoMethodError: undefined method `display_name' for nil:NilClass>
C:/Users/###/AppData/Roaming/SketchUp/SketchUp 2019/SketchUp/Plugins/materialconsolidator.rb:202:in `block (3 levels) in new'
C:/Users/###/AppData/Roaming/SketchUp/SketchUp 2019/SketchUp/Plugins/materialconsolidator.rb:195:in `each'
C:/Users/###/AppData/Roaming/SketchUp/SketchUp 2019/SketchUp/Plugins/materialconsolidator.rb:195:in `block (2 levels) in new'
C:/Users/###/AppData/Roaming/SketchUp/SketchUp 2019/SketchUp/Plugins/materialconsolidator.rb:191:in `each'
C:/Users/###/AppData/Roaming/SketchUp/SketchUp 2019/SketchUp/Plugins/materialconsolidator.rb:191:in `block in new'
C:/Users/###/AppData/Roaming/SketchUp/SketchUp 2019/SketchUp/Plugins/materialconsolidator.rb:189:in `each'
C:/Users/###/AppData/Roaming/SketchUp/SketchUp 2019/SketchUp/Plugins/materialconsolidator.rb:189:in `new'
C:/Users/###/AppData/Roaming/SketchUp/SketchUp 2019/SketchUp/Plugins/materialconsolidator.rb:71:in `block in <module:MaterialConsolidator>'
0

SirFievel33 
 

Re: [Plugin] MaterialConsolidator

Postby TIG » Thu Jan 23, 2020 11:21 pm

I see the issue and will issue an update shortly...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] MaterialConsolidator

Postby TIG » Thu Jan 23, 2020 11:31 pm

Here's v4.0

Download


It should fix the display_name error for nil-materials...
2
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] MaterialConsolidator

Postby valerostudio » Wed Jan 29, 2020 2:18 pm

Is it possible to get some kind of progress bar with this plugin? I usually use it toward the end of a project, where I have imported a bunch of components and have a lot of materials. I ran this yesterday and I wasn't sure if SketchUp had crashed or it was still working. I let it sit overnight and it was just working away. It would be nice to know how far it has to go. Thomthoms Cleanup does a great job of doing this.
0

valerostudio 
 

Re: [Plugin] MaterialConsolidator

Postby TIG » Wed Jan 29, 2020 2:29 pm

The Ruby Console lists the key stage of its operation - open it before you start.
The bottom status_bar has a incrementing '...' to show it's doing something...
It also reports the key stages of operation...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] MaterialConsolidator

Postby melindasaur » Wed Feb 19, 2020 8:30 pm

First of all THANK YOU SO MUCH for this! This is saving me so much headache already.

It's not working for a couple of materials in one of my files. It WILL work in a new project if I apply those materials to surfaces and paste them in a new project... do you know why this might be? ie maybe it doesn't work with components?

2019 file attached
0

melindasaur 
 

Re: [Plugin] MaterialConsolidator

Postby Tom0212 » Tue Apr 14, 2020 4:49 pm

Hi TIG,
When I use the tool, it isn't doing anything..
Materials stay the same, and a consolided image is not added to my materials list.

Running Sketchup 2020.
0

Tom0212 
 

Re: [Plugin] MaterialConsolidator

Postby TIG » Wed Apr 15, 2020 11:10 am

Are you sure you understand its usage...
I just retested it in v2020 and it works fine.

When you run it it asks if you want to set RGBA 'tolerances'.
If 'No' then only materials which share the exact RGBA values are processed.
If 'Yes' then you can set a +- range of values - e.g. all materials sharing the same RGB but with a varied A[lpha] transparency will be consolidated.

Assuming some material matches are found, then it takes the first material in the list [alphanumerically] and makes that the 'base-material', then it replaces any other matching materials in the model's entities and within groups/components, with that 'base-material', and then it purges those now unused materials from the model...

Run it with the Ruby Console open to see the report...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] MaterialConsolidator

Postby Tom0212 » Thu Apr 16, 2020 9:12 pm

Hi TIG,
I'm not quite sure I used the tool correct.
Please review my attached .skp file.
0

Tom0212 
 

Re: [Plugin] MaterialConsolidator

Postby TIG » Fri Apr 17, 2020 11:15 am

In your example SKP the two materials use widely different RGB values, but these can be consolidated by giving a suitable range in the dialog.
However, they use different texture image files with different image-scaling etc, so they are seen as so different that they are not able to be processed...

Materials using textures can be consolidated, but only if the two materials use the same texture-file-name and they have the same image_height/width, and use the same texture-height/width settings.
Otherwise they are not merged into one, as they are too different...
0
TIG
User avatar
TIG 
Global Moderator
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Previous


 

Return to Plugins

Who is online

Users browsing this forum: beeamel7, lutus, sasapoli and 13 guests

Visit our sponsors: