[Plugin] MaterialConsolidator v1.3 20110116

[Plugin] MaterialConsolidator v1.3 20110116

Postby TIG » Sat Dec 18, 2010 3:01 pm



TIG (c) 2010
All Rights Reserved.
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES,INCLUDING,WITHOUT LIMITATION,THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.


materialconsolidator.rb


Type 'MaterialConsolidator.new' in the Ruby Console.
OR
'Menu' > 'Tools' > 'Material Consolidator'
All materials with the same 'properties' are consolidated into one, and the
rest are purged... [the progress is reported in the Console/Command-line]
It is one step undoable.


Donations:
By Paypal.com to info @ revitrev.org


Version:
1.0 20101218 First issue.
1.1 20101218 Menu added.
1.2 20101219 Listing/Sorting optimized, command-line prompts added.
1.3 20110116 Wrapped into a class 'MaterialConsolidator'.

1
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] MaterialConsolidator 20101218

Postby Gaieus » Sat Dec 18, 2010 3:17 pm

TIG wrote:All materials with the same 'properties' are consolidated into one

What do you mean by "properties"?
0
User avatar
Gaieus 
 

Re: [Plugin] MaterialConsolidator 20101218

Postby TIG » Sat Dec 18, 2010 3:27 pm

Gaieus wrote:
TIG wrote:All materials with the same 'properties' are consolidated into one

What do you mean by "properties"?

Two materials are only considered duplicates if they have exactly matching 'properties'.
These are:-
    materialType
    color RGB
    transparency [alpha]
If 'material.texture' then also:-
    texture.filename
    texture.image_width
    texture.image_height
    texture.width
    texture.height
The materials are all compared with each other.
If ANY one of their properties don't match then the compared materials are NOT duplicates and therefore they are NOT consolidated.
However, if ALL of the properties do match then the first 'duplicated material' in the list is 'kept'... all objects using these 'duplicated materials' will have them replaced with the 'kept' material [i.e. they are 'consolidated']...
On completion any now unused 'duplicated materials' are purged...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] MaterialConsolidator 20101218

Postby derei » Sat Dec 18, 2010 3:44 pm

Whoow TIG ! :D are you my Santa? :D Yesterday I was thinking that I could use something like that... and today here it is! :berserk:

Dear Santa,
Thanks for this mighty plugin and if you don't mind I would like in completion a bike, some tricky soap (the kind which colors hands in black), for my dear sister :twisted: and a candy ! :D
0
DESIGNER AND ARTIST DEREI.UK
User avatar
derei 
 

Re: [Plugin] MaterialConsolidator 20101218

Postby Gaieus » Sat Dec 18, 2010 3:46 pm

Thanks TIG for the explanation, it makes sense now. :enlight:
_______

Ah, and before I forget; many thanks for the plugin, too! :berserk:
0
User avatar
Gaieus 
 

Re: [Plugin] MaterialConsolidator 20101218

Postby autarchos » Sat Dec 18, 2010 4:30 pm

thank you so much TIG! this is a blessing. i can't tell you how many times i've downloaded models from the 3d warehouse which seem to exponentially multiply the list of materials already in my model.
0

autarchos 
 

Re: [Plugin] MaterialConsolidator 20101218

Postby Didier Bur » Sat Dec 18, 2010 4:37 pm

Hi TIG,

Are the faces that were painted with a "removed" material repainted with the consolidated one ?
I mean suppose you have 2 faces, one is painted with material m1 and the other with material m2.
If the materials have matching properties, one of them is purged, say m2.
Does the face painted with m2 repainted with the remaining m1 material ?
Thanks for all your work,
0
Didier Bur (Bytes Farmer)
Ecole Nationale Supérieure d'Architecture de Nancy (F)
http://rld.crai.archi.fr/rubylibrarydepot/
User avatar
Didier Bur 
 

Re: [Plugin] MaterialConsolidator 20101218

Postby TIG » Sat Dec 18, 2010 6:02 pm

Didier Bur wrote:Hi TIG,

Are the faces that were painted with a "removed" material repainted with the consolidated one ?
I mean suppose you have 2 faces, one is painted with material m1 and the other with material m2.
If the materials have matching properties, one of them is purged, say m2.
Does the face painted with m2 repainted with the remaining m1 material ?
Thanks for all your work,

Yes!
It ensures that only one material of the exact same 'properties' is used - this means that if m1==m2 then everything*** that used m2 now has m1 and m2 is purged if m1==m2==m3 etc m2 and m3 go and everything is m1...
---'everything' means all faces, edges, groups and component-instances etc... in the model and inside definitions too...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] MaterialConsolidator 20101218

Postby thomthom » Sat Dec 18, 2010 6:11 pm

Excellent! :thumb: :thumb:
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: [Plugin] MaterialConsolidator 20101218

Postby solo » Sat Dec 18, 2010 6:42 pm

Another awesome and needed tool, any possibility to have it available in the 'tools' drop down menu? as typing into ruby consol everytime will require me to remember the command and I have already forgotten it.
0
www.solos-art.com

I'm a social vegan, I avoid meet.
User avatar
solo 
Global Moderator
 

Re: [Plugin] MaterialConsolidator 20101218

Postby rv1974 » Sat Dec 18, 2010 6:53 pm

Awesome! It's time to clean those Augean stables.
0

rv1974 
 

Re: [Plugin] MaterialConsolidator 20101218

Postby d12dozr » Sat Dec 18, 2010 6:56 pm

:sketchstatic: Sweet! Thanks, TIG!
solo wrote:Another awesome and needed tool, any possibility to have it available in the 'tools' drop down menu? as typing into ruby consol everytime will require me to remember the command and I have already forgotten it.

+1
0
3D Printing with SketchUp Book
http://goo.gl/f7ooYh

d12dozr 
Top SketchUcator
 

Re: [Plugin] MaterialConsolidator v1.1 20101218

Postby TIG » Sat Dec 18, 2010 7:22 pm

Here's v1.1 viewtopic.php?p=295290#p295290
It now has 'Material Consolidator' under the 'Tools' menu...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] MaterialConsolidator v1.1 20101218

Postby Bob James » Sun Dec 19, 2010 6:22 am

Oh, YES!! :berserk:

Thank you, TIG
0
i7-4930K 3.4Ghz, 2x GTX780 6GB, 32GB DDR3-1600 ECC, OCZ Vertex 4 500GB, WD Black 3TB, 32TB NAS, 4x 27" Monitors, SpaceMouse Pro, X-keys XK-60
User avatar
Bob James 
Premium Member
Premium Member
 

Re: [Plugin] MaterialConsolidator v1.1 20101218

Postby rv1974 » Sun Dec 19, 2010 9:36 am

Hi TIG!
I have some important suggestion. The majority of people working in the 3D field use some prefixes in the mats\layers\camera names. It's extremely helpful to differ my stuff from the others.I for example name all my assets in this way: zzz_blahblah. And everything is inserted in the initial template file.
So what I'm asking for is ability to set the default name prioty directly in the ruby file
itself (just to set up it once and forget). In my case zzz_* formula would be dominant.
What do you think?
0

rv1974 
 

Re: [Plugin] MaterialConsolidator v1.1 20101218

Postby TIG » Sun Dec 19, 2010 10:32 am

rv1974

At the moment the first material in the database is used in preference to any other matches [the names are not considered just the position in the list], so if you have 'zzz_Material', 'zzz_Material1' and 'xxx_Material99' that are all exact matching 'clones' and 'zzz_Material' is the first one then everything becomes 'zzz_Material' and the others are purged...
I can't see how we would use 'prefixes' to sort materials [at the moment, as I said, the name is ignored and its 'order of being created' is used] :?
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] MaterialConsolidator v1.2 20101219

Postby TIG » Sun Dec 19, 2010 11:16 am

Here's v1.2 viewtopic.php?p=295290#p295290
The listing and sorting algorithms have been optimized for speed and command-line/console progress messages added...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] MaterialConsolidator v1.1 20101218

Postby rv1974 » Sun Dec 19, 2010 12:16 pm

TIG wrote:rv1974

At the moment the first material in the database is used in preference to any other matches [the names are not considered just the position in the list], so if you have 'zzz_Material', 'zzz_Material1' and 'xxx_Material99' that are all exact matching 'clones' and 'zzz_Material' is the first one then everything becomes 'zzz_Material' and the others are purged...
I can't see how we would use 'prefixes' to sort materials [at the moment, as I said, the name is ignored and its 'order of being created' is used] :?

---
order of being created is already a nice thing. The workaround is to embed a simple planes matrix with user common used materials applied into initial template.
Thank you.
0

rv1974 
 

Re: [Plugin] MaterialConsolidator 20101218

Postby rocorona » Thu Jan 06, 2011 9:50 am

TIG wrote:
Gaieus wrote:
TIG wrote:These are:-
    materialType
    color RGB
    transparency [alpha]

What is a material "type"?
I feel I'm missing something basilar, but I can't find this in the "modify material" window.
0

rocorona 
 

Re: [Plugin] MaterialConsolidator 20101218

Postby TIG » Thu Jan 06, 2011 10:22 am

rocorona wrote:
TIG wrote:
Gaieus wrote:
TIG wrote:These are:-
    materialType
    color RGB
    transparency [alpha]

What is a material "type"?
I feel I'm missing something basilar, but I can't find this in the "modify material" window.

The materialType is accessible via the API - it returns values [0/1/2] depending on if the material is simply a 'plain-color', has a 'texture' or it has a texture and it has been 'colorized'... that's all... http://code.google.com/apis/sketchup/do ... terialType
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] MaterialConsolidator v1.2 20101219

Postby rocorona » Thu Jan 06, 2011 4:37 pm

TIG, "thanks" for your reply, and "thanks" for your great and valuable work! :line:
0

rocorona 
 

Re: [Plugin] MaterialConsolidator v1.2 20101219

Postby Ecuadorian » Thu Jan 06, 2011 5:11 pm

I was thinking about this yesterday, as using FormFonts objects bloats my files with duplicate materials.

Thanks, TIG! :thumb:
0

Ecuadorian 
 

Re: [Plugin] MaterialConsolidator v1.3 20110116

Postby TIG » Sun Jan 16, 2011 3:13 pm

Here's v1.3 viewtopic.php?p=295290#p295290
It is now wrapped into its own class 'MaterialConsolidator'.
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] MaterialConsolidator v1.3 20110116

Postby headshot » Fri Feb 04, 2011 12:50 pm

GR8 !!!
TY.
0

headshot 
 

Re: [Plugin] MaterialConsolidator v1.3 20110116

Postby Staatsfeind » Mon Mar 28, 2011 12:29 pm

thank you for this useful tool !

but one question:

how do i delete unused materials that result from objects imported by
the warehouse and which i dont use anymore?

to be more exactly, i tried out several warehouse objects to fit my needs
and mixed some of them. at the end i got 50+ textures loaded but maybe only
15 are in use. deleting all by hand would take some time.

did i get something wrong ?


cheers
0

Staatsfeind 
 

Re: [Plugin] MaterialConsolidator v1.3 20110116

Postby TIG » Mon Mar 28, 2011 12:57 pm

Staatsfeind wrote:thank you for this useful tool !
but one question:
how do i delete unused materials that result from objects imported by
the warehouse and which i dont use anymore?
to be more exactly, i tried out several warehouse objects to fit my needs
and mixed some of them. at the end i got 50+ textures loaded but maybe only
15 are in use. deleting all by hand would take some time.
did i get something wrong ?
cheers
'Used' Materials are not 'purged'...
Erase all unwanted Component Instances OR go to the Component Browser and find the unwanted component, right-click its icon and pick 'Delete' - this removes it from the model/browser/data-base.
OR if there are no Instances left use Component Browser > Purge... pop-out to remove any unused Components
It's recommended that you also use Layer Browser > Purge... pop-out to remove any unused Layers [that might have been associated with Components that you have just purged]
NOW use Material Browser > Purge... pop-out to remove any unused Materials [that might have been associated with Components that you have just purged]

OR simply use Model Info > Statistics > Purge Unused... to purge them all in one go - this also includes a purge of unused Styles.

OR try my 'Purge' script which is similar but it lets you choose which kinds of thing to purge, and makes a 'report' of what's gone too...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] MaterialConsolidator v1.3 20110116

Postby Staatsfeind » Mon Mar 28, 2011 2:28 pm

hell you react fast ! ;D

thx for your answer, will give it a try.
0

Staatsfeind 
 

Re: [Plugin] MaterialConsolidator v1.3 20110116

Postby Brodie » Thu Aug 04, 2011 4:21 pm

Great plugin, thanks TIG. Not one I'll likely use very often but I just had need of it and it worked perfectly.

-Brodie
0
User avatar
Brodie 
Top SketchUcator
 

Re: [Plugin] MaterialConsolidator v1.3 20110116

Postby DavidXJ98 » Tue Aug 09, 2011 8:37 pm

Thank you for this plugin... it's quite useful.
0

DavidXJ98 
 

Re: [Plugin] MaterialConsolidator v1.3 20110116

Postby MartinK » Wed Aug 24, 2011 12:48 am

Thanks TIG, I've got just the project for this.
0

MartinK 
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Next


 

Return to Plugins

Who is online

Users browsing this forum: layercero, Pjotrdeotter, tektro11, yehoshua and 6 guests

Visit our sponsors: